diff --git a/src/actions.c b/src/actions.c index 65eaa844..17dc9651 100644 --- a/src/actions.c +++ b/src/actions.c @@ -712,6 +712,9 @@ void wFullscreenWindow(WWindow *wwin) rect = wGetRectForHead(wwin->screen_ptr, head); wWindowConfigure(wwin, rect.pos.x, rect.pos.y, rect.size.width, rect.size.height); + wwin->screen_ptr->bfs_focused_window = wwin->screen_ptr->focused_window; + wSetFocusTo(wwin->screen_ptr, wwin); + WMPostNotificationName(WMNChangedState, wwin, "fullscreen"); } @@ -742,6 +745,11 @@ void wUnfullscreenWindow(WWindow *wwin) */ WMPostNotificationName(WMNChangedState, wwin, "fullscreen"); + + if (wwin->screen_ptr->bfs_focused_window) { + wSetFocusTo(wwin->screen_ptr, wwin->screen_ptr->bfs_focused_window); + wwin->screen_ptr->bfs_focused_window = NULL; + } } #ifdef ANIMATIONS diff --git a/src/screen.h b/src/screen.h index bbf57c04..97e2e48a 100644 --- a/src/screen.h +++ b/src/screen.h @@ -97,6 +97,9 @@ typedef struct _WScreen { * Use this list if you want to * traverse the entire window list */ + struct WWindow *bfs_focused_window; /* window that had focus before + * another window entered fullscreen + */ WMArray *selected_windows; diff --git a/src/window.c b/src/window.c index d590fab1..dc634c80 100644 --- a/src/window.c +++ b/src/window.c @@ -1455,6 +1455,11 @@ void wUnmanageWindow(WWindow *wwin, Bool restore, Bool destroyed) if (wwin->flags.menu_open_for_me) CloseWindowMenu(scr); + /* Don't restore focus to this window after a window exits + * fullscreen mode */ + if (scr->bfs_focused_window == wwin) + scr->bfs_focused_window = NULL; + if (!destroyed) { if (!wwin->flags.internal_window) XRemoveFromSaveSet(dpy, wwin->client_win);