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 +- openbox/startupnotify.c | 19 ++++++++++++++----- openbox/startupnotify.h | 7 +++++-- 3 files changed, 20 insertions(+), 8 deletions(-) (limited to 'openbox') 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. */ diff --git a/openbox/startupnotify.c b/openbox/startupnotify.c index 66bce264..8bc38da2 100644 --- a/openbox/startupnotify.c +++ b/openbox/startupnotify.c @@ -28,7 +28,7 @@ void sn_startup(gboolean reconfig) {} void sn_shutdown(gboolean reconfig) {} gboolean sn_app_starting() { return FALSE; } -Time sn_app_started(const gchar *id, const gchar *wmclass) +Time sn_app_started(const gchar *id, const gchar *wmclass, const gchar *name) { return CurrentTime; } @@ -169,7 +169,7 @@ static void sn_event_func(SnMonitorEvent *ev, gpointer data) screen_set_root_cursor(); } -Time sn_app_started(const gchar *id, const gchar *wmclass) +Time sn_app_started(const gchar *id, const gchar *wmclass, const gchar *name) { GSList *it; Time t = CurrentTime; @@ -193,13 +193,22 @@ Time sn_app_started(const gchar *id, const gchar *wmclass) found = TRUE; } else { seqclass = sn_startup_sequence_get_wmclass(seq); - seqname = sn_startup_sequence_get_name(seq); seqbin = sn_startup_sequence_get_binary_name(seq); - if ((seqname && !g_ascii_strcasecmp(seqname, wmclass)) || + /* seqclass = "a string to match against the "resource name" or + "resource class" hints. These are WM_CLASS[0] and WM_CLASS[1]" + - from the startup-notification spec + */ + if ((seqclass && !strcmp(seqclass, wmclass)) || + (seqclass && !strcmp(seqclass, name)) || + /* Check the binary name against the class and name hints + as well, to help apps that don't have the class set + correctly */ (seqbin && !g_ascii_strcasecmp(seqbin, wmclass)) || - (seqclass && !strcmp(seqclass, wmclass))) + (seqbin && !g_ascii_strcasecmp(seqbin, name))) + { found = TRUE; + } } if (found) { diff --git a/openbox/startupnotify.h b/openbox/startupnotify.h index 7c28faba..d6f29724 100644 --- a/openbox/startupnotify.h +++ b/openbox/startupnotify.h @@ -27,8 +27,11 @@ void sn_shutdown(gboolean reconfig); gboolean sn_app_starting(); -/*! Notify that an app has started */ -Time sn_app_started(const gchar *id, const gchar *wmclass); +/*! Notify that an app has started + @param wmclass the WM_CLASS[1] hint + @param name the WM_CLASS[0] hint + */ +Time sn_app_started(const gchar *id, const gchar *wmclass, const gchar *name); /*! Get the desktop requested via the startup-notiication protocol if one was requested */ -- cgit v1.2.3 From b77a03a1f22e3e474c1338416ec30681c6216b0d Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 20 Jan 2008 18:34:26 -0500 Subject: only unset the startup_desktop_id once, and dont free the string we pass to putenv --- openbox/openbox.c | 4 +--- openbox/startupnotify.c | 7 ------- 2 files changed, 1 insertion(+), 10 deletions(-) (limited to 'openbox') diff --git a/openbox/openbox.c b/openbox/openbox.c index 48f31f91..0c74b255 100644 --- a/openbox/openbox.c +++ b/openbox/openbox.c @@ -515,9 +515,7 @@ static void remove_args(gint *argc, gchar **argv, gint index, gint num) static void parse_env() { /* unset this so we don't pass it on unknowingly */ - gchar *s = g_strdup("DESKTOP_STARTUP_ID"); - putenv(s); - g_free(s); + putenv(g_strdup("DESKTOP_STARTUP_ID")); } static void parse_args(gint *argc, gchar **argv) diff --git a/openbox/startupnotify.c b/openbox/startupnotify.c index 8bc38da2..78a1e94a 100644 --- a/openbox/startupnotify.c +++ b/openbox/startupnotify.c @@ -58,15 +58,8 @@ static void sn_event_func(SnMonitorEvent *event, gpointer data); void sn_startup(gboolean reconfig) { - gchar *s; - if (reconfig) return; - /* unset this so we don't pass it on unknowingly */ - s = g_strdup("DESKTOP_STARTUP_ID"); - putenv(s); - g_free(s); - sn_display = sn_display_new(ob_display, NULL, NULL); sn_context = sn_monitor_context_new(sn_display, ob_screen, sn_event_func, NULL, NULL); -- cgit v1.2.3 From 1b33ab6c0d9117a84325e1bc01489bde566cda64 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 21 Jan 2008 22:27:03 -0500 Subject: use the for startup notfication in the execute action. when present don't use the check against the binary. --- openbox/actions/execute.c | 1 + openbox/startupnotify.c | 39 +++++++++++++++++++-------------------- openbox/startupnotify.h | 5 +++-- 3 files changed, 23 insertions(+), 22 deletions(-) (limited to 'openbox') diff --git a/openbox/actions/execute.c b/openbox/actions/execute.c index 02de0154..9ab20d71 100644 --- a/openbox/actions/execute.c +++ b/openbox/actions/execute.c @@ -104,6 +104,7 @@ static gboolean run_func(ObActionsData *data, gpointer options) program = g_path_get_basename(argv[0]); /* sets up the environment */ sn_setup_spawn_environment(program, o->sn_name, o->sn_icon, + o->sn_wmclass, /* launch it on the current desktop */ screen_desktop); } diff --git a/openbox/startupnotify.c b/openbox/startupnotify.c index 78a1e94a..e9bb8310 100644 --- a/openbox/startupnotify.c +++ b/openbox/startupnotify.c @@ -33,8 +33,9 @@ Time sn_app_started(const gchar *id, const gchar *wmclass, const gchar *name) return CurrentTime; } gboolean sn_get_desktop(gchar *id, guint *desktop) { return FALSE; } -void sn_setup_spawn_environment(gchar *program, gchar *name, - gchar *icon_name, gint desktop) {} +void sn_setup_spawn_environment(const gchar *program, const gchar *name, + const gchar *icon_name, const gchar *wmclass, + gint desktop) {} void sn_spawn_cancel() {} #else @@ -173,10 +174,9 @@ Time sn_app_started(const gchar *id, const gchar *wmclass, const gchar *name) for (it = sn_waits; it; it = g_slist_next(it)) { SnStartupSequence *seq = it->data; gboolean found = FALSE; - const gchar *seqid, *seqclass, *seqname, *seqbin; + const gchar *seqid, *seqclass, *seqbin; seqid = sn_startup_sequence_get_id(seq); seqclass = sn_startup_sequence_get_wmclass(seq); - seqname = sn_startup_sequence_get_name(seq); seqbin = sn_startup_sequence_get_binary_name(seq); if (id && seqid) { @@ -184,24 +184,21 @@ Time sn_app_started(const gchar *id, const gchar *wmclass, const gchar *name) accuracy */ if (!strcmp(seqid, id)) found = TRUE; - } else { - seqclass = sn_startup_sequence_get_wmclass(seq); - seqbin = sn_startup_sequence_get_binary_name(seq); - + } + else if (seqclass) { /* seqclass = "a string to match against the "resource name" or "resource class" hints. These are WM_CLASS[0] and WM_CLASS[1]" - from the startup-notification spec */ - if ((seqclass && !strcmp(seqclass, wmclass)) || - (seqclass && !strcmp(seqclass, name)) || - /* Check the binary name against the class and name hints - as well, to help apps that don't have the class set - correctly */ - (seqbin && !g_ascii_strcasecmp(seqbin, wmclass)) || - (seqbin && !g_ascii_strcasecmp(seqbin, name))) - { - found = TRUE; - } + found = (seqclass && !strcmp(seqclass, wmclass)) || + (seqclass && !strcmp(seqclass, name)); + } + else if (seqbin) { + /* Check the binary name against the class and name hints + as well, to help apps that don't have the class set + correctly */ + found = (seqbin && !g_ascii_strcasecmp(seqbin, wmclass)) || + (seqbin && !g_ascii_strcasecmp(seqbin, name)); } if (found) { @@ -234,8 +231,9 @@ static gboolean sn_launch_wait_timeout(gpointer data) return FALSE; /* don't repeat */ } -void sn_setup_spawn_environment(gchar *program, gchar *name, - gchar *icon_name, gint desktop) +void sn_setup_spawn_environment(const gchar *program, const gchar *name, + const gchar *icon_name, const gchar *wmclass, + gint desktop) { gchar *desc; const char *id; @@ -252,6 +250,7 @@ void sn_setup_spawn_environment(gchar *program, gchar *name, sn_launcher_context_set_icon_name(sn_launcher, icon_name ? icon_name : program); sn_launcher_context_set_binary_name(sn_launcher, program); + if (wmclass) sn_launcher_context_set_wmclass(sn_launcher, wmclass); if (desktop >= 0 && (unsigned) desktop < screen_num_desktops) sn_launcher_context_set_workspace(sn_launcher, (signed) desktop); sn_launcher_context_initiate(sn_launcher, "openbox", program, diff --git a/openbox/startupnotify.h b/openbox/startupnotify.h index d6f29724..758beee6 100644 --- a/openbox/startupnotify.h +++ b/openbox/startupnotify.h @@ -38,8 +38,9 @@ Time sn_app_started(const gchar *id, const gchar *wmclass, const gchar *name); gboolean sn_get_desktop(gchar *id, guint *desktop); /* Get the environment to run the program in, with startup notification */ -void sn_setup_spawn_environment(gchar *program, gchar *name, - gchar *icon_name, gint desktop); +void sn_setup_spawn_environment(const gchar *program, const gchar *name, + const gchar *icon_name, const gchar *wmclass, + gint desktop); /* Tell startup notification we're not actually running the program we told it we were -- cgit v1.2.3 From f476442531061fb6d36e3cc79decac10b985db35 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Tue, 22 Jan 2008 12:54:53 -0500 Subject: print a warning when the session has a different number of desktops than the openbox config --- openbox/config.c | 4 ++-- openbox/config.h | 2 +- openbox/screen.c | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'openbox') diff --git a/openbox/config.c b/openbox/config.c index 867dfb51..56e625d4 100644 --- a/openbox/config.c +++ b/openbox/config.c @@ -55,7 +55,7 @@ RrFont *config_font_menuitem; RrFont *config_font_menutitle; RrFont *config_font_osd; -gint config_desktops_num; +guint config_desktops_num; GSList *config_desktops_names; guint config_screen_firstdesk; guint config_desktop_popup_time; @@ -605,7 +605,7 @@ static void parse_desktops(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, if ((n = parse_find_node("number", node))) { gint d = parse_int(doc, n); if (d > 0) - config_desktops_num = d; + config_desktops_num = (unsigned) d; } if ((n = parse_find_node("firstdesk", node))) { gint d = parse_int(doc, n); diff --git a/openbox/config.h b/openbox/config.h index 240b04f1..50e7dfe3 100644 --- a/openbox/config.h +++ b/openbox/config.h @@ -143,7 +143,7 @@ extern RrFont *config_font_menuitem; extern RrFont *config_font_osd; /*! The number of desktops */ -extern gint config_desktops_num; +extern guint config_desktops_num; /*! Desktop to start on, put 5 to start in the center of a 3x3 grid */ extern guint config_screen_firstdesk; /*! Names for the desktops */ diff --git a/openbox/screen.c b/openbox/screen.c index e008ffe5..932b157e 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -402,7 +402,13 @@ void screen_startup(gboolean reconfig) screen_num_desktops = 0; if (PROP_GET32(RootWindow(ob_display, ob_screen), net_number_of_desktops, cardinal, &d)) + { + if (d != config_desktops_num) { + g_warning(_("Openbox is configured for %d desktops, but the current session has %d. Overriding the Openbox configuration."), + config_desktops_num, d); + } screen_set_num_desktops(d); + } /* restore from session if possible */ else if (session_num_desktops) screen_set_num_desktops(session_num_desktops); -- cgit v1.2.3 From bed3cb7a30e5bc3e75bf624dafc2d7d94714ae2f Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Thu, 24 Jan 2008 20:19:33 -0500 Subject: strip non-modifier masks from the keyboard state for keyreleases when xkb is present too --- openbox/event.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'openbox') diff --git a/openbox/event.c b/openbox/event.c index 025f1188..fba5e86d 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -270,7 +270,8 @@ static void event_hack_mods(XEvent *e) magic. Our X core protocol stuff won't work, so we use this to find what the modifier state is instead. */ if (XkbGetState(ob_display, XkbUseCoreKbd, &xkb_state) == Success) - e->xkey.state = xkb_state.compat_state; + e->xkey.state = + modkeys_only_modifier_masks(xkb_state.compat_state); else #endif { -- cgit v1.2.3 From 3febcbb9ae6a31edbd64a86f0045148bb052fcff Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Fri, 25 Jan 2008 00:35:31 -0500 Subject: skip enter events caused by temporarily raising windows during alt-tab. also caused by the focus cycle indicator moving --- openbox/focus_cycle_indicator.c | 6 ++++++ openbox/stacking.c | 6 ++++++ 2 files changed, 12 insertions(+) (limited to 'openbox') diff --git a/openbox/focus_cycle_indicator.c b/openbox/focus_cycle_indicator.c index 0aa65a75..7c5d5290 100644 --- a/openbox/focus_cycle_indicator.c +++ b/openbox/focus_cycle_indicator.c @@ -158,6 +158,7 @@ void focus_cycle_draw_indicator(ObClient *c) */ gint x, y, w, h; gint wt, wl, wr, wb; + gulong ignore_start; wt = wl = wr = wb = FOCUS_INDICATOR_WIDTH; @@ -166,6 +167,9 @@ void focus_cycle_draw_indicator(ObClient *c) w = c->frame->area.width; h = wt; + /* kill enter events cause by this moving */ + ignore_start = event_start_ignore_all_enters(); + XMoveResizeWindow(ob_display, focus_indicator.top.win, x, y, w, h); a_focus_indicator->texture[0].data.lineart.x1 = 0; @@ -270,6 +274,8 @@ void focus_cycle_draw_indicator(ObClient *c) XMapWindow(ob_display, focus_indicator.right.win); XMapWindow(ob_display, focus_indicator.bottom.win); + event_end_ignore_all_enters(ignore_start); + visible = TRUE; } } diff --git a/openbox/stacking.c b/openbox/stacking.c index b18c02af..63819ae2 100644 --- a/openbox/stacking.c +++ b/openbox/stacking.c @@ -114,6 +114,7 @@ void stacking_temp_raise(ObWindow *window) { Window win[2]; GList *it; + gulong start; /* don't use this for internal windows..! it would lower them.. */ g_assert(window_layer(window) < OB_STACKING_LAYER_INTERNAL); @@ -129,7 +130,9 @@ void stacking_temp_raise(ObWindow *window) } win[1] = window_top(window); + start = event_start_ignore_all_enters(); XRestackWindows(ob_display, win, 2); + event_end_ignore_all_enters(start); pause_changes = TRUE; } @@ -139,12 +142,15 @@ void stacking_restore(void) Window *win; GList *it; gint i; + gulong start; win = g_new(Window, g_list_length(stacking_list) + 1); win[0] = screen_support_win; for (i = 1, it = stacking_list; it; ++i, it = g_list_next(it)) win[i] = window_top(it->data); + start = event_start_ignore_all_enters(); XRestackWindows(ob_display, win, i); + event_end_ignore_all_enters(start); g_free(win); pause_changes = FALSE; -- cgit v1.2.3 From 1d9991a0cd9b04dfa96a19bc73b40f01651de478 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Fri, 25 Jan 2008 12:53:43 +0100 Subject: Fix some memleaks. missing RrFontClose for osd_font in two places. missing a g_free(area); --- openbox/config.c | 1 + openbox/popup.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'openbox') diff --git a/openbox/config.c b/openbox/config.c index 56e625d4..50f6aef6 100644 --- a/openbox/config.c +++ b/openbox/config.c @@ -982,6 +982,7 @@ void config_shutdown(void) RrFontClose(config_font_inactivewindow); RrFontClose(config_font_menuitem); RrFontClose(config_font_menutitle); + RrFontClose(config_font_osd); for (it = config_desktops_names; it; it = g_slist_next(it)) g_free(it->data); diff --git a/openbox/popup.c b/openbox/popup.c index 283348e7..15d1bf52 100644 --- a/openbox/popup.c +++ b/openbox/popup.c @@ -257,6 +257,8 @@ void popup_delay_show(ObPopup *self, gulong usec, gchar *text) x=MAX(MIN(x, area->x+area->width-w),area->x); y=MAX(MIN(y, area->y+area->height-h),area->y); + g_free(area); + if (m == screen_num_monitors) { RECT_SET(mon, x, y, w, h); m = screen_find_monitor(&mon); @@ -266,6 +268,8 @@ void popup_delay_show(ObPopup *self, gulong usec, gchar *text) x=MAX(MIN(x, area->x+area->width-w),area->x); y=MAX(MIN(y, area->y+area->height-h),area->y); + + g_free(area); } /* set the windows/appearances up */ @@ -301,8 +305,6 @@ void popup_delay_show(ObPopup *self, gulong usec, gchar *text) popup_show_timeout(self); } } - - g_free(area); } void popup_hide(ObPopup *self) -- cgit v1.2.3 From 41aeb42af13774c11e5a23e51bf56fa053678b5a Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Fri, 25 Jan 2008 10:20:21 -0500 Subject: Create fake enter events in fewer situations - avoiding times that you don't actually want them. Ignore event serials without using XSync, so that we aren't doing an XSync 100 times per minute - slow! --- openbox/actions.c | 7 +++---- openbox/event.c | 8 +++----- 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'openbox') diff --git a/openbox/actions.c b/openbox/actions.c index 0c84489a..b7f5dc2b 100644 --- a/openbox/actions.c +++ b/openbox/actions.c @@ -339,9 +339,7 @@ void actions_client_move(ObActionsData *data, gboolean start) else if (config_focus_follow && data->context != OB_FRAME_CONTEXT_CLIENT) { - if (!data->button && data->client && !config_focus_under_mouse) - event_end_ignore_all_enters(ignore_start); - else { + if (data->button && config_focus_under_mouse) { struct _ObClient *c; /* usually this is sorta redundant, but with a press action @@ -355,6 +353,7 @@ void actions_client_move(ObActionsData *data, gboolean start) "mouse-event action"); event_enter_client(c); } - } + } else + event_end_ignore_all_enters(ignore_start); } } diff --git a/openbox/event.c b/openbox/event.c index fba5e86d..7d24640c 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -1928,8 +1928,7 @@ void event_halt_focus_delay(void) gulong event_start_ignore_all_enters(void) { - XSync(ob_display, FALSE); - return LastKnownRequestProcessed(ob_display); + return NextRequest(ob_display); } static void event_ignore_enter_range(gulong start, gulong end) @@ -1948,13 +1947,12 @@ static void event_ignore_enter_range(gulong start, gulong end) r->start, r->end); /* increment the serial so we don't ignore events we weren't meant to */ - XSync(ob_display, FALSE); + PROP_ERASE(screen_support_win, motif_wm_hints); } void event_end_ignore_all_enters(gulong start) { - XSync(ob_display, FALSE); - event_ignore_enter_range(start, LastKnownRequestProcessed(ob_display)); + event_ignore_enter_range(start, NextRequest(ob_display)); } static gboolean is_enter_focus_event_ignored(XEvent *e) -- cgit v1.2.3 From 7b181fe23d724b2057efc383b1bdadc837bad2fb Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Fri, 25 Jan 2008 10:27:44 -0500 Subject: fix a mem leak --- openbox/focus_cycle_popup.c | 1 + 1 file changed, 1 insertion(+) (limited to 'openbox') diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index 9a6f2420..f0cf25e2 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -481,6 +481,7 @@ void focus_cycle_popup_hide(void) g_free(t->text); XDestroyWindow(ob_display, t->win); + g_free(t); popup.targets = g_list_delete_link(popup.targets, popup.targets); } -- 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') 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') 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 be71b344fa740cfa061fea81426583ff44aeee9b Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sat, 26 Jan 2008 01:17:56 -0500 Subject: only add borders and stuff to the dock's size if it is holding anything. otherwise it gets a non-zero size which messes with resistence/placement/etc --- openbox/dock.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'openbox') diff --git a/openbox/dock.c b/openbox/dock.c index ed8bed4b..4c183e2c 100644 --- a/openbox/dock.c +++ b/openbox/dock.c @@ -249,8 +249,10 @@ void dock_configure(void) } } - dock->area.width += l + r; - dock->area.height += t + b; + if (dock->dock_apps) { + dock->area.width += l + r; + dock->area.height += t + b; + } hspot = l; vspot = t; @@ -427,11 +429,12 @@ void dock_configure(void) if (!dock->dock_apps) { STRUT_PARTIAL_SET(dock_strut, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - } else if (config_dock_floating || config_dock_nostrut) - { + } + else if (config_dock_floating || config_dock_nostrut) { STRUT_PARTIAL_SET(dock_strut, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - } else { + } + else { switch (config_dock_pos) { case OB_DIRECTION_NORTHWEST: switch (config_dock_orient) { @@ -529,9 +532,12 @@ void dock_configure(void) } else XUnmapWindow(ob_display, dock->frame); - /* but they are useful outside of this function! */ - dock->area.width += ob_rr_theme->obwidth * 2; - dock->area.height += ob_rr_theme->obwidth * 2; + /* but they are useful outside of this function! but don't add it if the + dock is actually not visible */ + if (dock->dock_apps) { + dock->area.width += ob_rr_theme->obwidth * 2; + dock->area.height += ob_rr_theme->obwidth * 2; + } screen_update_areas(); -- cgit v1.2.3 From 2c05d1fb529f80d7e040dd0b9f3af13bd90580f2 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sat, 26 Jan 2008 18:25:32 +0100 Subject: Add a few missing includes and remove a stray debug printf. --- openbox/client_list_combined_menu.c | 1 + openbox/client_list_menu.c | 1 + openbox/client_menu.c | 1 + openbox/extensions.c | 1 - 4 files changed, 3 insertions(+), 1 deletion(-) (limited to 'openbox') diff --git a/openbox/client_list_combined_menu.c b/openbox/client_list_combined_menu.c index f7fc36b8..c1572eaf 100644 --- a/openbox/client_list_combined_menu.c +++ b/openbox/client_list_combined_menu.c @@ -22,6 +22,7 @@ #include "menuframe.h" #include "screen.h" #include "client.h" +#include "client_list_combined_menu.h" #include "focus.h" #include "config.h" #include "gettext.h" diff --git a/openbox/client_list_menu.c b/openbox/client_list_menu.c index 33f4b6f5..0febe2e6 100644 --- a/openbox/client_list_menu.c +++ b/openbox/client_list_menu.c @@ -22,6 +22,7 @@ #include "menuframe.h" #include "screen.h" #include "client.h" +#include "client_list_menu.h" #include "focus.h" #include "config.h" #include "gettext.h" diff --git a/openbox/client_menu.c b/openbox/client_menu.c index cf556744..f35b5bd3 100644 --- a/openbox/client_menu.c +++ b/openbox/client_menu.c @@ -22,6 +22,7 @@ #include "config.h" #include "screen.h" #include "client.h" +#include "client_menu.h" #include "openbox.h" #include "frame.h" #include "moveresize.h" diff --git a/openbox/extensions.c b/openbox/extensions.c index d1088361..cd188dd0 100644 --- a/openbox/extensions.c +++ b/openbox/extensions.c @@ -87,7 +87,6 @@ void extensions_xinerama_screens(Rect **xin_areas, guint *nxin) guint i; gint l, r, t, b; if (ob_debug_xinerama) { - g_print("Using fake xinerama !\n"); gint w = WidthOfScreen(ScreenOfDisplay(ob_display, ob_screen)); gint h = HeightOfScreen(ScreenOfDisplay(ob_display, ob_screen)); *nxin = 2; -- cgit v1.2.3 From 4307366b713aaf1a5787dbb3244a5717db1330e8 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sat, 26 Jan 2008 13:25:03 -0500 Subject: create fake enter events for button press bindings. only swallow enter events when focus.undermouse is not on (for non-mouse actions) --- openbox/actions.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'openbox') diff --git a/openbox/actions.c b/openbox/actions.c index b7f5dc2b..a236b581 100644 --- a/openbox/actions.c +++ b/openbox/actions.c @@ -339,7 +339,7 @@ void actions_client_move(ObActionsData *data, gboolean start) else if (config_focus_follow && data->context != OB_FRAME_CONTEXT_CLIENT) { - if (data->button && config_focus_under_mouse) { + if (data->uact == OB_USER_ACTION_MOUSE_PRESS) { struct _ObClient *c; /* usually this is sorta redundant, but with a press action @@ -353,7 +353,8 @@ void actions_client_move(ObActionsData *data, gboolean start) "mouse-event action"); event_enter_client(c); } - } else + } + else if (!data->button && !config_focus_under_mouse) event_end_ignore_all_enters(ignore_start); } } -- cgit v1.2.3 From 8af80aa8dd47090bc418c6cf7e1c3894621566b7 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sat, 26 Jan 2008 13:36:20 -0500 Subject: when ignoring enter events, only ignore up to the current serial (NextRequest()-1). Don't ignore enters that come after this with the next serial. --- openbox/event.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'openbox') diff --git a/openbox/event.c b/openbox/event.c index 7d24640c..535e9f14 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -1952,7 +1952,13 @@ static void event_ignore_enter_range(gulong start, gulong end) void event_end_ignore_all_enters(gulong start) { - event_ignore_enter_range(start, NextRequest(ob_display)); + /* Use (NextRequest-1) so that we ignore up to the current serial only. + Inside event_ignore_enter_range, we increment the serial by one, but if + we ignore that serial too, then any enter events generated by mouse + movement will be ignored until we create some further network traffic. + Instead ignore up to NextRequest-1, then when we increment the serial, + we will be *past* the range of ignored serials */ + event_ignore_enter_range(start, NextRequest(ob_display)-1); } static gboolean is_enter_focus_event_ignored(XEvent *e) -- cgit v1.2.3 From dd8cb753c16a902b46400eb4e80288cbaa25ba99 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 27 Jan 2008 02:41:21 -0500 Subject: add a missing #include --- openbox/stacking.c | 1 + 1 file changed, 1 insertion(+) (limited to 'openbox') diff --git a/openbox/stacking.c b/openbox/stacking.c index 63819ae2..92a5285d 100644 --- a/openbox/stacking.c +++ b/openbox/stacking.c @@ -25,6 +25,7 @@ #include "group.h" #include "frame.h" #include "window.h" +#include "event.h" #include "debug.h" GList *stacking_list = NULL; -- cgit v1.2.3 From 6be65a7ddd453bded890a90bb5c0b84b2a89c65a Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 27 Jan 2008 02:53:26 -0500 Subject: we alloc theme elements for every window frame, but really it is unneccesary --- openbox/frame.c | 17 ----------------- openbox/frame.h | 10 ---------- openbox/framerender.c | 16 +++++++--------- openbox/openbox.c | 1 + 4 files changed, 8 insertions(+), 36 deletions(-) (limited to 'openbox') diff --git a/openbox/frame.c b/openbox/frame.c index a47c2f06..8fee3b69 100644 --- a/openbox/frame.c +++ b/openbox/frame.c @@ -216,27 +216,10 @@ static void set_theme_statics(ObFrame *self) ob_rr_theme->paddingx + 1, ob_rr_theme->title_height); XResizeWindow(ob_display, self->trrresize, ob_rr_theme->paddingx + 1, ob_rr_theme->title_height); - - /* set up the dynamic appearances */ - self->a_unfocused_title = RrAppearanceCopy(ob_rr_theme->a_unfocused_title); - self->a_focused_title = RrAppearanceCopy(ob_rr_theme->a_focused_title); - self->a_unfocused_label = RrAppearanceCopy(ob_rr_theme->a_unfocused_label); - self->a_focused_label = RrAppearanceCopy(ob_rr_theme->a_focused_label); - self->a_unfocused_handle = - RrAppearanceCopy(ob_rr_theme->a_unfocused_handle); - self->a_focused_handle = RrAppearanceCopy(ob_rr_theme->a_focused_handle); - self->a_icon = RrAppearanceCopy(ob_rr_theme->a_icon); } static void free_theme_statics(ObFrame *self) { - RrAppearanceFree(self->a_unfocused_title); - RrAppearanceFree(self->a_focused_title); - RrAppearanceFree(self->a_unfocused_label); - RrAppearanceFree(self->a_focused_label); - RrAppearanceFree(self->a_unfocused_handle); - RrAppearanceFree(self->a_focused_handle); - RrAppearanceFree(self->a_icon); } void frame_free(ObFrame *self) diff --git a/openbox/frame.h b/openbox/frame.h index 3e7b2c61..02be17a0 100644 --- a/openbox/frame.h +++ b/openbox/frame.h @@ -137,16 +137,6 @@ struct _ObFrame Colormap colormap; - RrAppearance *a_unfocused_title; - RrAppearance *a_focused_title; - RrAppearance *a_unfocused_label; - RrAppearance *a_focused_label; - RrAppearance *a_icon; - RrAppearance *a_unfocused_handle; - RrAppearance *a_focused_handle; - - GSList *clients; - gint icon_on; /* if the window icon button is on */ gint label_on; /* if the window title is on */ gint iconify_on; /* if the window iconify button is on */ diff --git a/openbox/framerender.c b/openbox/framerender.c index af6be016..e4db2a06 100644 --- a/openbox/framerender.c +++ b/openbox/framerender.c @@ -124,10 +124,8 @@ void framerender_frame(ObFrame *self) if (self->decorations & OB_FRAME_DECOR_TITLEBAR) { RrAppearance *t, *l, *m, *n, *i, *d, *s, *c, *clear; if (self->focused) { - - t = self->a_focused_title; - l = self->a_focused_label; - + t = ob_rr_theme->a_focused_title; + l = ob_rr_theme->a_focused_label; m = (!(self->decorations & OB_FRAME_DECOR_MAXIMIZE) ? ob_rr_theme->a_disabled_focused_max : (self->client->max_vert || self->client->max_horz ? @@ -141,7 +139,7 @@ void framerender_frame(ObFrame *self) (self->max_hover ? ob_rr_theme->a_hover_focused_max : ob_rr_theme->a_focused_unpressed_max)))); - n = self->a_icon; + n = ob_rr_theme->a_icon; i = (!(self->decorations & OB_FRAME_DECOR_ICONIFY) ? ob_rr_theme->a_disabled_focused_iconify : (self->iconify_press ? @@ -183,8 +181,8 @@ void framerender_frame(ObFrame *self) ob_rr_theme->a_hover_focused_close : ob_rr_theme->a_focused_unpressed_close))); } else { - t = self->a_unfocused_title; - l = self->a_unfocused_label; + t = ob_rr_theme->a_unfocused_title; + l = ob_rr_theme->a_unfocused_label; m = (!(self->decorations & OB_FRAME_DECOR_MAXIMIZE) ? ob_rr_theme->a_disabled_unfocused_max : (self->client->max_vert || self->client->max_horz ? @@ -198,7 +196,7 @@ void framerender_frame(ObFrame *self) (self->max_hover ? ob_rr_theme->a_hover_unfocused_max : ob_rr_theme->a_unfocused_unpressed_max)))); - n = self->a_icon; + n = ob_rr_theme->a_icon; i = (!(self->decorations & OB_FRAME_DECOR_ICONIFY) ? ob_rr_theme->a_disabled_unfocused_iconify : (self->iconify_press ? @@ -318,7 +316,7 @@ void framerender_frame(ObFrame *self) RrAppearance *h, *g; h = (self->focused ? - self->a_focused_handle : self->a_unfocused_handle); + ob_rr_theme->a_focused_handle : ob_rr_theme->a_unfocused_handle); RrPaint(h, self->handle, self->width, ob_rr_theme->handle_height); diff --git a/openbox/openbox.c b/openbox/openbox.c index 0c74b255..d1841437 100644 --- a/openbox/openbox.c +++ b/openbox/openbox.c @@ -36,6 +36,7 @@ #include "focus_cycle_popup.h" #include "moveresize.h" #include "frame.h" +#include "framerender.h" #include "keyboard.h" #include "mouse.h" #include "extensions.h" -- 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') 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 3a03a554f0d5fc78ae211b5cf7cd162ea524e157 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 27 Jan 2008 03:17:50 -0500 Subject: window a window stops responding to pings, don't use the xsync protocol while resizing it - its not going to be responding to it anyways --- openbox/moveresize.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'openbox') diff --git a/openbox/moveresize.c b/openbox/moveresize.c index 675cbe9c..9374f8b5 100644 --- a/openbox/moveresize.c +++ b/openbox/moveresize.c @@ -252,7 +252,8 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr) #ifdef SYNC if (config_resize_redraw && !moving && extensions_sync && - moveresize_client->sync_request && moveresize_client->sync_counter) + moveresize_client->sync_request && moveresize_client->sync_counter && + !moveresize_client->not_responding) { /* Initialize values for the resize syncing, and create an alarm for the client's xsync counter */ @@ -367,7 +368,8 @@ static void do_resize(void) #ifdef SYNC if (config_resize_redraw && extensions_sync && - moveresize_client->sync_request && moveresize_client->sync_counter) + moveresize_client->sync_request && moveresize_client->sync_counter && + !moveresize_client->not_responding) { XEvent ce; XSyncValue val; -- cgit v1.2.3 From a4d13100e67791955eef10876c6784748aff2fed Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 27 Jan 2008 03:48:49 -0500 Subject: use setenv/unsetenv instead of putenv, cuz they are not ugly and confusing wrt memory leaks --- openbox/actions/execute.c | 4 ++++ openbox/openbox.c | 4 ++-- openbox/startupnotify.c | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) (limited to 'openbox') diff --git a/openbox/actions/execute.c b/openbox/actions/execute.c index 9ab20d71..a857b1b8 100644 --- a/openbox/actions/execute.c +++ b/openbox/actions/execute.c @@ -4,6 +4,10 @@ #include "openbox/screen.h" #include "gettext.h" +#ifdef HAVE_STDLIB_H +# include +#endif + typedef struct { gchar *cmd; gboolean sn; diff --git a/openbox/openbox.c b/openbox/openbox.c index d1841437..18c34d2f 100644 --- a/openbox/openbox.c +++ b/openbox/openbox.c @@ -194,7 +194,7 @@ gint main(gint argc, gchar **argv) /* set the DISPLAY environment variable for any lauched children, to the display we're using, so they open in the right place. */ - putenv(g_strdup_printf("DISPLAY=%s", DisplayString(ob_display))); + setenv("DISPLAY", DisplayString(ob_display), TRUE); /* create available cursors */ cursors[OB_CURSOR_NONE] = None; @@ -516,7 +516,7 @@ static void remove_args(gint *argc, gchar **argv, gint index, gint num) static void parse_env() { /* unset this so we don't pass it on unknowingly */ - putenv(g_strdup("DESKTOP_STARTUP_ID")); + unsetenv("DESKTOP_STARTUP_ID"); } static void parse_args(gint *argc, gchar **argv) diff --git a/openbox/startupnotify.c b/openbox/startupnotify.c index e9bb8310..e13aa55c 100644 --- a/openbox/startupnotify.c +++ b/openbox/startupnotify.c @@ -21,7 +21,9 @@ #include "gettext.h" #include "event.h" -#include +#ifdef HAVE_STDLIB_H +# include +#endif #ifndef USE_LIBSN @@ -264,7 +266,7 @@ void sn_setup_spawn_environment(const gchar *program, const gchar *name, g_direct_equal, (GDestroyNotify)sn_launcher_context_unref); - putenv(g_strdup_printf("DESKTOP_STARTUP_ID=%s", id)); + setenv("DESKTOP_STARTUP_ID", id, TRUE); g_free(desc); } -- cgit v1.2.3 From d409936faae594df7854b5b42ff707315ca33086 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 27 Jan 2008 04:59:39 -0500 Subject: get rid of copying the rrappearances for each menu frame, except for the one that is actually useful --- openbox/menuframe.c | 165 ++++++++++++++++++++++------------------------------ openbox/menuframe.h | 20 +------ 2 files changed, 71 insertions(+), 114 deletions(-) (limited to 'openbox') diff --git a/openbox/menuframe.c b/openbox/menuframe.c index 979e834f..5ffaaf2f 100644 --- a/openbox/menuframe.c +++ b/openbox/menuframe.c @@ -93,7 +93,6 @@ ObMenuFrame* menu_frame_new(ObMenu *menu, guint show_from, ObClient *client) XSetWindowBorder(ob_display, self->window, RrColorPixel(ob_rr_theme->menu_border_color)); - self->a_title = RrAppearanceCopy(ob_rr_theme->a_menu_title); self->a_items = RrAppearanceCopy(ob_rr_theme->a_menu); stacking_add(MENU_AS_WINDOW(self)); @@ -111,10 +110,9 @@ void menu_frame_free(ObMenuFrame *self) stacking_remove(MENU_AS_WINDOW(self)); - XDestroyWindow(ob_display, self->window); - RrAppearanceFree(self->a_items); - RrAppearanceFree(self->a_title); + + XDestroyWindow(ob_display, self->window); g_free(self); } @@ -149,37 +147,6 @@ static ObMenuEntryFrame* menu_entry_frame_new(ObMenuEntry *entry, XMapWindow(ob_display, self->window); XMapWindow(ob_display, self->text); - self->a_normal = RrAppearanceCopy(ob_rr_theme->a_menu_normal); - self->a_selected = RrAppearanceCopy(ob_rr_theme->a_menu_selected); - self->a_disabled = RrAppearanceCopy(ob_rr_theme->a_menu_disabled); - self->a_disabled_selected = - RrAppearanceCopy(ob_rr_theme->a_menu_disabled_selected); - - if (entry->type == OB_MENU_ENTRY_TYPE_SEPARATOR) { - self->a_separator = RrAppearanceCopy(ob_rr_theme->a_clear_tex); - self->a_separator->texture[0].type = RR_TEXTURE_LINE_ART; - } else { - self->a_icon = RrAppearanceCopy(ob_rr_theme->a_clear_tex); - self->a_icon->texture[0].type = RR_TEXTURE_RGBA; - self->a_mask = RrAppearanceCopy(ob_rr_theme->a_clear_tex); - self->a_mask->texture[0].type = RR_TEXTURE_MASK; - self->a_bullet_normal = - RrAppearanceCopy(ob_rr_theme->a_menu_bullet_normal); - self->a_bullet_selected = - RrAppearanceCopy(ob_rr_theme->a_menu_bullet_selected); - } - - self->a_text_normal = - RrAppearanceCopy(ob_rr_theme->a_menu_text_normal); - self->a_text_selected = - RrAppearanceCopy(ob_rr_theme->a_menu_text_selected); - self->a_text_disabled = - RrAppearanceCopy(ob_rr_theme->a_menu_text_disabled); - self->a_text_disabled_selected = - RrAppearanceCopy(ob_rr_theme->a_menu_text_disabled_selected); - self->a_text_title = - RrAppearanceCopy(ob_rr_theme->a_menu_text_title); - return self; } @@ -201,22 +168,6 @@ static void menu_entry_frame_free(ObMenuEntryFrame *self) g_hash_table_remove(menu_frame_map, &self->bullet); } - RrAppearanceFree(self->a_normal); - RrAppearanceFree(self->a_selected); - RrAppearanceFree(self->a_disabled); - RrAppearanceFree(self->a_disabled_selected); - - RrAppearanceFree(self->a_separator); - RrAppearanceFree(self->a_icon); - RrAppearanceFree(self->a_mask); - RrAppearanceFree(self->a_text_normal); - RrAppearanceFree(self->a_text_selected); - RrAppearanceFree(self->a_text_disabled); - RrAppearanceFree(self->a_text_disabled_selected); - RrAppearanceFree(self->a_text_title); - RrAppearanceFree(self->a_bullet_normal); - RrAppearanceFree(self->a_bullet_selected); - g_free(self); } } @@ -362,18 +313,20 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self) !self->entry->data.normal.enabled ? /* disabled */ (self == self->frame->selected ? - self->a_disabled_selected : self->a_disabled) : + ob_rr_theme->a_menu_disabled_selected : + ob_rr_theme->a_menu_disabled) : /* enabled */ (self == self->frame->selected ? - self->a_selected : self->a_normal)); + ob_rr_theme->a_menu_selected : + ob_rr_theme->a_menu_normal)); th = ITEM_HEIGHT; break; case OB_MENU_ENTRY_TYPE_SEPARATOR: if (self->entry->data.separator.label) { - item_a = self->frame->a_title; + item_a = ob_rr_theme->a_menu_title; th = ob_rr_theme->menu_title_height; } else { - item_a = self->a_normal; + item_a = ob_rr_theme->a_menu_normal; th = SEPARATOR_HEIGHT + 2*PADDING; } break; @@ -394,10 +347,12 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self) !self->entry->data.normal.enabled ? /* disabled */ (self == self->frame->selected ? - self->a_text_disabled_selected : self->a_text_disabled) : + ob_rr_theme->a_menu_text_disabled_selected : + ob_rr_theme->a_menu_text_disabled) : /* enabled */ (self == self->frame->selected ? - self->a_text_selected : self->a_text_normal)); + ob_rr_theme->a_menu_text_selected : + ob_rr_theme->a_menu_text_normal)); text_a->texture[0].data.text.string = self->entry->data.normal.label; if (self->entry->data.normal.shortcut && (self->frame->menu->show_all_shortcuts || @@ -412,8 +367,8 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self) break; case OB_MENU_ENTRY_TYPE_SUBMENU: text_a = (self == self->frame->selected ? - self->a_text_selected : - self->a_text_normal); + ob_rr_theme->a_menu_text_selected : + ob_rr_theme->a_menu_text_normal); sub = self->entry->data.submenu.submenu; text_a->texture[0].data.text.string = sub ? sub->title : ""; if (sub->shortcut && (self->frame->menu->show_all_shortcuts || @@ -427,9 +382,9 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self) break; case OB_MENU_ENTRY_TYPE_SEPARATOR: if (self->entry->data.separator.label != NULL) - text_a = self->a_text_title; + text_a = ob_rr_theme->a_menu_text_title; else - text_a = self->a_text_normal; + text_a = ob_rr_theme->a_menu_text_normal; break; } @@ -472,20 +427,24 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self) ob_rr_theme->menu_title_height - 2*ob_rr_theme->paddingy); } else { + RrAppearance *clear; + /* unlabeled separaator */ XMoveResizeWindow(ob_display, self->text, PADDING, PADDING, self->area.width - 2*PADDING, SEPARATOR_HEIGHT); - self->a_separator->surface.parent = item_a; - self->a_separator->surface.parentx = PADDING; - self->a_separator->surface.parenty = PADDING; - self->a_separator->texture[0].data.lineart.color = + + clear = ob_rr_theme->a_clear_tex; + clear->texture[0].type = RR_TEXTURE_LINE_ART; + clear->surface.parent = item_a; + clear->surface.parentx = PADDING; + clear->surface.parenty = PADDING; + clear->texture[0].data.lineart.color = text_a->texture[0].data.text.color; - self->a_separator->texture[0].data.lineart.x1 = 2*PADDING; - self->a_separator->texture[0].data.lineart.y1 = SEPARATOR_HEIGHT/2; - self->a_separator->texture[0].data.lineart.x2 = - self->area.width - 4*PADDING; - self->a_separator->texture[0].data.lineart.y2 = SEPARATOR_HEIGHT/2; - RrPaint(self->a_separator, self->text, + clear->texture[0].data.lineart.x1 = 2*PADDING; + clear->texture[0].data.lineart.y1 = SEPARATOR_HEIGHT/2; + clear->texture[0].data.lineart.x2 = self->area.width - 4*PADDING; + clear->texture[0].data.lineart.y2 = SEPARATOR_HEIGHT/2; + RrPaint(clear, self->text, self->area.width - 2*PADDING, SEPARATOR_HEIGHT); } break; @@ -494,24 +453,29 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self) if (self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL && self->entry->data.normal.icon_data) { + RrAppearance *clear; + XMoveResizeWindow(ob_display, self->icon, PADDING, frame->item_margin.top, ITEM_HEIGHT - frame->item_margin.top - frame->item_margin.bottom, ITEM_HEIGHT - frame->item_margin.top - frame->item_margin.bottom); - self->a_icon->texture[0].data.rgba.width = + + clear = ob_rr_theme->a_clear_tex; + clear->texture[0].type = RR_TEXTURE_RGBA; + clear->texture[0].data.rgba.width = self->entry->data.normal.icon_width; - self->a_icon->texture[0].data.rgba.height = + clear->texture[0].data.rgba.height = self->entry->data.normal.icon_height; - self->a_icon->texture[0].data.rgba.alpha = + clear->texture[0].data.rgba.alpha = self->entry->data.normal.icon_alpha; - self->a_icon->texture[0].data.rgba.data = + clear->texture[0].data.rgba.data = self->entry->data.normal.icon_data; - self->a_icon->surface.parent = item_a; - self->a_icon->surface.parentx = PADDING; - self->a_icon->surface.parenty = frame->item_margin.top; - RrPaint(self->a_icon, self->icon, + clear->surface.parent = item_a; + clear->surface.parentx = PADDING; + clear->surface.parenty = frame->item_margin.top; + RrPaint(clear, self->icon, ITEM_HEIGHT - frame->item_margin.top - frame->item_margin.bottom, ITEM_HEIGHT - frame->item_margin.top @@ -521,6 +485,7 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self) self->entry->data.normal.mask) { RrColor *c; + RrAppearance *clear; XMoveResizeWindow(ob_display, self->icon, PADDING, frame->item_margin.top, @@ -528,7 +493,10 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self) - frame->item_margin.bottom, ITEM_HEIGHT - frame->item_margin.top - frame->item_margin.bottom); - self->a_mask->texture[0].data.mask.mask = + + clear = ob_rr_theme->a_clear_tex; + clear->texture[0].type = RR_TEXTURE_MASK; + clear->texture[0].data.mask.mask = self->entry->data.normal.mask; c = (self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL && @@ -541,12 +509,12 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self) (self == self->frame->selected ? self->entry->data.normal.mask_selected_color : self->entry->data.normal.mask_normal_color)); - self->a_mask->texture[0].data.mask.color = c; + clear->texture[0].data.mask.color = c; - self->a_mask->surface.parent = item_a; - self->a_mask->surface.parentx = PADDING; - self->a_mask->surface.parenty = frame->item_margin.top; - RrPaint(self->a_mask, self->icon, + clear->surface.parent = item_a; + clear->surface.parentx = PADDING; + clear->surface.parenty = frame->item_margin.top; + RrPaint(clear, self->icon, ITEM_HEIGHT - frame->item_margin.top - frame->item_margin.bottom, ITEM_HEIGHT - frame->item_margin.top @@ -563,8 +531,8 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self) ITEM_HEIGHT - 2*PADDING, ITEM_HEIGHT - 2*PADDING); bullet_a = (self == self->frame->selected ? - self->a_bullet_selected : - self->a_bullet_normal); + ob_rr_theme->a_menu_bullet_selected : + ob_rr_theme->a_menu_bullet_normal); bullet_a->surface.parent = item_a; bullet_a->surface.parentx = self->frame->text_x + self->frame->text_w - ITEM_HEIGHT + PADDING; @@ -640,31 +608,31 @@ void menu_frame_render(ObMenuFrame *self) gint l, t, r, b; e = self->entries->data; - e->a_text_normal->texture[0].data.text.string = ""; - tw = RrMinWidth(e->a_text_normal); + ob_rr_theme->a_menu_text_normal->texture[0].data.text.string = ""; + tw = RrMinWidth(ob_rr_theme->a_menu_text_normal); tw += 2*PADDING; th = ITEM_HEIGHT; - RrMargins(e->a_normal, &l, &t, &r, &b); + RrMargins(ob_rr_theme->a_menu_normal, &l, &t, &r, &b); STRUT_SET(self->item_margin, MAX(self->item_margin.left, l), MAX(self->item_margin.top, t), MAX(self->item_margin.right, r), MAX(self->item_margin.bottom, b)); - RrMargins(e->a_selected, &l, &t, &r, &b); + RrMargins(ob_rr_theme->a_menu_selected, &l, &t, &r, &b); STRUT_SET(self->item_margin, MAX(self->item_margin.left, l), MAX(self->item_margin.top, t), MAX(self->item_margin.right, r), MAX(self->item_margin.bottom, b)); - RrMargins(e->a_disabled, &l, &t, &r, &b); + RrMargins(ob_rr_theme->a_menu_disabled, &l, &t, &r, &b); STRUT_SET(self->item_margin, MAX(self->item_margin.left, l), MAX(self->item_margin.top, t), MAX(self->item_margin.right, r), MAX(self->item_margin.bottom, b)); - RrMargins(e->a_disabled_selected, &l, &t, &r, &b); + RrMargins(ob_rr_theme->a_menu_disabled_selected, &l, &t, &r, &b); STRUT_SET(self->item_margin, MAX(self->item_margin.left, l), MAX(self->item_margin.top, t), @@ -705,10 +673,12 @@ void menu_frame_render(ObMenuFrame *self) !e->entry->data.normal.enabled ? /* disabled */ (e == self->selected ? - e->a_text_disabled_selected : e->a_text_disabled) : + ob_rr_theme->a_menu_text_disabled_selected : + ob_rr_theme->a_menu_text_disabled) : /* enabled */ (e == self->selected ? - e->a_text_selected : e->a_text_normal)); + ob_rr_theme->a_menu_text_selected : + ob_rr_theme->a_menu_text_normal)); switch (e->entry->type) { case OB_MENU_ENTRY_TYPE_NORMAL: text_a->texture[0].data.text.string = e->entry->data.normal.label; @@ -735,9 +705,10 @@ void menu_frame_render(ObMenuFrame *self) break; case OB_MENU_ENTRY_TYPE_SEPARATOR: if (e->entry->data.separator.label != NULL) { - e->a_text_title->texture[0].data.text.string = + ob_rr_theme->a_menu_text_title->texture[0].data.text.string = e->entry->data.separator.label; - tw = RrMinWidth(e->a_text_title) + 2*ob_rr_theme->paddingx; + tw = RrMinWidth(ob_rr_theme->a_menu_text_title) + + 2*ob_rr_theme->paddingx; tw = MIN(tw, MAX_MENU_WIDTH); th = ob_rr_theme->menu_title_height + (ob_rr_theme->mbwidth - PADDING) *2; diff --git a/openbox/menuframe.h b/openbox/menuframe.h index 06975972..1b1dcc70 100644 --- a/openbox/menuframe.h +++ b/openbox/menuframe.h @@ -71,7 +71,9 @@ struct _ObMenuFrame gint monitor; /* monitor on which to show the menu in xinerama */ - RrAppearance *a_title; + /* We make a copy of this for each menu, so that we don't have to re-render + the background of the entire menu each time we render an item inside it. + */ RrAppearance *a_items; gboolean got_press; /* don't allow a KeyRelease event to run things in the @@ -94,22 +96,6 @@ struct _ObMenuEntryFrame Window icon; Window text; Window bullet; - - RrAppearance *a_normal; - RrAppearance *a_selected; - RrAppearance *a_disabled; - RrAppearance *a_disabled_selected; - - RrAppearance *a_icon; - RrAppearance *a_mask; - RrAppearance *a_bullet_normal; - RrAppearance *a_bullet_selected; - RrAppearance *a_separator; - RrAppearance *a_text_normal; - RrAppearance *a_text_selected; - RrAppearance *a_text_disabled; - RrAppearance *a_text_disabled_selected; - RrAppearance *a_text_title; }; extern GHashTable *menu_frame_map; -- cgit v1.2.3 From dd740b5562806a6b4692c938ad0e903ad89b6193 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 27 Jan 2008 11:31:23 -0500 Subject: replace the placement option with active/mouse/any --- openbox/config.c | 16 ++++++++++------ openbox/config.h | 2 +- openbox/place.c | 14 +++++++++----- openbox/place.h | 7 +++++++ 4 files changed, 27 insertions(+), 12 deletions(-) (limited to 'openbox') diff --git a/openbox/config.c b/openbox/config.c index 50f6aef6..5e6387bc 100644 --- a/openbox/config.c +++ b/openbox/config.c @@ -36,9 +36,9 @@ gboolean config_focus_raise; gboolean config_focus_last; gboolean config_focus_under_mouse; -ObPlacePolicy config_place_policy; -gboolean config_place_center; -gboolean config_place_active; +ObPlacePolicy config_place_policy; +gboolean config_place_center; +ObPlaceMonitor config_place_monitor; StrutPartial config_margins; @@ -491,8 +491,12 @@ static void parse_placement(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, config_place_policy = OB_PLACE_POLICY_MOUSE; if ((n = parse_find_node("center", node))) config_place_center = parse_bool(doc, n); - if ((n = parse_find_node("active", node))) - config_place_active = parse_bool(doc, n); + if ((n = parse_find_node("placeOn", node))) { + if (parse_contains("active", doc, n)) + config_place_monitor = OB_PLACE_MONITOR_ACTIVE; + else if (parse_contains("mouse", doc, n)) + config_place_monitor = OB_PLACE_MONITOR_MOUSE; + } } static void parse_margins(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, @@ -886,7 +890,7 @@ void config_startup(ObParseInst *i) config_place_policy = OB_PLACE_POLICY_SMART; config_place_center = TRUE; - config_place_active = FALSE; + config_place_monitor = OB_PLACE_MONITOR_ANY; parse_register(i, "placement", parse_placement, NULL); diff --git a/openbox/config.h b/openbox/config.h index 50e7dfe3..75275a8b 100644 --- a/openbox/config.h +++ b/openbox/config.h @@ -78,7 +78,7 @@ extern ObPlacePolicy config_place_policy; extern gboolean config_place_center; /*! Place windows on the active monitor (unless they are part of an application already on another monitor) */ -extern gboolean config_place_active; +extern ObPlaceMonitor config_place_monitor; /*! User-specified margins around the edge of the screen(s) */ extern StrutPartial config_margins; diff --git a/openbox/place.c b/openbox/place.c index 058bbfbe..81fb9752 100644 --- a/openbox/place.c +++ b/openbox/place.c @@ -108,7 +108,10 @@ static Rect **pick_head(ObClient *c) } } - if (focus_client && client_normal(focus_client)) { + /* skip this if placing by the mouse position */ + if (focus_client && client_normal(focus_client) && + config_place_monitor != OB_PLACE_MONITOR_MOUSE) + { add_choice(choice, client_monitor(focus_client)); ob_debug("placement adding choice %d for normal focused window\n", client_monitor(focus_client)); @@ -146,7 +149,8 @@ static gboolean place_random(ObClient *client, gint *x, gint *y) guint i; areas = pick_head(client); - i = config_place_active ? 0 : g_random_int_range(0, screen_num_monitors); + i = (config_place_monitor != OB_PLACE_MONITOR_ANY) ? + 0 : g_random_int_range(0, screen_num_monitors); l = areas[i]->x; t = areas[i]->y; @@ -255,9 +259,9 @@ static gboolean place_nooverlap(ObClient *c, gint *x, gint *y) /* try ignoring different things to find empty space */ for (ignore = 0; ignore < IGNORE_END && !ret; ignore++) { /* try all monitors in order of preference, but only the first one - if config_place_active is true */ - for (i = 0; (i < (config_place_active ? 1 : screen_num_monitors) && - !ret); ++i) + if config_place_monitor is MOUSE or ACTIVE */ + for (i = 0; (i < (config_place_monitor != OB_PLACE_MONITOR_ANY ? + 1 : screen_num_monitors) && !ret); ++i) { GList *it; diff --git a/openbox/place.h b/openbox/place.h index e2f1d4e4..6a9add40 100644 --- a/openbox/place.h +++ b/openbox/place.h @@ -31,6 +31,13 @@ typedef enum OB_PLACE_POLICY_MOUSE } ObPlacePolicy; +typedef enum +{ + OB_PLACE_MONITOR_ANY, + OB_PLACE_MONITOR_ACTIVE, + OB_PLACE_MONITOR_MOUSE +} ObPlaceMonitor; + gboolean place_client(struct _ObClient *client, gint *x, gint *y, struct _ObAppSettings *settings); -- cgit v1.2.3 From d7837051412b03ef167744d26043c0413614f85b Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sun, 27 Jan 2008 21:03:55 +0100 Subject: Change to . --- openbox/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'openbox') diff --git a/openbox/config.c b/openbox/config.c index 5e6387bc..69904d85 100644 --- a/openbox/config.c +++ b/openbox/config.c @@ -491,7 +491,7 @@ static void parse_placement(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, config_place_policy = OB_PLACE_POLICY_MOUSE; if ((n = parse_find_node("center", node))) config_place_center = parse_bool(doc, n); - if ((n = parse_find_node("placeOn", node))) { + if ((n = parse_find_node("monitor", node))) { if (parse_contains("active", doc, n)) config_place_monitor = OB_PLACE_MONITOR_ACTIVE; else if (parse_contains("mouse", doc, n)) -- 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') 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') 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') 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