]> Dogcows Code - chaz/openbox/blobdiff - openbox/client.c
document the per app settings in rc.xml.in. some xsd fixes. add the "default" option...
[chaz/openbox] / openbox / client.c
index 17d4c4a102bccd10216372b12272dc09a6fe743b..374ad4042dedc4a0b8fcadecdc823a8d28743836 100644 (file)
@@ -90,6 +90,9 @@ static void client_update_transient_tree(ObClient *self,
                                          ObClient* oldparent,
                                          ObClient *newparent);
 static void client_present(ObClient *self, gboolean here, gboolean raise);
+static GSList *client_search_all_top_parents_internal(ObClient *self,
+                                                      gboolean bylayer,
+                                                      ObStackingLayer layer);
 
 void client_startup(gboolean reconfig)
 {
@@ -609,6 +612,7 @@ void client_unmanage(ObClient *self)
         g_free(self->icons[j].data);
     if (self->nicons > 0)
         g_free(self->icons);
+    g_free(self->wm_command);
     g_free(self->title);
     g_free(self->icon_title);
     g_free(self->name);
@@ -635,13 +639,13 @@ static ObAppSettings *client_get_settings_state(ObClient *self)
             || (app->class && app->name && !strcmp(app->class, self->class)
                 && !strcmp(app->name, self->name)))
         {
-            ob_debug("Window matching: %s\n", app->name);
             /* Match if no role was specified in the per app setting, or if the
              * string matches the beginning of the role, since apps like to set
              * the role to things like browser-window-23c4b2f */
             if (!app->role
                 || !strncmp(app->role, self->role, strlen(app->role)))
             {
+                ob_debug("Window matching: %s\n", app->name);
                 /* use this one */
                 settings = app;
                 break;
@@ -815,7 +819,7 @@ gboolean client_find_onscreen(ObClient *self, gint *x, gint *y, gint w, gint h,
     if (!rude) {
         Point oldtl, oldtr, oldbl, oldbr;
         Point newtl, newtr, newbl, newbr;
-        gboolean stationary;
+        gboolean stationary_l, stationary_r, stationary_t, stationary_b;
 
         POINT_SET(oldtl, self->frame->area.x, self->frame->area.y);
         POINT_SET(oldbr, self->frame->area.x + self->frame->area.width - 1,
@@ -829,20 +833,22 @@ gboolean client_find_onscreen(ObClient *self, gint *x, gint *y, gint w, gint h,
         POINT_SET(newbl, newtl.x, newbr.y);
 
         /* is it moving or just resizing from some corner? */
-        stationary = (POINT_EQUAL(oldtl, newtl) || POINT_EQUAL(oldtr, newtr) ||
-                      POINT_EQUAL(oldbl, newbl) || POINT_EQUAL(oldbr, newbr));
+        stationary_l = oldtl.x == oldtl.x;
+        stationary_r = oldtr.x == oldtr.x;
+        stationary_t = oldtl.y == oldtl.y;
+        stationary_b = oldbl.y == oldbl.y;
 
-        /* if left edge is growing */
-        if (stationary && newtl.x < oldtl.x)
+        /* if left edge is growing and didnt move right edge */
+        if (stationary_r && newtl.x < oldtl.x)
             rudel = TRUE;
-        /* if right edge is growing */
-        if (stationary && newtr.x > oldtr.x)
+        /* if right edge is growing and didnt move left edge */
+        if (stationary_l && newtr.x > oldtr.x)
             ruder = TRUE;
-        /* if top edge is growing */
-        if (stationary && newtl.y < oldtl.y)
+        /* if top edge is growing and didnt move bottom edge */
+        if (stationary_b && newtl.y < oldtl.y)
             rudet = TRUE;
-        /* if bottom edge is growing */
-        if (stationary && newbl.y > oldbl.y)
+        /* if bottom edge is growing and didnt move top edge */
+        if (stationary_t && newbl.y > oldbl.y)
             rudeb = TRUE;
     }
 
@@ -989,6 +995,7 @@ static void client_get_all(ObClient *self)
     client_update_title(self);
     client_update_class(self);
     client_update_sm_client_id(self);
+    client_update_command(self);
     client_update_strut(self);
     client_update_icons(self);
     client_update_user_time(self);
@@ -2178,15 +2185,22 @@ static ObStackingLayer calc_layer(ObClient *self)
 {
     ObStackingLayer l;
 
-    if (self->fullscreen &&
-        (client_focused(self) || client_search_focus_tree(self)))
-        l = OB_STACKING_LAYER_FULLSCREEN;
-    else if (self->type == OB_CLIENT_TYPE_DESKTOP)
+    if (self->type == OB_CLIENT_TYPE_DESKTOP)
         l = OB_STACKING_LAYER_DESKTOP;
     else if (self->type == OB_CLIENT_TYPE_DOCK) {
         if (self->below) l = OB_STACKING_LAYER_NORMAL;
         else l = OB_STACKING_LAYER_ABOVE;
     }
+    else if ((self->fullscreen ||
+              /* no decorations and fills the monitor = oldskool fullscreen */
+              (self->frame != NULL &&
+               (self->frame->size.right == 0 && self->frame->size.left == 0 &&
+                self->frame->size.bottom == 0 && self->frame->size.top == 0 &&
+                RECT_EQUAL(self->area,
+                           *screen_physical_area_monitor
+                           (client_monitor(self)))))) &&
+             (client_focused(self) || client_search_focus_tree(self)))
+        l = OB_STACKING_LAYER_FULLSCREEN;
     else if (self->above) l = OB_STACKING_LAYER_ABOVE;
     else if (self->below) l = OB_STACKING_LAYER_BELOW;
     else l = OB_STACKING_LAYER_NORMAL;
@@ -2763,7 +2777,7 @@ static void client_iconify_recursive(ObClient *self,
 void client_iconify(ObClient *self, gboolean iconic, gboolean curdesk)
 {
     /* move up the transient chain as far as possible first */
-    self = client_search_top_parent(self);
+    self = client_search_top_normal_parent(self);
     client_iconify_recursive(self, iconic, curdesk);
 }
 
@@ -2958,7 +2972,7 @@ void client_set_desktop_recursive(ObClient *self,
 
 void client_set_desktop(ObClient *self, guint target, gboolean donthide)
 {
-    self = client_search_top_parent(self);
+    self = client_search_top_normal_parent(self);
     client_set_desktop_recursive(self, target, donthide);
 }
 
@@ -3295,7 +3309,7 @@ static void client_present(ObClient *self, gboolean here, gboolean raise)
         if (here)
             client_set_desktop(self, screen_desktop, FALSE);
         else
-            screen_set_desktop(self->desktop);
+            screen_set_desktop(self->desktop, FALSE);
     } else if (!self->frame->visible)
         /* if its not visible for other reasons, then don't mess
            with it */
@@ -3449,20 +3463,24 @@ guint client_monitor(ObClient *self)
     return screen_find_monitor(&self->frame->area);
 }
 
-ObClient *client_search_top_parent(ObClient *self)
+ObClient *client_search_top_normal_parent(ObClient *self)
 {
     while (self->transient_for && self->transient_for != OB_TRAN_GROUP &&
-           client_normal(self))
+           client_normal(self->transient_for))
         self = self->transient_for;
     return self;
 }
 
-GSList *client_search_all_top_parents(ObClient *self)
+static GSList *client_search_all_top_parents_internal(ObClient *self,
+                                                      gboolean bylayer,
+                                                      ObStackingLayer layer)
 {
     GSList *ret = NULL;
-
+    
     /* move up the direct transient chain as far as possible */
-    while (self->transient_for && self->transient_for != OB_TRAN_GROUP)
+    while (self->transient_for && self->transient_for != OB_TRAN_GROUP &&
+           (!bylayer || self->transient_for->layer == layer) &&
+           client_normal(self->transient_for))
         self = self->transient_for;
 
     if (!self->transient_for)
@@ -3475,8 +3493,11 @@ GSList *client_search_all_top_parents(ObClient *self)
             for (it = self->group->members; it; it = g_slist_next(it)) {
                 ObClient *c = it->data;
 
-                if (!c->transient_for && client_normal(c))
+                if (!c->transient_for && client_normal(c) &&
+                    (!bylayer || c->layer == layer))
+                {
                     ret = g_slist_prepend(ret, c);
+                }
             }
 
             if (ret == NULL) /* no group parents */
@@ -3486,6 +3507,16 @@ GSList *client_search_all_top_parents(ObClient *self)
     return ret;
 }
 
+GSList *client_search_all_top_parents(ObClient *self)
+{
+    return client_search_all_top_parents_internal(self, FALSE, 0);
+}
+
+GSList *client_search_all_top_parents_layer(ObClient *self)
+{
+    return client_search_all_top_parents_internal(self, TRUE, self->layer);
+}
+
 ObClient *client_search_focus_parent(ObClient *self)
 {
     if (self->transient_for) {
@@ -3550,20 +3581,36 @@ void client_update_sm_client_id(ObClient *self)
     g_free(self->sm_client_id);
     self->sm_client_id = NULL;
 
-    if (!PROP_GETS(self->window, sm_client_id, locale, &self->sm_client_id) &&
-        self->group) {
-        ob_debug_type(OB_DEBUG_SM, "Client %s does not have session id\n",
-                      self->title);
-        if (!PROP_GETS(self->group->leader, sm_client_id, locale,
-                       &self->sm_client_id)) {
-            ob_debug_type(OB_DEBUG_SM, "Client %s does not have session id on "
-                          "group window\n", self->title);
-        } else
-            ob_debug_type(OB_DEBUG_SM, "Client %s has session id on "
-                          "group window\n", self->title);
-    } else
-        ob_debug_type(OB_DEBUG_SM, "Client %s has session id\n",
-                      self->title);
+    if (!PROP_GETS(self->window, sm_client_id, locale, &self->sm_client_id))
+        if (self->group)
+            PROP_GETS(self->group->leader, sm_client_id, locale,
+                      &self->sm_client_id);
+}
+
+void client_update_command(ObClient *self)
+{
+    gchar **data;
+
+    g_free(self->wm_command);
+    self->wm_command = NULL;
+
+    if (PROP_GETSS(self->window, wm_command, locale, &data)) {
+        /* merge/mash them all together */
+        gchar *merge = NULL;
+        gint i;
+
+        for (i = 0; data[i]; ++i) {
+            gchar *tmp = merge;
+            if (merge)
+                merge = g_strconcat(merge, data[i], NULL);
+            else
+                merge = g_strconcat(data[i], NULL);
+            g_free(tmp);
+        }
+        g_strfreev(data);
+
+        self->wm_command = merge;
+    }
 }
 
 #define WANT_EDGE(cur, c) \
This page took 0.028609 seconds and 4 git commands to generate.