diff --git a/settings-dialogs/xfwm4-settings.c b/settings-dialogs/xfwm4-settings.c index 7e1a700..5dd78a0 100644 --- a/settings-dialogs/xfwm4-settings.c +++ b/settings-dialogs/xfwm4-settings.c @@ -254,6 +254,7 @@ static const ShortcutTemplate shortcut_values[] = { { N_("Stick window"), "stick_window_key", NULL }, { N_("Raise window"), "raise_window_key", NULL }, { N_("Lower window"), "lower_window_key", NULL }, + { N_("Toggle Raise/Lower window"), "toggle_window_key", NULL }, { N_("Fill window"), "fill_window_key", NULL }, { N_("Fill window horizontally"), "fill_horiz_key", NULL }, { N_("Fill window vertically"), "fill_vert_key", NULL }, diff --git a/src/events.c b/src/events.c index eb92c58..20336f8 100644 --- a/src/events.c +++ b/src/events.c @@ -370,6 +370,9 @@ handleKeyPress (DisplayInfo *display_info, XKeyEvent * ev) case KEY_TOGGLE_FULLSCREEN: clientToggleFullscreen (c); break; + case KEY_TOGGLE_WINDOW: + clientToggleWindow (c); + break; case KEY_MOVE_NEXT_WORKSPACE: workspaceSwitch (screen_info, screen_info->current_ws + 1, c, TRUE, ev->time); break; diff --git a/src/settings.c b/src/settings.c index 78e07c6..0787c36 100644 --- a/src/settings.c +++ b/src/settings.c @@ -617,6 +617,7 @@ loadKeyBindings (ScreenInfo *screen_info) parseShortcut (screen_info, KEY_SWITCH_WINDOW, "switch_window_key", shortcuts); parseShortcut (screen_info, KEY_TOGGLE_ABOVE, "above_key", shortcuts); parseShortcut (screen_info, KEY_TOGGLE_FULLSCREEN, "fullscreen_key", shortcuts); + parseShortcut (screen_info, KEY_TOGGLE_WINDOW, "toggle_window_key", shortcuts); parseShortcut (screen_info, KEY_UP_WORKSPACE, "up_workspace_key", shortcuts); for (i = 0; i < 12; i++) diff --git a/src/settings.h b/src/settings.h index 76ffa62..4388ea6 100644 --- a/src/settings.h +++ b/src/settings.h @@ -101,6 +101,7 @@ enum KEY_SWITCH_WINDOW, KEY_TOGGLE_ABOVE, KEY_TOGGLE_FULLSCREEN, + KEY_TOGGLE_WINDOW, KEY_UP_WORKSPACE, KEY_WORKSPACE_1, KEY_WORKSPACE_2, diff --git a/src/stacking.c b/src/stacking.c index c299d74..4eb1cdc 100644 --- a/src/stacking.c +++ b/src/stacking.c @@ -539,6 +539,48 @@ clientLower (Client * c, Window wsibling) } } +void +clientToggleWindow (Client * c) +{ + GList *list; + Client *c2; + gboolean istop=TRUE; + gint x; + gint y; + + g_return_if_fail (c != NULL); + TRACE ("entering clientToggleWindow"); + TRACE ("toggling client \"%s\" (0x%lx) below (0x%lx)", c->name, c->window, wsibling); + + /* find first window on top of current */ + list= g_list_find(c->screen_info->windows_stack, (gconstpointer) c); + if (list) list= g_list_next(list); + + /* consider c on top if no other window overlaps it */ + while(list) { + c2= (Client *) list->data; + if (FLAG_TEST (c2->xfwm_flags, XFWM_FLAG_VISIBLE) + && c2->win_layer == c->win_layer) { + x= c2->x - c->x; + y= c2->y - c->y; + if ((x > 0 && x < c->width || + x + c2->width > 0 && x + c2->width < c->width) && + (y > 0 && y < c->height || + y + c2->height > 0 && y + c2->height < c->height)) { + /* overlap: 'c' is not on top */ + istop= FALSE; + break; + } + } + list= g_list_next(list); + } + + if (istop) + clientLower (c, None); + else + clientRaise (c, None); +} + gboolean clientAdjustFullscreenLayer (Client *c, gboolean set) { diff --git a/src/stacking.h b/src/stacking.h index cfe4121..3294466 100644 --- a/src/stacking.h +++ b/src/stacking.h @@ -50,6 +50,7 @@ void clientRaise (Client *, Window); void clientLower (Client *, Window); +void clientToggleWindow (Client * c); gboolean clientAdjustFullscreenLayer (Client *, gboolean); void clientAddToList (Client *);