From 8161a84a50dde1a2af5707b25e2130ea2819470a Mon Sep 17 00:00:00 2001 From: sabetts Date: Fri, 1 Jun 2001 11:33:51 +0000 Subject: transients appear overtop of other windows --- src/events.c | 23 ++++++++++++-- src/list.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- src/list.h | 2 ++ src/manage.c | 14 ++++++++ src/manage.h | 1 + src/split.c | 1 + 6 files changed, 139 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/events.c b/src/events.c index 26edccb..bb1ddbc 100644 --- a/src/events.c +++ b/src/events.c @@ -58,12 +58,31 @@ new_window (XCreateWindowEvent *e) static void cleanup_frame (rp_window_frame *frame) { - frame->win = find_window_other (); - if (frame->win) + rp_window *win; + + win = find_window_other (); + if (win) { + if (frame->win->transient + && find_window (win->transient_for) == frame->win) + { + } + else + { + hide_transient_for (frame->win); + } + + frame->win = win; + maximize (frame->win); + unhide_transient_for (frame->win); unhide_window (frame->win); } + else + { + hide_transient_for (frame->win); + frame->win = NULL; + } } void diff --git a/src/list.c b/src/list.c index 750221e..a53d0b8 100644 --- a/src/list.c +++ b/src/list.c @@ -402,6 +402,61 @@ give_window_focus (rp_window *win, rp_window *last_win) XSync (dpy, False); } +void +unhide_transient_for (rp_window *win) +{ + rp_window_frame *frame; + rp_window *transient_for; + + if (win == NULL) return; + if (!win->transient) return; + frame = find_windows_frame (win); + + transient_for = find_window (win->transient_for); + if (find_windows_frame (transient_for) == NULL) + { + frame->win = transient_for; + maximize (transient_for); + + PRINT_DEBUG ("unhide transient window: %s\n", transient_for->name); + + unhide_below_window (transient_for); + + if (transient_for->transient) + { + unhide_transient_for (transient_for); + } + + frame->win = win; + } + else if (transient_for->transient) + { + unhide_transient_for (transient_for); + } +} + +void +hide_transient_for (rp_window *win) +{ + rp_window *transient_for; + + if (win == NULL) return; + if (!win->transient) return; + + transient_for = find_window (win->transient_for); + if (find_windows_frame (transient_for) == NULL) + { + PRINT_DEBUG ("hide transient window: %s\n", transient_for->name); + hide_window (transient_for); + } + + if (transient_for->transient) + { + hide_transient_for (transient_for); + } +} + + void set_active_window (rp_window *win) { @@ -412,14 +467,57 @@ set_active_window (rp_window *win) last_win = rp_current_frame->win; rp_current_frame->win = win; + if (last_win) PRINT_DEBUG ("last window: %s\n", last_win->name); + PRINT_DEBUG ("new window: %s\n", win->name); + + if (win->transient + && find_window (win->transient_for) == last_win) + { + /* Do nothing if the transient is already in the frame */ + } + else + { + hide_window (last_win); + } + + hide_transient_for (last_win); + /* Make sure the window comes up full screen */ + unhide_transient_for (win); maximize (win); unhide_window (win); - give_window_focus (win, last_win); - hide_window (last_win); + + /* hide the old active window */ +/* if (win->transient */ +/* && find_window (win->transient_for) == last_win) */ +/* { */ +/* /\* Do nothing if the transient is already in the frame *\/ */ +/* } */ +/* else */ +/* { */ +/* if (last_win) */ +/* { */ +/* if(win->transient && last_win->transient */ +/* && find_window (win->transient_for) == find_window (last_win->transient_for)) */ +/* { */ +/* /\* Do nothing if last win's transient is already in the */ +/* frame. *\/ */ +/* } */ +/* else */ +/* { */ +/* hide_transient_for (last_win); */ +/* } */ + +/* hide_window (last_win); */ +/* } */ + + give_window_focus (win, last_win); +/* } */ /* Make sure the program bar is always on the top */ update_window_names (win->scr); + + XSync (dpy, False); } /* Go to the window, switching frames if the window is already in a diff --git a/src/list.h b/src/list.h index 8a97f92..71b94ad 100644 --- a/src/list.h +++ b/src/list.h @@ -35,6 +35,8 @@ void give_window_focus (rp_window *win, rp_window *last_win); void set_active_window (rp_window *win); void goto_window (rp_window *win); void set_current_window (rp_window *win); +void unhide_transient_for (rp_window *win); +void hide_transient_for (rp_window *win); /* int goto_window_name (char *name); */ rp_window *find_window_other (); rp_window *find_window_by_number (int n); diff --git a/src/manage.c b/src/manage.c index 11fbfd9..e611b1f 100644 --- a/src/manage.c +++ b/src/manage.c @@ -515,6 +515,20 @@ unhide_window (rp_window *win) set_state (win, NormalState); } +/* same as unhide_window except that it make sure the window is mapped + on the bottom of the window stack. */ +void +unhide_below_window (rp_window *win) +{ + if (win == NULL) return; + if (win->state != IconicState) return; + + XLowerWindow (dpy, win->w); + XMapWindow (dpy, win->w); + set_state (win, NormalState); +} + + void withdraw_window (rp_window *win) { diff --git a/src/manage.h b/src/manage.h index 5607cda..fb4c937 100644 --- a/src/manage.h +++ b/src/manage.h @@ -45,6 +45,7 @@ void ungrab_prefix_key (Window w); void hide_window (rp_window *win); void unhide_window (rp_window *win); +void unhide_below_window (rp_window *win); void withdraw_window (rp_window *win); #endif /* ! _RATPOISION_MANAGE_H */ diff --git a/src/split.c b/src/split.c index eafef7a..b14dca3 100644 --- a/src/split.c +++ b/src/split.c @@ -489,6 +489,7 @@ blank_frame (rp_window_frame *frame) { if (frame->win == NULL) return; + hide_transient_for (frame->win); hide_window (frame->win); frame->win = NULL; -- cgit v1.2.3