Enlightenment CVS committal

Author  : handyande
Project : misc
Module  : engage

Dir     : misc/engage/src/module


Modified Files:
        e_mod_main.h tray.c 


Log Message:
OK, so the tray protocol stuff is up and running, but with a simple layout 
routine that needs a lot of work


BUT - can someone *please* tell me why multiple system tray icons stack on top 
of each other? I cannot seem to crack it
===================================================================
RCS file: /cvsroot/enlightenment/misc/engage/src/module/e_mod_main.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- e_mod_main.h        12 Jun 2005 13:24:55 -0000      1.14
+++ e_mod_main.h        12 Jun 2005 15:32:15 -0000      1.15
@@ -47,7 +47,7 @@
    int          w, h;
    int          icons;
    Evas_List   *wins;
-   Ecore_X_Window tray_container;
+   Ecore_X_Window win;
 
    Ecore_Event_Handler *msg_handler;
    Ecore_Event_Handler *dst_handler;
===================================================================
RCS file: /cvsroot/enlightenment/misc/engage/src/module/tray.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- tray.c      12 Jun 2005 13:24:55 -0000      1.2
+++ tray.c      12 Jun 2005 15:32:15 -0000      1.3
@@ -12,9 +12,12 @@
 
 #define XEMBED_EMBEDDED_NOTIFY      0
 
-static int _engage_tray_msg_cb(void *data, int type, void *event);
-static void    _engage_bar_cb_tray_move(void *data, Evas_Object *o, Evas_Coord 
x, Evas_Coord y);
-static void    _engage_bar_cb_tray_resize(void *data, Evas_Object *o, 
Evas_Coord w, Evas_Coord h);
+static int     _engage_tray_cb_msg(void *data, int type, void *event);
+
+static void    _engage_tray_cb_move(void *data, Evas_Object *o, Evas_Coord x, 
Evas_Coord y);
+static void    _engage_tray_cb_resize(void *data, Evas_Object *o, Evas_Coord 
w, Evas_Coord h);
+
+static void    _engage_tray_layout(Engage_Bar *eb);
 
 
 void
@@ -28,42 +31,42 @@
 
    /* FIXME - temp */
    eb->tray = malloc(sizeof(Engage_Tray));
-   eb->tray->icons = 1;
-   eb->tray->w = 0;
-   eb->tray->h = 0;
+   eb->tray->icons = 0;
+   eb->tray->w = 1;
+   eb->tray->h = 1;
    eb->tray->wins = NULL;
 
    eb->tray->tray = evas_object_rectangle_add(eb->evas);
    evas_object_resize(eb->tray->tray, eb->tray->w, eb->tray->h);
-   evas_object_color_set(eb->tray->tray, 180, 180, 180, 255);
+   evas_object_color_set(eb->tray->tray, 180, 0, 0, 255);
    evas_object_show(eb->tray->tray);
-   evas_object_intercept_move_callback_add(eb->tray->tray, 
_engage_bar_cb_tray_move, eb);
-   evas_object_intercept_resize_callback_add(eb->tray->tray, 
_engage_bar_cb_tray_resize, eb);
+   evas_object_intercept_move_callback_add(eb->tray->tray, 
_engage_tray_cb_move, eb);
+   evas_object_intercept_resize_callback_add(eb->tray->tray, 
_engage_tray_cb_resize, eb);
 
   display = ecore_x_display_get();
   root = RootWindow (display, DefaultScreen(display));
 
   snprintf(buf, sizeof(buf), "_NET_SYSTEM_TRAY_S%d", DefaultScreen(display));
   selection_atom = ecore_x_atom_get(buf);
-  XSetSelectionOwner (display, selection_atom, eb->con->manager->win, 
CurrentTime);
+  XSetSelectionOwner (display, selection_atom, eb->con->bg_win, CurrentTime);
 
-  if (XGetSelectionOwner (display, selection_atom) == eb->con->manager->win) {
+  if (XGetSelectionOwner (display, selection_atom) == eb->con->bg_win) {
     printf("am a system tray :) :)\n");
 
     ecore_x_client_message32_send(root, ecore_x_atom_get("MANAGER"),
                                 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE, 
CurrentTime
 ,
-                                selection_atom, eb->con->manager->win, 0, 0);
+                                selection_atom, eb->con->bg_win, 0, 0);
   }
 
   evas_object_geometry_get(eb->tray->tray, &x, &y, &w, &h);
-  eb->tray->tray_container = ecore_x_window_new(eb->con->manager->win, x, y, 
w, h);
-  ecore_x_window_container_manage(eb->tray->tray_container);
-  ecore_x_window_background_color_set(eb->tray->tray_container, 0xcccc, 
0xcccc, 0xcccc);
-  ecore_x_window_show(eb->tray->tray_container);
+  eb->tray->win = ecore_x_window_new(eb->con->bg_win, x, y, w, h);
+  ecore_x_window_container_manage(eb->tray->win);
+  ecore_x_window_background_color_set(eb->tray->win, 0xcccc, 0xcccc, 0xcccc);
+  ecore_x_window_show(eb->tray->win);
   
