]> Dogcows Code - chaz/openbox/blobdiff - openbox/client.c
better buttons for inactive windows - no hover and bright lightup pressed
[chaz/openbox] / openbox / client.c
index 2f1c9c7be2cb3601648fb7a6db9675f5c438cfd2..c3e7ae6cee31e6a949a5b61b4482b6f0b9ca5663 100644 (file)
@@ -85,6 +85,7 @@ static gboolean client_restore_session_stacking(ObClient *self);
 static ObAppSettings *client_get_settings_state(ObClient *self);
 static void client_update_transient_tree(ObClient *self,
                                          ObGroup *oldgroup, ObGroup *newgroup,
 static ObAppSettings *client_get_settings_state(ObClient *self);
 static void client_update_transient_tree(ObClient *self,
                                          ObGroup *oldgroup, ObGroup *newgroup,
+                                         gboolean oldgtran, gboolean newgtran,
                                          ObClient* oldparent,
                                          ObClient *newparent);
 static void client_present(ObClient *self, gboolean here, gboolean raise);
                                          ObClient* oldparent,
                                          ObClient *newparent);
 static void client_present(ObClient *self, gboolean here, gboolean raise);
@@ -1038,7 +1039,7 @@ static void client_get_all(ObClient *self, gboolean real)
 
     client_update_wmhints(self);
     /* this may have already been called from client_update_wmhints */
 
     client_update_wmhints(self);
     /* this may have already been called from client_update_wmhints */
-    if (self->transient_for == NULL)
+    if (!self->parents && !self->transient_for_group)
         client_update_transient_for(self);
 
     client_get_startup_id(self);
         client_update_transient_for(self);
 
     client_get_startup_id(self);
@@ -1122,16 +1123,24 @@ static void client_get_desktop(ObClient *self)
         }
         if (all != screen_num_desktops) {
             self->desktop = all;
         }
         if (all != screen_num_desktops) {
             self->desktop = all;
+
+            ob_debug("client desktop set from parents: 0x%x\n",
+                     self->desktop);
         }
         /* try get from the startup-notification protocol */
         else if (sn_get_desktop(self->startup_id, &self->desktop)) {
             if (self->desktop >= screen_num_desktops &&
                 self->desktop != DESKTOP_ALL)
                 self->desktop = screen_num_desktops - 1;
         }
         /* try get from the startup-notification protocol */
         else if (sn_get_desktop(self->startup_id, &self->desktop)) {
             if (self->desktop >= screen_num_desktops &&
                 self->desktop != DESKTOP_ALL)
                 self->desktop = screen_num_desktops - 1;
+            ob_debug("client desktop set from startup-notification: 0x%x\n",
+                     self->desktop);
         }
         /* defaults to the current desktop */
         }
         /* defaults to the current desktop */
-        else
+        else {
             self->desktop = screen_desktop;
             self->desktop = screen_desktop;
+            ob_debug("client desktop set to the current desktop: %d\n",
+                     self->desktop);
+        }
     }
 }
 
     }
 }
 
