From 6a8a8531bad25c148b4c62263d16c0996a21ca6e Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 20 Jan 2008 09:52:10 -0500 Subject: check them startupnotify-provided wmclass against both parts of a window's wm_class hint, as the spec doth say so. --- openbox/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'openbox/client.c') diff --git a/openbox/client.c b/openbox/client.c index 63245a3c..0a0d1ffc 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -313,7 +313,7 @@ void client_manage(Window window) client_setup_decor_and_functions(self, FALSE); /* tell startup notification that this app started */ - launch_time = sn_app_started(self->startup_id, self->class); + launch_time = sn_app_started(self->startup_id, self->class, self->name); /* do this after we have a frame.. it uses the frame to help determine the WM_STATE to apply. */ -- cgit v1.2.3 From 01a60706be14d7bd20ec527935ee005e90de9bf2 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Fri, 25 Jan 2008 10:29:49 -0500 Subject: fix a mem leak --- openbox/client.c | 1 + 1 file changed, 1 insertion(+) (limited to 'openbox/client.c') diff --git a/openbox/client.c b/openbox/client.c index 0a0d1ffc..47e0af6d 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -798,6 +798,7 @@ void client_unmanage(ObClient *self) g_free(self->icons[j].data); if (self->nicons > 0) g_free(self->icons); + g_free(self->startup_id); g_free(self->wm_command); g_free(self->title); g_free(self->icon_title); -- cgit v1.2.3 From 1c2ec09e43b09554c10dd53fc750e975eaa8719c Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Fri, 25 Jan 2008 10:32:39 -0500 Subject: fix a memleak in client_update_icon_geometry --- openbox/client.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'openbox/client.c') diff --git a/openbox/client.c b/openbox/client.c index 47e0af6d..6adaa059 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -2176,12 +2176,13 @@ void client_update_icon_geometry(ObClient *self) RECT_SET(self->icon_geometry, 0, 0, 0, 0); - if (PROP_GETA32(self->window, net_wm_icon_geometry, cardinal, &data, &num) - && num == 4) + if (PROP_GETA32(self->window, net_wm_icon_geometry, cardinal, &data, &num)) { - /* don't let them set it with an area < 0 */ - RECT_SET(self->icon_geometry, data[0], data[1], - MAX(data[2],0), MAX(data[3],0)); + if (num == 4) + /* don't let them set it with an area < 0 */ + RECT_SET(self->icon_geometry, data[0], data[1], + MAX(data[2],0), MAX(data[3],0)); + g_free(data); } } -- cgit v1.2.3 From ee0477d167a3b87618b82d1080fd37e4403e6d2e Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 27 Jan 2008 03:14:35 -0500 Subject: only store icons for windows that are 64px or smaller, as we don't have need for any bigger icons at this time. unless they only provide icons bigger than that, then just store one of them (the smallest) --- openbox/client.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 9 deletions(-) (limited to 'openbox/client.c') diff --git a/openbox/client.c b/openbox/client.c index 6adaa059..e5e25567 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -2067,11 +2067,17 @@ void client_update_strut(ObClient *self) } } +/* Avoid storing icons above this size if possible */ +#define AVOID_ABOVE 64 + void client_update_icons(ObClient *self) { guint num; guint32 *data; guint w, h, i, j; + guint num_seen; /* number of icons present */ + guint num_small_seen; /* number of icons small enough present */ + guint smallest, smallest_area; for (i = 0; i < self->nicons; ++i) g_free(self->icons[i].data); @@ -2082,25 +2088,54 @@ void client_update_icons(ObClient *self) if (PROP_GETA32(self->window, net_wm_icon, cardinal, &data, &num)) { /* figure out how many valid icons are in here */ i = 0; - while (num - i > 2) { - w = data[i++]; - h = data[i++]; - i += w * h; - if (i > num || w*h == 0) break; - ++self->nicons; - } + num_seen = num_small_seen = 0; + smallest = smallest_area = 0; + if (num > 2) + while (i < num) { + w = data[i++]; + h = data[i++]; + i += w * h; + /* watch for it being too small for the specified size, or for + zero sized icons. */ + if (i > num || w == 0 || h == 0) break; + + if (!smallest_area || w*h < smallest_area) { + smallest = num_seen; + smallest_area = w*h; + } + ++num_seen; + if (w <= AVOID_ABOVE && h <= AVOID_ABOVE) + ++num_small_seen; + } + if (num_small_seen > 0) + self->nicons = num_small_seen; + else if (num_seen) + self->nicons = 1; self->icons = g_new(ObClientIcon, self->nicons); /* store the icons */ i = 0; - for (j = 0; j < self->nicons; ++j) { + for (j = 0; j < self->nicons;) { guint x, y, t; w = self->icons[j].width = data[i++]; h = self->icons[j].height = data[i++]; - if (w*h == 0) continue; + /* if there are some icons smaller than the threshold, we're + skipping all the ones above */ + if (num_small_seen > 0) { + if (w > AVOID_ABOVE || h > AVOID_ABOVE) { + i += w*h; + continue; + } + } + /* if there were no icons smaller than the threshold, then we are + only taking the smallest available one we saw */ + else if (j != smallest) { + i += w*h; + continue; + } self->icons[j].data = g_new(RrPixel32, w * h); for (x = 0, y = 0, t = 0; t < w * h; ++t, ++x, ++i) { @@ -2115,6 +2150,8 @@ void client_update_icons(ObClient *self) (((data[i] >> 0) & 0xff) << RrDefaultBlueOffset); } g_assert(i <= num); + + ++j; } g_free(data); -- cgit v1.2.3 From 3b48aa4ea29b4c41037b0f8b02c17e7fa138e31f Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 27 Jan 2008 20:26:29 -0500 Subject: fix a rare assert condition (window maps in iconic state but is not allowed to be iconic) --- openbox/client.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'openbox/client.c') diff --git a/openbox/client.c b/openbox/client.c index e5e25567..ba244756 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -309,9 +309,6 @@ void client_manage(Window window) /* the session should get the last say though */ client_restore_session_state(self); - /* now we have all of the window's information so we can set this up */ - client_setup_decor_and_functions(self, FALSE); - /* tell startup notification that this app started */ launch_time = sn_app_started(self->startup_id, self->class, self->name); @@ -319,12 +316,18 @@ void client_manage(Window window) WM_STATE to apply. */ client_change_state(self); - /* add ourselves to the focus order */ + /* add ourselves to the focus order. do this before + setup_decor_and_functions. if the window is mapping in a state that is + not allowed, then it will be adjusted, and that can change its position + in the focus order (deiconify for example) */ focus_order_add_new(self); /* do this to add ourselves to the stacking list in a non-intrusive way */ client_calc_layer(self); + /* now we have all of the window's information so we can set this up */ + client_setup_decor_and_functions(self, FALSE); + /* focus the new window? */ if (ob_state() != OB_STATE_STARTING && (!self->session || self->session->focused) && -- cgit v1.2.3 From e7e02728a337f3757aa00c260cb16f5f8224eae0 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 28 Jan 2008 00:26:13 -0500 Subject: reordering things when mapping windows a little to work with iconified windows with iconified toolbars on restart. (e.g. ooffice) --- openbox/client.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'openbox/client.c') diff --git a/openbox/client.c b/openbox/client.c index ba244756..035f7c45 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -201,14 +201,17 @@ void client_manage_all(void) } } - for (i = 0; i < nchild; ++i) { - if (children[i] == None) + /* manage windows in reverse order from how they were originally mapped. + this is an attempt to manage children windows before their parents, so + that when the parent is mapped, it can find the child */ + for (i = nchild; i > 0; --i) { + if (children[i--1] == None) continue; - if (XGetWindowAttributes(ob_display, children[i], &attrib)) { + if (XGetWindowAttributes(ob_display, children[i-1], &attrib)) { if (attrib.override_redirect) continue; if (attrib.map_state != IsUnmapped) - client_manage(children[i]); + client_manage(children[i-1]); } } XFree(children); @@ -289,6 +292,11 @@ void client_manage(Window window) ob_debug("Window type: %d\n", self->type); ob_debug("Window group: 0x%x\n", self->group?self->group->leader:0); + /* now we have all of the window's information so we can set this up. + do this before creating the frame, so it can tell that we are still + mapping and doesn't go applying things right away */ + client_setup_decor_and_functions(self, FALSE); + /* specify that if we exit, the window should not be destroyed and should be reparented back to root automatically */ XChangeSaveSet(ob_display, window, SetModeInsert); @@ -316,18 +324,12 @@ void client_manage(Window window) WM_STATE to apply. */ client_change_state(self); - /* add ourselves to the focus order. do this before - setup_decor_and_functions. if the window is mapping in a state that is - not allowed, then it will be adjusted, and that can change its position - in the focus order (deiconify for example) */ + /* add ourselves to the focus order */ focus_order_add_new(self); /* do this to add ourselves to the stacking list in a non-intrusive way */ client_calc_layer(self); - /* now we have all of the window's information so we can set this up */ - client_setup_decor_and_functions(self, FALSE); - /* focus the new window? */ if (ob_state() != OB_STATE_STARTING && (!self->session || self->session->focused) && -- cgit v1.2.3 From d11ac82062d729be5d63c9c40c5c2bb312a8b8f1 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 28 Jan 2008 09:59:45 -0500 Subject: don't deiconify windows on reconfigure if they cant be iconified directly. stop managing windows in reverse order on restart it messes up the dock among other things --- openbox/client.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'openbox/client.c') diff --git a/openbox/client.c b/openbox/client.c index 035f7c45..8169048f 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -204,14 +204,14 @@ void client_manage_all(void) /* manage windows in reverse order from how they were originally mapped. this is an attempt to manage children windows before their parents, so that when the parent is mapped, it can find the child */ - for (i = nchild; i > 0; --i) { - if (children[i--1] == None) + for (i = 0; i < nchild; ++i) { + if (children[i] == None) continue; - if (XGetWindowAttributes(ob_display, children[i-1], &attrib)) { + if (XGetWindowAttributes(ob_display, children[i], &attrib)) { if (attrib.override_redirect) continue; if (attrib.map_state != IsUnmapped) - client_manage(children[i-1]); + client_manage(children[i]); } } XFree(children); @@ -1836,16 +1836,16 @@ static void client_change_allowed_actions(ObClient *self) PROP_SETA32(self->window, net_wm_allowed_actions, atom, actions, num); - /* make sure the window isn't breaking any rules now */ + /* make sure the window isn't breaking any rules now + + don't check ICONIFY here. just cuz a window can't iconify doesnt mean + it can't be iconified with its parent + */ if (!(self->functions & OB_CLIENT_FUNC_SHADE) && self->shaded) { if (self->frame) client_shade(self, FALSE); else self->shaded = FALSE; } - if (!(self->functions & OB_CLIENT_FUNC_ICONIFY) && self->iconic) { - if (self->frame) client_iconify(self, FALSE, TRUE, FALSE); - else self->iconic = FALSE; - } if (!(self->functions & OB_CLIENT_FUNC_FULLSCREEN) && self->fullscreen) { if (self->frame) client_fullscreen(self, FALSE); else self->fullscreen = FALSE; -- cgit v1.2.3