[PATCH] Fix activate transient_for when current window has no frame (e.g. menus)

Cameron Stewart cameron at shptech.com
Fri Oct 18 13:56:52 CEST 2013


---
 src/xwayland/window-manager.c | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/src/xwayland/window-manager.c b/src/xwayland/window-manager.c
index a889278..4f06bee 100644
--- a/src/xwayland/window-manager.c
+++ b/src/xwayland/window-manager.c
@@ -659,6 +659,20 @@ weston_wm_kill_client(struct wl_listener *listener, void *data)
 		kill(window->pid, SIGKILL);
 }
 
+struct weston_wm_window *
+weston_wm_window_get_framed_parent(struct weston_wm_window *window)
+{
+	struct weston_wm_window *framed_window = window;
+	while (!framed_window->frame && framed_window->transient_for) {
+		framed_window = framed_window->transient_for;
+	}
+	if (framed_window->frame) {
+		return framed_window;
+	} else {
+		return NULL;
+	}
+}
+
 static void
 weston_wm_window_activate(struct wl_listener *listener, void *data)
 {
@@ -694,13 +708,23 @@ weston_wm_window_activate(struct wl_listener *listener, void *data)
 	}
 
 	if (wm->focus_window) {
-		frame_unset_flag(wm->focus_window->frame, FRAME_FLAG_ACTIVE);
-		weston_wm_window_schedule_repaint(wm->focus_window);
+		struct weston_wm_window *action_window = weston_wm_window_get_framed_parent(wm->focus_window);
+		if (action_window) {
+			frame_unset_flag(action_window->frame, FRAME_FLAG_ACTIVE);
+			weston_wm_window_schedule_repaint(action_window);
+		} else {
+			wm_log("window has no frame??\n");
+		}
 	}
 	wm->focus_window = window;
 	if (wm->focus_window) {
-		frame_set_flag(wm->focus_window->frame, FRAME_FLAG_ACTIVE);
-		weston_wm_window_schedule_repaint(wm->focus_window);
+		struct weston_wm_window *action_window = weston_wm_window_get_framed_parent(wm->focus_window);
+		if (action_window) {
+			frame_set_flag(action_window->frame, FRAME_FLAG_ACTIVE);
+			weston_wm_window_schedule_repaint(action_window);
+		} else {
+			wm_log("window has no frame??\n");
+		}
 	}
 }
 
-- 
1.8.4.1



More information about the wayland-devel mailing list