@@ -1196,6 +1205,7 @@ void client_update_transient_for(ObClient *self)
 {
     Window t = None;
     ObClient *target = NULL;
 {
     Window t = None;
     ObClient *target = NULL;
+    gboolean trangroup = FALSE;
 
     if (XGetTransientForHint(ob_display, self->window, &t)) {
         if (t != self->window) { /* cant be transient to itself! */
 
     if (XGetTransientForHint(ob_display, self->window, &t)) {
         if (t != self->window) { /* cant be transient to itself! */
@@ -1207,36 +1217,41 @@ void client_update_transient_for(ObClient *self)
                    a dockapp, for example */
                 target = NULL;
             }
                    a dockapp, for example */
                 target = NULL;
             }
-
-            /* Setting the transient_for to Root is actually illegal, however
-               applications from time have done this to specify transient for
-               their group */
-            if (!target && self->group) {
-                /* not transient to a client, see if it is transient for a
-                   group */
-                if (t == RootWindow(ob_display, ob_screen)) {
-                    /* window is a transient for its group! */
-                    target = OB_TRAN_GROUP;
-                }
-            }
         }
         }
-    } else if (self->transient && self->group)
-        target = OB_TRAN_GROUP;
+
+        /* Setting the transient_for to Root is actually illegal, however
+           applications from time have done this to specify transient for
+           their group */
+        if (!target && self->group && t == RootWindow(ob_display, ob_screen))
+            trangroup = TRUE;
+    } else if (self->group && self->transient)
+        trangroup = TRUE;
 
     client_update_transient_tree(self, self->group, self->group,
 
     client_update_transient_tree(self, self->group, self->group,
-                                 self->transient_for, target);
-    self->transient_for = target;
+                                 self->transient_for_group, trangroup,
+                                 client_direct_parent(self), target);
+    self->transient_for_group = trangroup;
                           
 }
 
 static void client_update_transient_tree(ObClient *self,
                                          ObGroup *oldgroup, ObGroup *newgroup,
                           
 }
 
 static void client_update_transient_tree(ObClient *self,
                                          ObGroup *oldgroup, ObGroup *newgroup,
+                                         gboolean oldgtran, gboolean newgtran,
                                          ObClient* oldparent,
                                          ObClient *newparent)
 {
     GSList *it, *next;
     ObClient *c;
 
                                          ObClient* oldparent,
                                          ObClient *newparent)
 {
     GSList *it, *next;
     ObClient *c;
 
+    g_assert(!oldgtran || oldgroup);
+    g_assert(!newgtran || newgroup);
+    g_assert((!oldgtran && !oldparent) ||
+             (oldgtran && !oldparent) ||
+             (!oldgtran && oldparent));
+    g_assert((!newgtran && !newparent) ||
+             (newgtran && !newparent) ||
+             (!newgtran && newparent));
+
     /* * *
       Group transient windows are not allowed to have other group
       transient windows as their children.
     /* * *
       Group transient windows are not allowed to have other group
       transient windows as their children.
@@ -1244,7 +1259,9 @@ static void client_update_transient_tree(ObClient *self,
 
 
     /* No change has occured */
 
 
     /* No change has occured */
-    if (oldgroup == newgroup && oldparent == newparent) return;
+    if (oldgroup == newgroup &&
+        oldgtran == newgtran &&
+        oldparent == newparent) return;
 
     /** Remove the client from the transient tree wherever it has changed **/
 
 
     /** Remove the client from the transient tree wherever it has changed **/
 
@@ -1256,16 +1273,13 @@ static void client_update_transient_tree(ObClient *self,
        we could have any number of direct parents above up, any of which could
        be transient for the group, and we need to remove it from our children.
     */
        we could have any number of direct parents above up, any of which could
        be transient for the group, and we need to remove it from our children.
     */
-    if (oldparent != newparent &&
-        newparent != NULL && newparent != OB_TRAN_GROUP &&
-        newgroup != NULL && newgroup == oldgroup && client_normal(newparent))
+    if (!oldgtran && oldparent != newparent && newparent != NULL &&
+        newgroup != NULL && newgroup == oldgroup &&
+        client_normal(newparent))
     {
     {
-        ObClient *look = newparent;
-        do {
-            self->transients = g_slist_remove(self->transients, look);
-            look->parents = g_slist_remove(look->parents, self);
-            look = look->transient_for;
-        } while (look != NULL && look != OB_TRAN_GROUP && client_normal(look));
+        ObClient *look = client_search_top_direct_parent(newparent);
+        self->transients = g_slist_remove(self->transients, look);
+        look->parents = g_slist_remove(look->parents, self);
     }
             
 
     }
             
 
@@ -1273,9 +1287,8 @@ static void client_update_transient_tree(ObClient *self,
        group, then we need to remove any old group transient windows
        from our children. But if we were already transient for the group, then
        other group transients are not our children. */
        group, then we need to remove any old group transient windows
        from our children. But if we were already transient for the group, then
        other group transients are not our children. */
-    if ((oldgroup != newgroup ||
-         (newparent == OB_TRAN_GROUP && oldparent != newparent)) &&
-        oldgroup != NULL && oldparent != OB_TRAN_GROUP)
+    if ((oldgroup != newgroup || (newgtran && oldgtran != newgtran)) &&
+        oldgroup != NULL && !oldgtran)
     {
         for (it = self->transients; it; it = next) {
             next = g_slist_next(it);
     {
         for (it = self->transients; it; it = next) {
             next = g_slist_next(it);
@@ -1290,15 +1303,12 @@ static void client_update_transient_tree(ObClient *self,
     /* If we used to be transient for a group and now we are not, or we're
        transient for a new group, then we need to remove ourselves from all
        our ex-parents */
     /* If we used to be transient for a group and now we are not, or we're
        transient for a new group, then we need to remove ourselves from all
        our ex-parents */
-    if (oldparent == OB_TRAN_GROUP && (oldgroup != newgroup ||
-                                       oldparent != newparent))
+    if (oldgtran && (oldgroup != newgroup || oldgtran != newgtran))
     {
         for (it = self->parents; it; it = next) {
             next = g_slist_next(it);
             c = it->data;
     {
         for (it = self->parents; it; it = next) {
             next = g_slist_next(it);
             c = it->data;
-            if ((!c->transient_for || c->transient_for != OB_TRAN_GROUP) &&
-                client_normal(c))
-            {
+            if (!c->transient_for_group && client_normal(c)) {
                 c->transients = g_slist_remove(c->transients, self);
                 self->parents = g_slist_delete_link(self->parents, it);
             }
                 c->transients = g_slist_remove(c->transients, self);
                 self->parents = g_slist_delete_link(self->parents, it);
             }
@@ -1306,8 +1316,8 @@ static void client_update_transient_tree(ObClient *self,
     }
     /* If we used to be transient for a single window and we are no longer
        transient for it, then we need to remove ourself from its children */
     }
     /* If we used to be transient for a single window and we are no longer
        transient for it, then we need to remove ourself from its children */
-    else if (oldparent != NULL && oldparent != OB_TRAN_GROUP &&
-             oldparent != newparent && client_normal(oldparent))
+    else if (oldparent && oldparent != newparent &&
+             client_normal(oldparent))
     {
         oldparent->transients = g_slist_remove(oldparent->transients, self);
         self->parents = g_slist_remove(self->parents, oldparent);
     {
         oldparent->transients = g_slist_remove(oldparent->transients, self);
         self->parents = g_slist_remove(self->parents, oldparent);
@@ -1317,15 +1327,11 @@ static void client_update_transient_tree(ObClient *self,
 
     /* If we're now transient for a group and we weren't transient for it
        before then we need to add ourselves to all our new parents */
 
     /* If we're now transient for a group and we weren't transient for it
        before then we need to add ourselves to all our new parents */
-    if (newparent == OB_TRAN_GROUP && (oldgroup != newgroup ||
-                                       oldparent != newparent))
+    if (newgtran && (oldgroup != newgroup || oldgtran != newgtran))
     {
         for (it = oldgroup->members; it; it = g_slist_next(it)) {
             c = it->data;
     {
         for (it = oldgroup->members; it; it = g_slist_next(it)) {
             c = it->data;
-            if (c != self &&
-                (!c->transient_for ||
-                 c->transient_for != OB_TRAN_GROUP) &&
-                client_normal(c))
+            if (c != self && !c->transient_for_group && client_normal(c))
             {
                 c->transients = g_slist_prepend(c->transients, self);
                 self->parents = g_slist_prepend(self->parents, c);
             {
                 c->transients = g_slist_prepend(c->transients, self);
                 self->parents = g_slist_prepend(self->parents, c);
@@ -1338,8 +1344,7 @@ static void client_update_transient_tree(ObClient *self,
        WARNING: Cyclical transient ness is possible if two windows are
        transient for eachother.
     */
        WARNING: Cyclical transient ness is possible if two windows are
        transient for eachother.
     */
-    else if (newparent != NULL && newparent != OB_TRAN_GROUP &&
-             newparent != oldparent &&
+    else if (newparent && newparent != oldparent &&
              /* don't make ourself its child if it is already our child */
              !client_is_direct_child(self, newparent) &&
              client_normal(newparent))
              /* don't make ourself its child if it is already our child */
              !client_is_direct_child(self, newparent) &&
              client_normal(newparent))
@@ -1358,15 +1363,14 @@ static void client_update_transient_tree(ObClient *self,
        C is transient for B
        A can't be transient for C or we have a cycle
     */
        C is transient for B
        A can't be transient for C or we have a cycle
     */
-    if (oldgroup != newgroup && newgroup != NULL &&
-        newparent != OB_TRAN_GROUP)
+    if (oldgroup != newgroup && newgroup != NULL && !newgtran &&
+        client_normal(self))
     {
         for (it = newgroup->members; it; it = g_slist_next(it)) {
             c = it->data;
     {
         for (it = newgroup->members; it; it = g_slist_next(it)) {
             c = it->data;
-            if (c != self && c->transient_for == OB_TRAN_GROUP &&
+            if (c != self && c->transient_for_group &&
                 /* Don't make it our child if it is already our parent */
                 /* Don't make it our child if it is already our parent */
-                !client_is_direct_child(c, self) &&
-                client_normal(self))
+                !client_is_direct_child(c, self))
             {
                 self->transients = g_slist_prepend(self->transients, c);
                 c->parents = g_slist_prepend(c->parents, self);
             {
                 self->transients = g_slist_prepend(self->transients, c);
                 c->parents = g_slist_prepend(c->parents, self);
@@ -1840,8 +1844,10 @@ void client_update_wmhints(ObClient *self)
             /* Put ourselves into the new group's transient tree, and remove
                ourselves from the old group's */
             client_update_transient_tree(self, oldgroup, self->group,
             /* Put ourselves into the new group's transient tree, and remove
                ourselves from the old group's */
             client_update_transient_tree(self, oldgroup, self->group,
-                                         self->transient_for,
-                                         self->transient_for);
+                                         self->transient_for_group,
+                                         self->transient_for_group,
+                                         client_direct_parent(self),
+                                         client_direct_parent(self));
 
             /* Lastly, being in a group, or not, can change if the window is
                transient for anything.
 
             /* Lastly, being in a group, or not, can change if the window is
                transient for anything.
@@ -1851,11 +1857,11 @@ void client_update_wmhints(ObClient *self)
                transient for something, even if transient_for was NULL because
                it wasn't in a group before.
 
                transient for something, even if transient_for was NULL because
                it wasn't in a group before.
 
-               If transient_for was NULL and oldgroup was NULL we can assume
+               If parents was NULL and oldgroup was NULL we can assume
                that when we add the new group, it will become transient for
                something.
 
                that when we add the new group, it will become transient for
                something.
 
-               If transient_for was OB_TRAN_GROUP, then it must have already
+               If transient_for_group is TRUE, then it must have already
                had a group. If it is getting a new group, the above call to
                client_update_transient_tree has already taken care of
                everything ! If it is losing all group status then it will
                had a group. If it is getting a new group, the above call to
                client_update_transient_tree has already taken care of
                everything ! If it is losing all group status then it will
@@ -1863,8 +1869,8 @@ void client_update_wmhints(ObClient *self)
                updated.
             */
             if (self->transient &&
                updated.
             */
             if (self->transient &&
-                ((self->transient_for == NULL && oldgroup == NULL) ||
-                 (self->transient_for == OB_TRAN_GROUP && !self->group)))
+                ((self->parents == NULL && oldgroup == NULL) ||
+                 (self->transient_for_group && !self->group)))
                 client_update_transient_for(self);
         }
 
                 client_update_transient_for(self);
         }
 
@@ -2041,18 +2047,19 @@ void client_update_icons(ObClient *self)
 
         if ((hints = XGetWMHints(ob_display, self->window))) {
             if (hints->flags & IconPixmapHint) {
 
         if ((hints = XGetWMHints(ob_display, self->window))) {
             if (hints->flags & IconPixmapHint) {
-                self->nicons++;
+                self->nicons = 1;
                 self->icons = g_new(ObClientIcon, self->nicons);
                 xerror_set_ignore(TRUE);
                 if (!RrPixmapToRGBA(ob_rr_inst,
                                     hints->icon_pixmap,
                                     (hints->flags & IconMaskHint ?
                                      hints->icon_mask : None),
                 self->icons = g_new(ObClientIcon, self->nicons);
                 xerror_set_ignore(TRUE);
                 if (!RrPixmapToRGBA(ob_rr_inst,
                                     hints->icon_pixmap,
                                     (hints->flags & IconMaskHint ?
                                      hints->icon_mask : None),
-                                    &self->icons[self->nicons-1].width,
-                                    &self->icons[self->nicons-1].height,
-                                    &self->icons[self->nicons-1].data)){
-                    g_free(&self->icons[self->nicons-1]);
-                    self->nicons--;
+                                    &self->icons[0].width,
+                                    &self->icons[0].height,
+                                    &self->icons[0].data))
+                {
+                    g_free(self->icons);
+                    self->nicons = 0;
                 }
                 xerror_set_ignore(FALSE);
             }
                 }
                 xerror_set_ignore(FALSE);
             }
@@ -3713,7 +3720,7 @@ guint client_monitor(ObClient *self)
 ObClient *client_direct_parent(ObClient *self)
 {
     if (!self->parents) return NULL;
 ObClient *client_direct_parent(ObClient *self)
 {
     if (!self->parents) return NULL;
-    if (self->transient_for == OB_TRAN_GROUP) return NULL;
+    if (self->transient_for_group) return NULL;
     return self->parents->data;
 }                        
 
     return self->parents->data;
 }                        
 
This page took 0.031747 seconds and 4 git commands to generate.