@@ -3364,8 +3364,8 @@ static bool should_keep_on_top(Ghandles *g, Window window) {
33643364
33653365
33663366/* Move a newly mapped override_redirect window below windows that need to be
3367- * kept on top, i.e. screen lockers. */
3368- static void restack_windows (Ghandles * g , struct windowdata * vm_window )
3367+ * kept on top, i.e. screen lockers. Returns new index (-1 == top of all) */
3368+ static int restack_windows (Ghandles * g , struct windowdata * vm_window )
33693369{
33703370 Window root ;
33713371 Window parent ;
@@ -3379,7 +3379,7 @@ static void restack_windows(Ghandles *g, struct windowdata *vm_window)
33793379
33803380 if (!children_list ) {
33813381 fprintf (stderr , "XQueryTree returned an empty list\n" );
3382- return ;
3382+ return 0 ;
33833383 }
33843384
33853385 /* Traverse children_list, looking for bottom-most window that
@@ -3415,6 +3415,7 @@ static void restack_windows(Ghandles *g, struct windowdata *vm_window)
34153415 }
34163416
34173417 XFree (children_list );
3418+ return goal_pos ;
34183419}
34193420
34203421
@@ -3473,7 +3474,12 @@ static void handle_map(Ghandles * g, struct windowdata *vm_window)
34733474 (void ) XMapWindow (g -> display , vm_window -> local_winid );
34743475
34753476 if (vm_window -> override_redirect ) {
3476- restack_windows (g , vm_window );
3477+ if (restack_windows (g , vm_window ) == -1 ) {
3478+ // Ensure override redirect window is raised after mapping
3479+ // But only if no screensaver is active
3480+ XRaiseWindow (g -> display , vm_window -> local_winid );
3481+ XFlush (g -> display ); // Ensure raise takes effect immediately
3482+ }
34773483 }
34783484}
34793485
0 commit comments