Make RaiseLower work for the dock as well
authorMikael Magnusson <mikachu@gmail.com>
Sat, 12 Jul 2014 03:19:41 +0000 (05:19 +0200)
committerMikael Magnusson <mikachu@gmail.com>
Sat, 12 Jul 2014 03:19:41 +0000 (05:19 +0200)
As a side effect, _NET_RESTACK_REQUEST now also allows specifying the dock as the sibling.

openbox/actions/lowerraiseone.c
openbox/event.c
openbox/stacking.c
openbox/stacking.h

index b41a0ed..3786e57 100644 (file)
@@ -34,7 +34,7 @@ static gboolean run_func(ObActionsData *data, gpointer options)
 
     if (data->client) {
         ObClient *client = data->client;
-        ObClient *sibling;
+        ObWindow *sibling;
         actions_client_move(data, TRUE);
         if (dir == 1) {
           sibling = stacking_occluded(client, NULL);
index fee9800..659314a 100644 (file)
@@ -1210,7 +1210,7 @@ static void event_handle_client(ObClient *client, XEvent *e)
             }
 
         if (e->xconfigurerequest.value_mask & CWStackMode) {
-            ObClient *sibling = NULL;
+            ObWindow *sibling = NULL;
             gulong ignore_start;
             gboolean ok = TRUE;
 
@@ -1221,7 +1221,11 @@ static void event_handle_client(ObClient *client, XEvent *e)
                 if (win && WINDOW_IS_CLIENT(win) &&
                     WINDOW_AS_CLIENT(win) != client)
                 {
-                    sibling = WINDOW_AS_CLIENT(win);
+                    sibling = win;
+                }
+                else if (win && WINDOW_IS_DOCK(win))
+                {
+                    sibling = win;
                 }
                 else
                     /* an invalid sibling was specified so don't restack at
@@ -1577,13 +1581,17 @@ static void event_handle_client(ObClient *client, XEvent *e)
                               "invalid source indication %ld",
                               client->title, e->xclient.data.l[0]);
             } else {
-                ObClient *sibling = NULL;
+                ObWindow *sibling = NULL;
                 if (e->xclient.data.l[1]) {
                     ObWindow *win = window_find(e->xclient.data.l[1]);
                     if (WINDOW_IS_CLIENT(win) &&
                         WINDOW_AS_CLIENT(win) != client)
                     {
-                        sibling = WINDOW_AS_CLIENT(win);
+                        sibling = win;
+                    }
+                    if (WINDOW_IS_DOCK(win))
+                    {
+                        sibling = win;
                     }
                     if (sibling == NULL)
                         ob_debug_type(OB_DEBUG_APP_BUGS,
index 43eff85..5fc0703 100644 (file)
@@ -26,6 +26,7 @@
 #include "window.h"
 #include "event.h"
 #include "debug.h"
+#include "dock.h"
 #include "obt/prop.h"
 
 GList  *stacking_list = NULL;
@@ -578,14 +579,18 @@ void stacking_add_nonintrusive(ObWindow *win)
     stacking_list_tail = g_list_last(stacking_list);
 }
 
-ObClient *stacking_occluded(ObClient *client, ObClient *sibling)
+ObWindow *stacking_occluded(ObClient *client, ObWindow *sibling_win)
 {
     GList *it;
-    ObClient *occluded = NULL;
+    ObWindow *occluded = NULL;
+    ObClient *sibling = NULL;
+
+    if (sibling_win && WINDOW_IS_CLIENT(sibling_win))
+        sibling = WINDOW_AS_CLIENT(sibling_win);
 
     /* no need for any looping in this case */
     if (sibling && client->layer != sibling->layer)
-        return occluded;
+        return NULL;
 
     for (it = g_list_previous(g_list_find(stacking_list, client)); it;
          it = g_list_previous(it))
@@ -600,12 +605,12 @@ ObClient *stacking_occluded(ObClient *client, ObClient *sibling)
                 {
                     if (sibling != NULL) {
                         if (c == sibling) {
-                            occluded = sibling;
+                            occluded = sibling_win;
                             break;
                         }
                     }
                     else if (c->layer == client->layer) {
-                        occluded = c;
+                        occluded = CLIENT_AS_WINDOW(c);
                         break;
                     }
                     else if (c->layer > client->layer)
@@ -613,17 +618,35 @@ ObClient *stacking_occluded(ObClient *client, ObClient *sibling)
                 }
             }
         }
+        else if (WINDOW_IS_DOCK(it->data)) {
+            ObDock *dock = it->data;
+            if (RECT_INTERSECTS_RECT(dock->area, client->frame->area))
+            {
+                if (sibling_win != NULL) {
+                    if (DOCK_AS_WINDOW(dock) == sibling_win) {
+                        occluded = sibling_win;
+                        break;
+                    }
+                }
+                else
+                    occluded = DOCK_AS_WINDOW(dock);
+            }
+        }
     return occluded;
 }
 
