ecore/wayland: Add title_set and class_name_set APIs.

These two APIs will save the title and class_name inside
Ecore_Wl_Window, so if they are called before the shell surface is
created, the stored names will be used later when the window is finally
shown (shell surface is created).

This way we are also hiding the shell surface from ecore_evas modules.
This commit is contained in:
Rafael Antognolli 2013-11-01 11:38:05 -02:00
parent a63c69cac5
commit 1c33a1a57b
5 changed files with 44 additions and 20 deletions

View File

@ -127,6 +127,9 @@ struct _Ecore_Wl_Window
int id, surface_id;
int rotation;
const char *title;
const char *class_name;
Eina_Rectangle allocation;
struct
@ -627,7 +630,10 @@ EAPI void ecore_wl_window_cursor_from_name_set(Ecore_Wl_Window *win, const char
EAPI void ecore_wl_window_cursor_default_restore(Ecore_Wl_Window *win);
EAPI void ecore_wl_window_parent_set(Ecore_Wl_Window *win, Ecore_Wl_Window *parent);
EAPI int ecore_wl_window_id_get(Ecore_Wl_Window *win);
EAPI void ecore_wl_window_title_set(Ecore_Wl_Window *win, const char *title);
EAPI void ecore_wl_window_class_name_set(Ecore_Wl_Window *win, const char *class_name);
/**
* Returns a wl_surface with no association to any wl_shell_surface.

View File

@ -86,6 +86,9 @@ ecore_wl_window_new(Ecore_Wl_Window *parent, int x, int y, int w, int h, int buf
win->opaque.w = w;
win->opaque.h = h;
win->title = NULL;
win->class_name = NULL;
eina_hash_add(_windows, _ecore_wl_window_id_str_get(win->id), win);
return win;
}
@ -121,6 +124,9 @@ ecore_wl_window_free(Ecore_Wl_Window *win)
if (win->surface) wl_surface_destroy(win->surface);
win->surface = NULL;
if (win->title) eina_stringshare_del(win->title);
if (win->class_name) eina_stringshare_del(win->class_name);
/* HMMM, why was this disabled ? */
free(win);
}
@ -258,6 +264,8 @@ ecore_wl_window_show(Ecore_Wl_Window *win)
win->shell_surface =
wl_shell_get_shell_surface(_ecore_wl_disp->wl.shell,
win->surface);
wl_shell_surface_set_title(win->shell_surface, win->title);
wl_shell_surface_set_class(win->shell_surface, win->class_name);
}
if (win->shell_surface)
@ -679,6 +687,32 @@ ecore_wl_window_id_get(Ecore_Wl_Window *win)
return win->id;
}
/* @since 1.8 */
EAPI void
ecore_wl_window_title_set(Ecore_Wl_Window *win, const char *title)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!win) return;
eina_stringshare_replace(&win->title, title);
if (win->shell_surface)
wl_shell_surface_set_title(win->shell_surface, win->title);
}
/* @since 1.8 */
EAPI void
ecore_wl_window_class_name_set(Ecore_Wl_Window *win, const char *class_name)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!win) return;
eina_stringshare_replace(&win->class_name, class_name);
if (win->shell_surface)
wl_shell_surface_set_class(win->shell_surface, win->class_name);
}
/* local functions */
static void

View File

@ -920,9 +920,8 @@ _ecore_evas_wl_common_title_set(Ecore_Evas *ee, const char *title)
evas_object_text_text_set(sd->text, ee->prop.title);
}
if ((ee->prop.title) && (wdata->win->shell_surface))
wl_shell_surface_set_title(wdata->win->shell_surface,
ee->prop.title);
if (ee->prop.title)
ecore_wl_window_title_set(wdata->win, ee->prop.title);
}
void
@ -941,9 +940,8 @@ _ecore_evas_wl_common_name_class_set(Ecore_Evas *ee, const char *n, const char *
if (n) ee->prop.name = strdup(n);
if (c) ee->prop.clas = strdup(c);
if ((ee->prop.clas) && (wdata->win->shell_surface))
wl_shell_surface_set_class(wdata->win->shell_surface,
ee->prop.clas);
if (ee->prop.clas)
ecore_wl_window_class_name_set(wdata->win, ee->prop.clas);
}
void

View File

@ -389,13 +389,6 @@ _ecore_evas_wl_show(Ecore_Evas *ee)
/* einfo->info.surface = ecore_wl_window_surface_get(wdata->win); */
/* evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); */
/* } */
if ((ee->prop.clas) && (wdata->win->shell_surface))
wl_shell_surface_set_class(wdata->win->shell_surface,
ee->prop.clas);
if ((ee->prop.title) && (wdata->win->shell_surface))
wl_shell_surface_set_title(wdata->win->shell_surface,
ee->prop.title);
}
if (wdata->frame)

View File

@ -388,13 +388,6 @@ _ecore_evas_wl_show(Ecore_Evas *ee)
evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
}
}
if ((ee->prop.clas) && (wdata->win->shell_surface))
wl_shell_surface_set_class(wdata->win->shell_surface,
ee->prop.clas);
if ((ee->prop.title) && (wdata->win->shell_surface))
wl_shell_surface_set_title(wdata->win->shell_surface,
ee->prop.title);
}
if (wdata->frame)