Enlightenment CVS committal

Author  : kwo
Project : e17
Module  : libs/esmart

Dir     : e17/libs/esmart/src/lib/esmart_trans_x11


Modified Files:
        esmart_trans_x11.c 


Log Message:
Fix trans update on desktop switch.
===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/esmart/src/lib/esmart_trans_x11/esmart_trans_x11.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -3 -r1.1.1.1 -r1.2
--- esmart_trans_x11.c  5 May 2004 05:57:01 -0000       1.1.1.1
+++ esmart_trans_x11.c  28 Jun 2004 13:18:32 -0000      1.2
@@ -41,7 +41,7 @@
 static int _esmart_trans_x11_property_cb(void *data, int type, void *event);
 
 static Ecore_List       *_objects = NULL;
-static Ecore_X_Window   root;
+static Ecore_X_Window   rroot, vroot;
 static Ecore_X_Atom     rootpmap, rootcolor;
 static Ecore_X_Atom     x_virtual_roots, x_current_desktop, x_num_desktops;
 static Ecore_X_Atom     x_pixmap, x_window, x_cardinal;
@@ -79,37 +79,31 @@
 static Evas_Object *
 _esmart_trans_x11_pixmap_get(Evas *evas, Evas_Object *old, int x, int y, int w, int h)
 {
-   int                  root_list_num, num_desks = 0, ret, current_desk;
+   int                  num_desks = 0, ret, current_desk;
    unsigned char        *data;
    Evas_Object          *new = NULL;
    Ecore_X_Pixmap       p;
-   Ecore_X_Window       *root_list = NULL;
+   Ecore_X_Window       *vroot_list = NULL;
    int                  offscreen = 0;
    int                  ox = 0, oy = 0;
 
    if (old)
       evas_object_del(old);
    
-   root_list = ecore_x_window_root_list(&root_list_num);
-
-   if (root_list_num)
-      root = *root_list;
-   else
-      root = DefaultRootWindow(ecore_x_display_get());
-
    imlib_context_set_display(ecore_x_display_get());
    
imlib_context_set_visual(DefaultVisual(ecore_x_display_get(),DefaultScreen(ecore_x_display_get())));
    
imlib_context_set_colormap(DefaultColormap(ecore_x_display_get(),DefaultScreen(ecore_x_display_get())));
 
    /* Attempt to find the current virtual desktop using NetWM properties */
-   if (ecore_x_window_prop_property_get(root, x_current_desktop, 
+   vroot = rroot;      /* Fall back to real root */
+   if (ecore_x_window_prop_property_get(rroot, x_current_desktop, 
                                         x_cardinal,
                                         32, &data, &ret))
    {
       current_desk = *((int *) data);
       free (data);
 
-      if (ecore_x_window_prop_property_get(root, x_num_desktops,
+      if (ecore_x_window_prop_property_get(rroot, x_num_desktops,
                                            x_cardinal,
                                            32, &data, &ret))
       {
@@ -117,34 +111,21 @@
          free(data);
       }
       
-      if (ecore_x_window_prop_property_get(root, x_virtual_roots, x_window,
+      if (ecore_x_window_prop_property_get(rroot, x_virtual_roots, x_window,
                                            32, &data, &ret))
       {
-         if (root_list)
-            free(root_list);
-         root_list = (Ecore_X_Window *) data;
+         vroot_list = (Ecore_X_Window *) data;
 
          if (current_desk < num_desks)
-            root = root_list[current_desk];
-         
-      }
-      else
-      {
-         /* Fall back to root list provided by Xlib */
-         if (root_list && current_desk < root_list_num)
-            root = root_list[current_desk];
-         else
-            root = 0; /* Hopefully this never happens */
+            vroot = vroot_list[current_desk];
+         free(data);
       }
    }
 
-   if (root_list)
-      free(root_list);
-
    if (rootpmap)
    {
       /* Fetch the root pixmap */
-      ret = ecore_x_window_prop_property_get(root, rootpmap, 
+      ret = ecore_x_window_prop_property_get(vroot, rootpmap, 
                                              x_pixmap, 32, &data, &ret);
       if (ret && (p = *((Ecore_X_Pixmap *) data)))
       {
@@ -239,7 +220,7 @@
       evas_object_move(new, 0, 0);
       evas_object_layer_set(new, -9999);
       
-      if (ecore_x_window_prop_property_get(root, rootcolor, 
ecore_x_atom_get("CARDINAL"),
+      if (ecore_x_window_prop_property_get(vroot, rootcolor, x_cardinal,
                                            32, &data, &ret))
       {
          unsigned long pixel = *((unsigned long *) data);
@@ -269,7 +250,7 @@
 
   Ecore_List_Node *n;
 
-  static Ecore_X_Window old_root = 0;
+  static Ecore_X_Window old_vroot = 0;
 
   /* Search for requested object in list */
   for (n = _objects->first; n; n = n->next)
@@ -300,19 +281,13 @@
         }
 
         /* Check for change in desktop, update event masks accordingly */
-        if (root != old_root)
+        if (vroot != old_vroot)
         {
-           if(_root_prop_hnd)
-              ecore_event_handler_del(_root_prop_hnd);
-           if (old_root != DefaultRootWindow(ecore_x_display_get()))
-              ecore_x_event_mask_unset(old_root, ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
-           ecore_x_event_mask_set(root, ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
-           old_root = root;
+           if (old_vroot != rroot)
+              ecore_x_event_mask_unset(old_vroot, ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
+           ecore_x_event_mask_set(vroot, ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
+           old_vroot = vroot;
         }
-        
-        _root_prop_hnd = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, 
-                                                 _esmart_trans_x11_property_cb, 
-                                                 NULL);
         return;
      }
   }
@@ -377,9 +352,9 @@
    
    e = (Ecore_X_Event_Window_Property *) event;
 
-   if (e->win == root && (e->atom == rootpmap || e->atom == rootcolor
-                          || e->atom == x_current_desktop
-                          || e->atom == enlightenment_desktop))
+   if ((e->win == rroot && (e->atom == x_current_desktop ||
+                            e->atom == enlightenment_desktop)) ||
+       (e->win == vroot && (e->atom == rootpmap || e->atom == rootcolor)))
    {
       /* Background may have changed: freshen all trans objects */
       for (n = _objects->first; n; n = n->next)
@@ -397,7 +372,7 @@
          if (o->timer)
             continue;
          else
-            o->timer = ecore_timer_add(0.5, _esmart_trans_x11_timer_cb, o);
+            o->timer = ecore_timer_add(0.2, _esmart_trans_x11_timer_cb, o);
       }
    }
 
@@ -430,6 +405,14 @@
                           NULL
                           );
 
+  /* Get the real root window */
+  rroot = DefaultRootWindow(ecore_x_display_get());
+
+  ecore_x_event_mask_set(rroot, ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
+  _root_prop_hnd = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, 
+                                           _esmart_trans_x11_property_cb, 
+                                           NULL);
+
   return smart; 
 }
 




-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to