-ObClient *stacking_occludes(ObClient *client, ObClient *sibling)
+ObWindow *stacking_occludes(ObClient *client, ObWindow *sibling_win)
 {
     GList *it;
-    ObClient *occludes = NULL;
+    ObWindow *occludes = NULL;
+    ObClient *sibling = NULL;
+
+    if (sibling_win && WINDOW_IS_CLIENT(sibling_win))
+        sibling = WINDOW_AS_CLIENT(sibling_win);
 
     /* no need for any looping in this case */
     if (sibling && client->layer != sibling->layer)
-        return occludes;
+        return NULL;
 
     for (it = g_list_next(g_list_find(stacking_list, client));
          it; it = g_list_next(it))
@@ -638,12 +661,12 @@ ObClient *stacking_occludes(ObClient *client, ObClient *sibling)
                 {
                     if (sibling != NULL) {
                         if (c == sibling) {
-                            occludes = sibling;
+                            occludes = sibling_win;
                             break;
                         }
                     }
                     else if (c->layer == client->layer) {
-                        occludes = c;
+                        occludes = CLIENT_AS_WINDOW(c);
                         break;
                     }
                     else if (c->layer < client->layer)
@@ -651,14 +674,33 @@ ObClient *stacking_occludes(ObClient *client, ObClient *sibling)
                 }
             }
         }
+        else if (WINDOW_IS_DOCK(it->data)) {
+            ObDock *dock = it->data;
+            if (RECT_INTERSECTS_RECT(dock->area, client->frame->area))
+            {
+                if (sibling_win != NULL) {
+                    if (DOCK_AS_WINDOW(dock) == sibling_win) {
+                        occludes = sibling_win;
+                        break;
+                    }
+                }
+                else
+                    occludes = DOCK_AS_WINDOW(dock);
+            }
+        }
     return occludes;
 }
 
-gboolean stacking_restack_request(ObClient *client, ObClient *sibling,
+gboolean stacking_restack_request(ObClient *client, ObWindow *sibling_win,
                                   gint detail)
 {
     gboolean ret = FALSE;
 
+    ObClient *sibling;
+
+    if (sibling_win && WINDOW_IS_CLIENT(sibling_win))
+        sibling = WINDOW_AS_CLIENT(sibling_win);
+
     if (sibling && ((client->desktop != sibling->desktop &&
                      client->desktop != DESKTOP_ALL &&
                      sibling->desktop != DESKTOP_ALL) ||
@@ -682,7 +724,7 @@ gboolean stacking_restack_request(ObClient *client, ObClient *sibling,
                  client->title, sibling ? sibling->title : "(all)");
         /* if this client occludes sibling (or anything if NULL), then
            lower it to the bottom */
-        if (stacking_occludes(client, sibling)) {
+        if (stacking_occludes(client, sibling_win)) {
             stacking_lower(CLIENT_AS_WINDOW(client));
             ret = TRUE;
         }
@@ -696,7 +738,7 @@ gboolean stacking_restack_request(ObClient *client, ObClient *sibling,
     case TopIf:
         ob_debug("Restack request TopIf for client %s sibling %s",
                  client->title, sibling ? sibling->title : "(all)");
-        if (stacking_occluded(client, sibling)) {
+        if (stacking_occluded(client, sibling_win)) {
             stacking_raise(CLIENT_AS_WINDOW(client));
             ret = TRUE;
         }
@@ -704,11 +746,11 @@ gboolean stacking_restack_request(ObClient *client, ObClient *sibling,
     case Opposite:
         ob_debug("Restack request Opposite for client %s sibling %s",
                  client->title, sibling ? sibling->title : "(all)");
-        if (stacking_occluded(client, sibling)) {
+        if (stacking_occluded(client, sibling_win)) {
             stacking_raise(CLIENT_AS_WINDOW(client));
             ret = TRUE;
         }
-        else if (stacking_occludes(client, sibling)) {
+        else if (stacking_occludes(client, sibling_win)) {
             stacking_lower(CLIENT_AS_WINDOW(client));
             ret = TRUE;
         }
index c538576..dfc0a9d 100644 (file)
@@ -72,18 +72,18 @@ void stacking_below(struct _ObWindow *window, struct _ObWindow *below);
 void stacking_above(struct _ObWindow *window, struct _ObWindow *above);
 
 /*! Returns sibling if client is occluded by the sibling. If sibling is NULL it
-  tries against all other clients, then the nearest client occluding is returned.
+  tries against all other clients, then the nearest window occluding is returned.
 */
-struct _ObClient *stacking_occluded(struct _ObClient *client, struct _ObClient *sibling);
+struct _ObWindow *stacking_occluded(struct _ObClient *client, struct _ObWindow *sibling);
 
 /*! Returns sibling if client occludes the sibling. If sibling is NULL it tries
-  against all other clients, then the nearest client occluded is returned.
+  against all other clients, then the nearest window occluded is returned.
 */
-struct _ObClient *stacking_occludes(struct _ObClient *client, struct _ObClient *sibling);
+struct _ObWindow *stacking_occludes(struct _ObClient *client, struct _ObWindow *sibling);
 
 /*! Restack a window based upon a sibling (or all windows) in various ways.
   @param client The client to be restacked
-  @param sibling Another client to compare to, or NULL to compare to all
+  @param sibling A window to compare to, or NULL to compare to all
                  windows
   @param detail One of Above, Below, TopIf, BottomIf, Opposite
   @return TRUE if the client was restacked
@@ -91,7 +91,7 @@ struct _ObClient *stacking_occludes(struct _ObClient *client, struct _ObClient *
   how each detail works with and without a sibling.
 */
 gboolean stacking_restack_request(struct _ObClient *client,
-                                  struct _ObClient *sibling,
+                                  struct _ObWindow *sibling,
                                   gint detail);
 
 #endif