Make RaiseLower work for the dock as well

As a side effect, _NET_RESTACK_REQUEST now also allows specifying the dock as the sibling.
This commit is contained in:
Mikael Magnusson 2014-07-12 05:19:41 +02:00
parent 7b3dc69468
commit 6273bf2e94
3 changed files with 69 additions and 15 deletions

View file

@ -1198,7 +1198,7 @@ static void event_handle_client(ObClient *client, XEvent *e)
} }
if (e->xconfigurerequest.value_mask & CWStackMode) { if (e->xconfigurerequest.value_mask & CWStackMode) {
ObClient *sibling = NULL; ObWindow *sibling = NULL;
gulong ignore_start; gulong ignore_start;
gboolean ok = TRUE; gboolean ok = TRUE;
@ -1209,7 +1209,11 @@ static void event_handle_client(ObClient *client, XEvent *e)
if (win && WINDOW_IS_CLIENT(win) && if (win && WINDOW_IS_CLIENT(win) &&
WINDOW_AS_CLIENT(win) != client) WINDOW_AS_CLIENT(win) != client)
{ {
sibling = WINDOW_AS_CLIENT(win); sibling = win;
}
else if (win && WINDOW_IS_DOCK(win))
{
sibling = win;
} }
else else
/* an invalid sibling was specified so don't restack at /* an invalid sibling was specified so don't restack at
@ -1560,13 +1564,17 @@ static void event_handle_client(ObClient *client, XEvent *e)
"invalid source indication %ld", "invalid source indication %ld",
client->title, e->xclient.data.l[0]); client->title, e->xclient.data.l[0]);
} else { } else {
ObClient *sibling = NULL; ObWindow *sibling = NULL;
if (e->xclient.data.l[1]) { if (e->xclient.data.l[1]) {
ObWindow *win = window_find(e->xclient.data.l[1]); ObWindow *win = window_find(e->xclient.data.l[1]);
if (WINDOW_IS_CLIENT(win) && if (WINDOW_IS_CLIENT(win) &&
WINDOW_AS_CLIENT(win) != client) WINDOW_AS_CLIENT(win) != client)
{ {
sibling = WINDOW_AS_CLIENT(win); sibling = win;
}
if (WINDOW_IS_DOCK(win))
{
sibling = win;
} }
if (sibling == NULL) if (sibling == NULL)
ob_debug_type(OB_DEBUG_APP_BUGS, ob_debug_type(OB_DEBUG_APP_BUGS,

View file

@ -26,6 +26,8 @@
#include "window.h" #include "window.h"
#include "event.h" #include "event.h"
#include "debug.h" #include "debug.h"
#include "dock.h"
#include "config.h"
#include "obt/prop.h" #include "obt/prop.h"
GList *stacking_list = NULL; GList *stacking_list = NULL;
@ -567,14 +569,18 @@ void stacking_add_nonintrusive(ObWindow *win)
/*! Returns TRUE if client is occluded by the sibling. If sibling is NULL it /*! Returns TRUE if client is occluded by the sibling. If sibling is NULL it
tries against all other clients. tries against all other clients.
*/ */
static gboolean stacking_occluded(ObClient *client, ObClient *sibling) static gboolean stacking_occluded(ObClient *client, ObWindow *sibling_win)
{ {
GList *it; GList *it;
gboolean occluded = FALSE; gboolean occluded = FALSE;
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 */ /* no need for any looping in this case */
if (sibling && client->layer != sibling->layer) if (sibling && client->layer != sibling->layer)
return occluded; return FALSE;
for (it = g_list_previous(g_list_find(stacking_list, client)); it; for (it = g_list_previous(g_list_find(stacking_list, client)); it;
it = g_list_previous(it)) it = g_list_previous(it))
@ -601,6 +607,21 @@ static gboolean stacking_occluded(ObClient *client, ObClient *sibling)
break; /* we past its layer */ break; /* we past its layer */
} }
} }
} 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 = TRUE;
break;
}
}
else if (config_dock_layer == client->layer) {
occluded = TRUE;
break;
}
}
} }
return occluded; return occluded;
} }
@ -608,14 +629,18 @@ static gboolean stacking_occluded(ObClient *client, ObClient *sibling)
/*! Returns TRUE if client occludes the sibling. If sibling is NULL it tries /*! Returns TRUE if client occludes the sibling. If sibling is NULL it tries
against all other clients. against all other clients.
*/ */
static gboolean stacking_occludes(ObClient *client, ObClient *sibling) static gboolean stacking_occludes(ObClient *client, ObWindow *sibling_win)
{ {
GList *it; GList *it;
gboolean occludes = FALSE; gboolean occludes = FALSE;
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 */ /* no need for any looping in this case */
if (sibling && client->layer != sibling->layer) if (sibling && client->layer != sibling->layer)
return occludes; return FALSE;
for (it = g_list_next(g_list_find(stacking_list, client)); for (it = g_list_next(g_list_find(stacking_list, client));
it; it = g_list_next(it)) it; it = g_list_next(it))
@ -643,14 +668,35 @@ static gboolean 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 = TRUE;
break;
}
}
else if (config_dock_layer == client->layer) {
occludes = TRUE;
break;
}
}
}
return occludes; return occludes;
} }
gboolean stacking_restack_request(ObClient *client, ObClient *sibling, gboolean stacking_restack_request(ObClient *client, ObWindow *sibling_win,
gint detail) gint detail)
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
ObClient *sibling = NULL;
if (sibling_win && WINDOW_IS_CLIENT(sibling_win))
sibling = WINDOW_AS_CLIENT(sibling_win);
if (sibling && ((client->desktop != sibling->desktop && if (sibling && ((client->desktop != sibling->desktop &&
client->desktop != DESKTOP_ALL && client->desktop != DESKTOP_ALL &&
sibling->desktop != DESKTOP_ALL) || sibling->desktop != DESKTOP_ALL) ||
@ -674,7 +720,7 @@ gboolean stacking_restack_request(ObClient *client, ObClient *sibling,
client->title, sibling ? sibling->title : "(all)"); client->title, sibling ? sibling->title : "(all)");
/* if this client occludes sibling (or anything if NULL), then /* if this client occludes sibling (or anything if NULL), then
lower it to the bottom */ lower it to the bottom */
if (stacking_occludes(client, sibling)) { if (stacking_occludes(client, sibling_win)) {
stacking_lower(CLIENT_AS_WINDOW(client)); stacking_lower(CLIENT_AS_WINDOW(client));
ret = TRUE; ret = TRUE;
} }
@ -688,7 +734,7 @@ gboolean stacking_restack_request(ObClient *client, ObClient *sibling,
case TopIf: case TopIf:
ob_debug("Restack request TopIf for client %s sibling %s", ob_debug("Restack request TopIf for client %s sibling %s",
client->title, sibling ? sibling->title : "(all)"); client->title, sibling ? sibling->title : "(all)");
if (stacking_occluded(client, sibling)) { if (stacking_occluded(client, sibling_win)) {
stacking_raise(CLIENT_AS_WINDOW(client)); stacking_raise(CLIENT_AS_WINDOW(client));
ret = TRUE; ret = TRUE;
} }
@ -696,11 +742,11 @@ gboolean stacking_restack_request(ObClient *client, ObClient *sibling,
case Opposite: case Opposite:
ob_debug("Restack request Opposite for client %s sibling %s", ob_debug("Restack request Opposite for client %s sibling %s",
client->title, sibling ? sibling->title : "(all)"); client->title, sibling ? sibling->title : "(all)");
if (stacking_occluded(client, sibling)) { if (stacking_occluded(client, sibling_win)) {
stacking_raise(CLIENT_AS_WINDOW(client)); stacking_raise(CLIENT_AS_WINDOW(client));
ret = TRUE; ret = TRUE;
} }
else if (stacking_occludes(client, sibling)) { else if (stacking_occludes(client, sibling_win)) {
stacking_lower(CLIENT_AS_WINDOW(client)); stacking_lower(CLIENT_AS_WINDOW(client));
ret = TRUE; ret = TRUE;
} }

View file

@ -71,7 +71,7 @@ void stacking_below(struct _ObWindow *window, struct _ObWindow *below);
/*! Restack a window based upon a sibling (or all windows) in various ways. /*! Restack a window based upon a sibling (or all windows) in various ways.
@param client The client to be restacked @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 windows
@param detail One of Above, Below, TopIf, BottomIf, Opposite @param detail One of Above, Below, TopIf, BottomIf, Opposite
@return TRUE if the client was restacked @return TRUE if the client was restacked
@ -79,7 +79,7 @@ void stacking_below(struct _ObWindow *window, struct _ObWindow *below);
how each detail works with and without a sibling. how each detail works with and without a sibling.
*/ */
gboolean stacking_restack_request(struct _ObClient *client, gboolean stacking_restack_request(struct _ObClient *client,
struct _ObClient *sibling, struct _ObWindow *sibling_win,
gint detail); gint detail);
#endif #endif