@@ -44,6 +44,7 @@ xcb_screen_t *screen = NULL; // Our current screen.
44
44
int randrbase = 0 ; // Beginning of RANDR extension events.
45
45
static uint8_t curws = 0 ; // Current workspace.
46
46
struct client * focuswin = NULL ; // Current focus window.
47
+ struct client * lastwin [WORKSPACES ]; // Last focused window.
47
48
static xcb_drawable_t top_win = 0 ; // Window always on top.
48
49
static xcb_drawable_t dock_win = 0 ; // A single dock always on top.
49
50
static struct item * winlist = NULL ; // Global list of all client windows.
@@ -66,6 +67,7 @@ static void cursor_move(const Arg *);
66
67
static void changeworkspace (const Arg * );
67
68
static void changeworkspace_helper (const uint32_t );
68
69
static void focusnext (const Arg * );
70
+ static void focuslastwin (const Arg * );
69
71
static void focusnext_helper (bool );
70
72
static void sendtoworkspace (const Arg * );
71
73
static void sendtonextworkspace (const Arg * );
@@ -190,6 +192,15 @@ focusnext(const Arg *arg)
190
192
focusnext_helper (arg -> i > 0 );
191
193
}
192
194
195
+ void
196
+ focuslastwin (const Arg * arg )
197
+ {
198
+ if (lastwin [curws ] == NULL )
199
+ return ;
200
+ raisewindow (lastwin [curws ]-> id );
201
+ setfocus (lastwin [curws ]);
202
+ }
203
+
193
204
void
194
205
delfromworkspace (struct client * client )
195
206
{
@@ -1634,6 +1645,7 @@ setfocus(struct client *client)// Set focus on window client.
1634
1645
ewmh -> _NET_ACTIVE_WINDOW , XCB_ATOM_WINDOW , 32 , 1 ,& client -> id );
1635
1646
1636
1647
/* Remember the new window as the current focused window. */
1648
+ lastwin [curws ] = focuswin ;
1637
1649
focuswin = client ;
1638
1650
1639
1651
grabbuttons (client );
@@ -2957,6 +2969,9 @@ destroynotify(xcb_generic_event_t *ev)
2957
2969
if (NULL != focuswin && focuswin -> id == e -> window )
2958
2970
focuswin = NULL ;
2959
2971
2972
+ if (NULL != lastwin [curws ] && lastwin [curws ]-> id == e -> window )
2973
+ lastwin [curws ] = NULL ;
2974
+
2960
2975
cl = findclient ( & e -> window );
2961
2976
2962
2977
/* Find this window in list of clients and forget about it. */
@@ -3061,6 +3076,9 @@ unmapnotify(xcb_generic_event_t *ev)
3061
3076
return ;
3062
3077
if (focuswin != NULL && client -> id == focuswin -> id )
3063
3078
focuswin = NULL ;
3079
+ if (lastwin [curws ]!= NULL && client -> id == lastwin [curws ]-> id )
3080
+ lastwin [curws ] = NULL ;
3081
+
3064
3082
if (client -> iconic == false)
3065
3083
forgetclient (client );
3066
3084
0 commit comments