soc.2008.finch: 5e9f93dd: More appropriately handle the case where...

queueram at soc.pidgin.im queueram at soc.pidgin.im
Fri Sep 12 22:45:38 EDT 2008


-----------------------------------------------------------------
Revision: 5e9f93ddd871ede830e84bb7e3d6ca94f0460400
Ancestor: df619a2980a528cd192c2234c7e2a7930ec1df06
Author: queueram at soc.pidgin.im
Date: 2008-09-13T02:42:26
Branch: im.pidgin.soc.2008.finch
URL: http://d.pidgin.im/viewmtn/revision/info/5e9f93ddd871ede830e84bb7e3d6ca94f0460400

Modified files:
        finch/libgnt/wms/tiling.c

ChangeLog: 

More appropriately handle the case where a window was closed that was in
a frame other than the one currently in focus.

-------------- next part --------------
============================================================
--- finch/libgnt/wms/tiling.c	c98478839b9e9d2a1302f891e5fe2d5c1b465894
+++ finch/libgnt/wms/tiling.c	8c199d176b4801a9ab18335ee530292ff6f18068
@@ -285,6 +285,28 @@ twm_set_next_window_in_current(GntWM *wm
 	}
 }
 
+/* recursive function to find a frame that is currently display a given window */
+static TilingFrame *
+find_frame_by_window(TilingFrame *root, GntWidget *win)
+{
+	TilingFrame *cur = root;
+	TilingFrame *left_top, *right_bot;
+
+	if (root->window == win) return root;
+
+	if (cur->left_top) {
+		left_top = find_frame_by_window(cur->left_top, win);
+		if (left_top) return left_top;
+	}
+
+	if (cur->right_bottom) {
+		right_bot = find_frame_by_window(cur->right_bottom, win);
+		if (right_bot) return right_bot;
+	}
+
+	return NULL;
+}
+
 static void
 tiling_wm_new_window(GntWM *wm, GntWidget *win)
 {
@@ -328,24 +350,29 @@ tiling_wm_close_window(GntWM *wm, GntWid
 tiling_wm_close_window(GntWM *wm, GntWidget *win)
 {
 	TilingWM *twm = (TilingWM*)wm;
+	TilingFrame *frame;
 	GntWidget *wid;
 
-	/* TODO: if it isn't current->window, need to search the tree for it */
+	/* quick way to grab the current window */
 	if (win == twm->current->window) {
-		wid = get_next_window(wm, win, 1);
+		frame = twm->current;
+	} else {
+		frame = find_frame_by_window(&twm->root, win);
+	}
 
-		if (wid != twm->current->window) {
-			/* hide previous window */
-			if (twm->current->window) {
-				twm_hide_window(wm, twm->current->window);
-			}
+	if (frame) {
+		wid = get_next_window(wm, win, 1);
 
-			/* show new window */
-			twm->current->window = wid;
+		if (wid != frame->window) {
+			frame->window = wid;
 			if (wid) {
-				twm_show_window_in_frame(wm, wid, twm->current);
-				window_reverse(wid, TRUE, wm);
-				gnt_wm_raise_window(wm, wid);
+				/* show new window */
+				twm_show_window_in_frame(wm, wid, frame);
+				/* if the window being closed was in the current frame, bring the new one in focus */
+				if (frame == twm->current) {
+					window_reverse(wid, TRUE, wm);
+					gnt_wm_raise_window(wm, wid);
+				}
 			}
 		}
 	}


More information about the Commits mailing list