summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/events.c4
-rw-r--r--src/list.c53
-rw-r--r--src/list.h2
-rw-r--r--src/manage.c6
-rw-r--r--src/split.c7
5 files changed, 60 insertions, 12 deletions
diff --git a/src/events.c b/src/events.c
index 86361bf..0937b0b 100644
--- a/src/events.c
+++ b/src/events.c
@@ -66,9 +66,9 @@ cleanup_frame (rp_window_frame *frame)
win = find_window_other ();
if (win)
{
- if (frame->win->transient
- && find_window (win->transient_for) == frame->win)
+ if (is_transient_ancestor (frame->win, win))
{
+ hide_transient_for_between (frame->win, win);
}
else
{
diff --git a/src/list.c b/src/list.c
index d4a7ab5..e1f982d 100644
--- a/src/list.c
+++ b/src/list.c
@@ -439,8 +439,9 @@ unhide_transient_for (rp_window *win)
}
}
+/* Hide all transient windows for win until we get to last. */
void
-hide_transient_for (rp_window *win)
+hide_transient_for_between (rp_window *win, rp_window *last)
{
rp_window *transient_for;
@@ -448,7 +449,7 @@ hide_transient_for (rp_window *win)
if (!win->transient) return;
transient_for = find_window (win->transient_for);
- if (transient_for == NULL)
+ if (transient_for == last)
{
PRINT_DEBUG ("Can't find transient_for for '%s'", win->name );
return;
@@ -459,13 +460,42 @@ hide_transient_for (rp_window *win)
PRINT_DEBUG ("hide transient window: %s\n", transient_for->name);
hide_window (transient_for);
}
-
+
if (transient_for->transient)
{
hide_transient_for (transient_for);
}
}
+void
+hide_transient_for (rp_window *win)
+{
+ /* Hide ALL the transient windows for win. */
+ hide_transient_for_between (win, NULL);
+}
+
+/* return 1 if transient_for is a transient window for win or one of
+ win's transient_for ancestors. */
+int
+is_transient_ancestor (rp_window *win, rp_window *transient_for)
+{
+ rp_window *tmp;
+
+ if (win == NULL) return 0;
+ if (!win->transient) return 0;
+ if (transient_for == NULL) return 0;
+
+ tmp = win;
+
+ do
+ {
+ tmp = find_window (tmp->transient_for);
+ if (tmp == transient_for)
+ return 1;
+ } while (tmp->transient);
+
+ return 0;
+}
void
set_active_window (rp_window *win)
@@ -480,17 +510,24 @@ set_active_window (rp_window *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)
+ if (is_transient_ancestor (win, last_win))
{
- /* Do nothing if the transient is already in the frame */
+ /* Do nothing if last_win is a transient since it should stay visible */
}
else
{
hide_window (last_win);
- }
- hide_transient_for (last_win);
+ if (last_win && is_transient_ancestor (last_win, win))
+ {
+ /* We only need to hide the transients "between" last_win and win */
+ hide_transient_for_between (last_win, win);
+ }
+ else
+ {
+ hide_transient_for (last_win);
+ }
+ }
/* Make sure the window comes up full screen */
unhide_transient_for (win);
diff --git a/src/list.h b/src/list.h
index 71b94ad..e216e9d 100644
--- a/src/list.h
+++ b/src/list.h
@@ -37,6 +37,8 @@ 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);
+void hide_transient_for_between (rp_window *win, rp_window *last);
+int is_transient_ancestor (rp_window *win, rp_window *transient_for);
/* 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 434f698..c1113d9 100644
--- a/src/manage.c
+++ b/src/manage.c
@@ -523,9 +523,13 @@ void
unhide_below_window (rp_window *win)
{
if (win == NULL) return;
- if (win->state != IconicState) return;
+ /* Always lower the window, but if its not iconic we don't need to
+ map it since it already is mapped. */
XLowerWindow (dpy, win->w);
+
+ if (win->state != IconicState) return;
+
XMapWindow (dpy, win->w);
set_state (win, NormalState);
}
diff --git a/src/split.c b/src/split.c
index 053ef5b..d81f385 100644
--- a/src/split.c
+++ b/src/split.c
@@ -223,6 +223,7 @@ split_frame (rp_window_frame *frame, int way)
maximize (win);
unhide_window (win);
+ unhide_transient_for (win);
XRaiseWindow (dpy, win->w);
}
else
@@ -268,7 +269,11 @@ remove_all_splits ()
{
cur = rp_window_frame_sentinel->next;
delete_frame_from_list (cur);
- if (cur != rp_current_frame) hide_window (cur->win);
+ if (cur != rp_current_frame)
+ {
+ hide_window (cur->win);
+ hide_transient_for (cur->win);
+ }
free (cur);
}