ecore/wayland: Add title_set and class_name_set APIs.
authorRafael Antognolli <rafael.antognolli@intel.com>
Fri, 1 Nov 2013 13:38:05 +0000 (11:38 -0200)
committerRafael Antognolli <rafael.antognolli@intel.com>
Fri, 1 Nov 2013 17:07:48 +0000 (15:07 -0200)
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.

src/lib/ecore_wayland/Ecore_Wayland.h
src/lib/ecore_wayland/ecore_wl_window.c
src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_egl.c
src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_shm.c

index 424e3db..387c9f2 100644 (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.
index 4c40a62..8059f44 100644 (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 
index 4a1628e..705d588 100644 (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
index e0bb743..4e32009 100644 (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)
index 5542173..2e3a352 100644 (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)