-  eb->tray->msg_handler = 
ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, _engage_tray_msg_cb, eb);
-  eb->tray->dst_handler = 
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_DESTROY, _engage_tray_msg_cb, eb);
+  eb->tray->msg_handler = 
ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, _engage_tray_cb_msg, eb);
+  eb->tray->dst_handler = 
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_DESTROY, _engage_tray_cb_msg, eb);
 
 }
 
@@ -85,29 +88,32 @@
   display = ecore_x_display_get();
     
   /* we want to insert at the end, so as not to move all icons on each add */
-  eb->tray->wins = evas_list_append(eb->tray->wins, &win);
+  eb->tray->wins = evas_list_append(eb->tray->wins, (void *)win);
   eb->tray->icons++;
-    
-  XReparentWindow (display, win, eb->tray->tray_container, 0, 0);
   ecore_x_window_resize(win, 24, 24);
-//  od_tray_layout();
-//  od_dock_reposition();
+  XReparentWindow (display, win, eb->tray->win, 0, 0);
+
   ecore_x_window_show(win);
+
+  _engage_tray_layout(eb);
+
 }
 
 static void
 _engage_tray_remove(Engage_Bar *eb, Ecore_X_Window win) {
 
-  if (!evas_list_remove(eb->tray->wins, &win)) /* if was not found */
+  if (!win)
+    return;
+  if (!evas_list_find(eb->tray->wins, (void *)win)) /* if was not found */
     return;
 
+  eb->tray->wins = evas_list_remove(eb->tray->wins, (void *)win);
   eb->tray->icons--;
-//  od_tray_layout();
-//  od_dock_reposition();
+  _engage_tray_layout(eb);
 }
 
 static int
-_engage_tray_msg_cb(void *data, int type, void *event)
+_engage_tray_cb_msg(void *data, int type, void *event)
 {
   Ecore_X_Event_Client_Message *ev;
   Ecore_X_Event_Window_Destroy *dst;
@@ -116,22 +122,19 @@
   eb = data;
   if (type == ECORE_X_EVENT_CLIENT_MESSAGE) {
     ev = event;
-    printf("got message\n");
     if (ev->message_type == ecore_x_atom_get("_NET_SYSTEM_TRAY_OPCODE")) {
-printf("add\n");    
       _engage_tray_add(eb, (Ecore_X_Window) ev->data.l[2]);
       
       /* Should proto be set according to clients _XEMBED_INFO? */
       ecore_x_client_message32_send(ev->data.l[2], ecore_x_atom_get("_XEMBED"),
                                   ECORE_X_EVENT_MASK_NONE, CurrentTime,
-                                  XEMBED_EMBEDDED_NOTIFY, 0, 
eb->con->manager->win, /*proto*/1);                              
+                                  XEMBED_EMBEDDED_NOTIFY, 0, eb->con->bg_win, 
/*proto*/1);                              
 
     } else if (ev->message_type == 
ecore_x_atom_get("_NET_SYSTEM_TRAY_MESSAGE_DATA")) {
       printf("got message\n");
     } 
   } else if (type == ECORE_X_EVENT_WINDOW_DESTROY) {
-    dst = ev;
-printf("del\n");
+    dst = event;
     _engage_tray_remove(eb, (Ecore_X_Window) dst->win);
   } 
   
@@ -140,22 +143,54 @@
 }
 
 static void
-_engage_bar_cb_tray_move(void *data, Evas_Object *o, Evas_Coord x, Evas_Coord 
y)
+_engage_tray_cb_move(void *data, Evas_Object *o, Evas_Coord x, Evas_Coord y)
 {
    Engage_Bar *eb;
 
    eb = data;
    evas_object_move(o, x, y);
-   ecore_x_window_move(eb->tray->tray_container, x, y);
+   ecore_x_window_move(eb->tray->win, (int) x, (int) y);
 }
 
 static void
-_engage_bar_cb_tray_resize(void *data, Evas_Object *o, Evas_Coord w, 
Evas_Coord h)
+_engage_tray_cb_resize(void *data, Evas_Object *o, Evas_Coord w, Evas_Coord h)
 {
    Engage_Bar *eb;
 
    eb = data;
    evas_object_resize(o, w, h);
-   ecore_x_window_resize(eb->tray->tray_container, w, h);
+
+   e_box_pack_options_set(o,
+                         1, 1, /* fill */
+                         0, 0, /* expand */
+                         0.5, 0.5, /* align */
+                         w, h, /* min */
+                         w, h /* max */
+                         );
+   ecore_x_window_resize(eb->tray->win, (int) w, (int) h);
 }
 
+static void
+_engage_tray_layout(Engage_Bar *eb)
+{
+   Display *display;
+   Evas_Coord w, h;
+   int x, y;
+   Evas_List *wins;
+   
+   /* FIXME - this is a simple placeholder - need to check the height of the
+    * bar and the orientation... */
+   h = 24;
+   w = eb->tray->icons * 24;
+   evas_object_resize(eb->tray->tray, w, h);
+   
+   display = ecore_x_display_get();
+   x = 0;
+   y = 0;
+   for (wins = eb->tray->wins; wins; wins = wins->next)
+     {
+       ecore_x_window_move((Ecore_X_Window) wins->data, x, y);
+
+       x += 24;
+     }
+}




-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to