From 5a45d4e7bc1139c1da62d0e5c8af98f5d7664cfe Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Thu, 6 Mar 2008 02:28:43 +0100 Subject: [PATCH 1/3] Don't draw titlebar buttons on top of eachother. --- openbox/frame.c | 73 ++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 41 deletions(-) diff --git a/openbox/frame.c b/openbox/frame.c index 0b764a4c..ca5dbb6c 100644 --- a/openbox/frame.c +++ b/openbox/frame.c @@ -1137,15 +1137,37 @@ static gboolean is_button_present(ObFrame *self, const gchar *lc, gint dir) { return FALSE; } +static void place_button(ObFrame *self, const char *lc, gint bwidth, + gint left, gint i, + gint *x, gint *button_on, gint *button_x) +{ + if (!(*button_on = is_button_present(self, lc, i))) + return; + + self->label_width -= bwidth; + if (i > 0) + *button_x = *x; + *x += i * bwidth; + if (i < 0) { + if (self->label_x <= left || *x > self->label_x) { + *button_x = *x; + } else { + /* the button would have been drawn on top of another button */ + *button_on = FALSE; + self->label_width += bwidth; + } + } +} + static void layout_title(ObFrame *self) { gchar *lc; gint i; const gint bwidth = ob_rr_theme->button_size + ob_rr_theme->paddingx + 1; - /* position of the left most button */ + /* position of the leftmost button */ const gint left = ob_rr_theme->paddingx + 1; - /* position of the right most button */ + /* position of the rightmost button */ const gint right = self->width; /* turn them all off */ @@ -1184,53 +1206,23 @@ static void layout_title(ObFrame *self) break; /* break the for loop, do other side of label */ } else if (*lc == 'N') { if (firstcon) *firstcon = OB_FRAME_CONTEXT_ICON; - if ((self->icon_on = is_button_present(self, lc, i))) { - /* icon is bigger than buttons */ - self->label_width -= bwidth + 2; - if (i > 0) self->icon_x = x; - x += i * (bwidth + 2); - if (i < 0) self->icon_x = x; - } + /* icon is bigger than buttons */ + place_button(self, lc, bwidth + 2, left, i, &x, &self->icon_on, &self->icon_x); } else if (*lc == 'D') { if (firstcon) *firstcon = OB_FRAME_CONTEXT_ALLDESKTOPS; - if ((self->desk_on = is_button_present(self, lc, i))) { - self->label_width -= bwidth; - if (i > 0) self->desk_x = x; - x += i * bwidth; - if (i < 0) self->desk_x = x; - } + place_button(self, lc, bwidth, left, i, &x, &self->desk_on, &self->desk_x); } else if (*lc == 'S') { if (firstcon) *firstcon = OB_FRAME_CONTEXT_SHADE; - if ((self->shade_on = is_button_present(self, lc, i))) { - self->label_width -= bwidth; - if (i > 0) self->shade_x = x; - x += i * bwidth; - if (i < 0) self->shade_x = x; - } + place_button(self, lc, bwidth, left, i, &x, &self->shade_on, &self->shade_x); } else if (*lc == 'I') { if (firstcon) *firstcon = OB_FRAME_CONTEXT_ICONIFY; - if ((self->iconify_on = is_button_present(self, lc, i))) { - self->label_width -= bwidth; - if (i > 0) self->iconify_x = x; - x += i * bwidth; - if (i < 0) self->iconify_x = x; - } + place_button(self, lc, bwidth, left, i, &x, &self->iconify_on, &self->iconify_x); } else if (*lc == 'M') { if (firstcon) *firstcon = OB_FRAME_CONTEXT_MAXIMIZE; - if ((self->max_on = is_button_present(self, lc, i))) { - self->label_width -= bwidth; - if (i > 0) self->max_x = x; - x += i * bwidth; - if (i < 0) self->max_x = x; - } + place_button(self, lc, bwidth, left, i, &x, &self->max_on, &self->max_x); } else if (*lc == 'C') { if (firstcon) *firstcon = OB_FRAME_CONTEXT_CLOSE; - if ((self->close_on = is_button_present(self, lc, i))) { - self->label_width -= bwidth; - if (i > 0) self->close_x = x; - x += i * bwidth; - if (i < 0) self->close_x = x; - } + place_button(self, lc, bwidth, left, i, &x, &self->close_on, &self->close_x); } else continue; /* don't set firstcon */ firstcon = NULL; @@ -1280,8 +1272,7 @@ static void layout_title(ObFrame *self) } else XUnmapWindow(ob_display, self->close); - if (self->label_on) { - self->label_width = MAX(1, self->label_width); /* no lower than 1 */ + if (self->label_on && self->label_width > 0) { XMapWindow(ob_display, self->label); XMoveWindow(ob_display, self->label, self->label_x, ob_rr_theme->paddingy); From 617effd275a7c998d9bea686bc1a33240fd16704 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Thu, 6 Mar 2008 20:02:26 +0100 Subject: [PATCH 2/3] Don't run actions in focus cycling actions backwards either (as in 664b0b4e943ba4d410168817dcff953804b44253). --- openbox/actions/cyclewindows.c | 2 +- openbox/actions/directionalwindows.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openbox/actions/cyclewindows.c b/openbox/actions/cyclewindows.c index cb341af7..6fba17ff 100644 --- a/openbox/actions/cyclewindows.c +++ b/openbox/actions/cyclewindows.c @@ -73,7 +73,7 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) m = parse_find_node("action", n->xmlChildrenNode); while (m) { ObActionsAct *action = actions_parse(i, doc, m); - if (action) o->actions = g_slist_prepend(o->actions, action); + if (action) o->actions = g_slist_append(o->actions, action); m = parse_find_node("action", m->next); } } diff --git a/openbox/actions/directionalwindows.c b/openbox/actions/directionalwindows.c index 55c9e606..d9f24d61 100644 --- a/openbox/actions/directionalwindows.c +++ b/openbox/actions/directionalwindows.c @@ -93,7 +93,7 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) m = parse_find_node("action", n->xmlChildrenNode); while (m) { ObActionsAct *action = actions_parse(i, doc, m); - if (action) o->actions = g_slist_prepend(o->actions, action); + if (action) o->actions = g_slist_append(o->actions, action); m = parse_find_node("action", m->next); } } From c716d1788bb4f4b9db403617023f06347ba48102 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sat, 8 Mar 2008 16:42:43 +0100 Subject: [PATCH 3/3] Remove double newlines. --- openbox/actions.c | 1 - openbox/actions/desktop.c | 2 -- openbox/client.c | 7 ------- openbox/config.h | 1 - openbox/event.c | 1 - openbox/focus.c | 1 - openbox/focus_cycle.c | 1 - openbox/frame.c | 1 - openbox/keyboard.c | 1 - openbox/keytree.h | 1 - openbox/menu.c | 1 - openbox/menuframe.c | 2 -- openbox/modkeys.c | 1 - openbox/moveresize.c | 1 - openbox/openbox.c | 3 --- openbox/prompt.c | 1 - openbox/session.c | 1 - render/gradient.c | 1 - render/render.c | 1 - render/test.c | 1 - render/theme.c | 2 -- tests/usertimewin.c | 1 - 22 files changed, 33 deletions(-) diff --git a/openbox/actions.c b/openbox/actions.c index d43896d7..948ac2c0 100644 --- a/openbox/actions.c +++ b/openbox/actions.c @@ -58,7 +58,6 @@ struct _ObActionsAct { static GSList *registered = NULL; - void actions_startup(gboolean reconfig) { if (reconfig) return; diff --git a/openbox/actions/desktop.c b/openbox/actions/desktop.c index 142fec51..bc70748b 100644 --- a/openbox/actions/desktop.c +++ b/openbox/actions/desktop.c @@ -122,8 +122,6 @@ static gboolean run_func(ObActionsData *data, gpointer options) Options *o = options; guint d; - - switch (o->type) { case LAST: d = screen_last_desktop; diff --git a/openbox/client.c b/openbox/client.c index 585379ec..7062cabd 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -108,7 +108,6 @@ static void client_call_notifies(ObClient *self, GSList *list); static void client_ping_event(ObClient *self, gboolean dead); static void client_prompt_kill(ObClient *self); - void client_startup(gboolean reconfig) { if ((client_default_icon = RrImageCacheFind(ob_rr_icons, @@ -503,7 +502,6 @@ void client_manage(Window window, ObPrompt *prompt) (client_search_focus_tree_full(self) != NULL || client_search_focus_group_full(self) != NULL)); - /* This is focus stealing prevention */ ob_debug_type(OB_DEBUG_FOCUS, "Want to focus new window 0x%x at time %u " @@ -658,7 +656,6 @@ void client_manage(Window window, ObPrompt *prompt) return; } - ObClient *client_fake_manage(Window window) { ObClient *self; @@ -1381,7 +1378,6 @@ static void client_update_transient_tree(ObClient *self, transient windows as their children. * * */ - /* No change has occured */ if (oldgroup == newgroup && oldgtran == newgtran && @@ -2194,7 +2190,6 @@ void client_update_icons(ObClient *self) (gint*)&w, (gint*)&h, &data); xerror_set_ignore(FALSE); - if (xicon) { if (w > 0 && h > 0) { /* is this icon in the cache yet? */ @@ -2686,7 +2681,6 @@ gboolean client_enter_focusable(ObClient *self) self->type != OB_CLIENT_TYPE_DESKTOP); } - static void client_apply_startup_state(ObClient *self, gint x, gint y, gint w, gint h) { @@ -2996,7 +2990,6 @@ void client_try_configure(ObClient *self, gint *x, gint *y, gint *w, gint *h, g_assert(*h > 0); } - void client_configure(ObClient *self, gint x, gint y, gint w, gint h, gboolean user, gboolean final, gboolean force_reply) { diff --git a/openbox/config.h b/openbox/config.h index 62b92473..69fe6ff4 100644 --- a/openbox/config.h +++ b/openbox/config.h @@ -198,5 +198,4 @@ ObAppSettings* config_create_app_settings(); void config_app_settings_copy_non_defaults(const ObAppSettings *src, ObAppSettings *dest); - #endif diff --git a/openbox/event.c b/openbox/event.c index a7f65fcb..3abaa675 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -1114,7 +1114,6 @@ static void event_handle_client(ObClient *client, XEvent *e) move = TRUE; } - if (e->xconfigurerequest.value_mask & CWStackMode) { ObClient *sibling = NULL; gulong ignore_start; diff --git a/openbox/focus.c b/openbox/focus.c index 12625fde..63eb2cca 100644 --- a/openbox/focus.c +++ b/openbox/focus.c @@ -359,4 +359,3 @@ gboolean focus_valid_target(ObClient *ft, return ok; } - diff --git a/openbox/focus_cycle.c b/openbox/focus_cycle.c index c7fc42ee..e30672dc 100644 --- a/openbox/focus_cycle.c +++ b/openbox/focus_cycle.c @@ -96,7 +96,6 @@ ObClient* focus_cycle(gboolean forward, gboolean all_desktops, list = client_list; } - if (focus_cycle_target == NULL) { focus_cycle_iconic_windows = TRUE; focus_cycle_all_desktops = all_desktops; diff --git a/openbox/frame.c b/openbox/frame.c index ca5dbb6c..235dd30b 100644 --- a/openbox/frame.c +++ b/openbox/frame.c @@ -590,7 +590,6 @@ void frame_adjust_area(ObFrame *self, gboolean moved, sidebwidth) * 2, self->bwidth); - if (sidebwidth) { XMoveResizeWindow(ob_display, self->lgripleft, 0, diff --git a/openbox/keyboard.c b/openbox/keyboard.c index c318a4cf..e62cff8a 100644 --- a/openbox/keyboard.c +++ b/openbox/keyboard.c @@ -326,4 +326,3 @@ void keyboard_shutdown(gboolean reconfig) popup_free(popup); popup = NULL; } - diff --git a/openbox/keytree.h b/openbox/keytree.h index 391cb154..66edc3c7 100644 --- a/openbox/keytree.h +++ b/openbox/keytree.h @@ -42,5 +42,4 @@ void tree_assimilate(KeyBindingTree *node); KeyBindingTree *tree_find(KeyBindingTree *search, gboolean *conflict); gboolean tree_chroot(KeyBindingTree *tree, GList *keylist); - #endif diff --git a/openbox/menu.c b/openbox/menu.c index 0c10b757..23a0527a 100644 --- a/openbox/menu.c +++ b/openbox/menu.c @@ -62,7 +62,6 @@ static gunichar parse_shortcut(const gchar *label, gboolean allow_shortcut, gchar **strippedlabel, guint *position, gboolean *always_show); - static void client_dest(ObClient *client, gpointer data) { /* menus can be associated with a client, so close any that are since diff --git a/openbox/menuframe.c b/openbox/menuframe.c index ac1d88d5..a9b54408 100644 --- a/openbox/menuframe.c +++ b/openbox/menuframe.c @@ -696,7 +696,6 @@ void menu_frame_render(ObMenuFrame *self) XSetWindowBorder(ob_display, e->window, RrColorPixel(ob_rr_theme->menu_border_color)); - text_a = (e->entry->type == OB_MENU_ENTRY_TYPE_NORMAL && !e->entry->data.normal.enabled ? /* disabled */ @@ -1086,7 +1085,6 @@ void menu_frame_hide_all_client(ObClient *client) } } - ObMenuFrame* menu_frame_under(gint x, gint y) { ObMenuFrame *ret = NULL; diff --git a/openbox/modkeys.c b/openbox/modkeys.c index 9e8da321..c52cbef1 100644 --- a/openbox/modkeys.c +++ b/openbox/modkeys.c @@ -187,4 +187,3 @@ KeyCode modkeys_sym_to_code(KeySym sym) return i; return 0; } - diff --git a/openbox/moveresize.c b/openbox/moveresize.c index 9374f8b5..c023340e 100644 --- a/openbox/moveresize.c +++ b/openbox/moveresize.c @@ -348,7 +348,6 @@ static void do_move(gboolean keyboard, gint keydist) moveresize_client->frame->area.y); } - static void do_resize(void) { gint x, y, w, h, lw, lh; diff --git a/openbox/openbox.c b/openbox/openbox.c index 7221556e..4a49c802 100644 --- a/openbox/openbox.c +++ b/openbox/openbox.c @@ -85,7 +85,6 @@ #include #include - RrInstance *ob_rr_inst; RrImageCache *ob_rr_icons; RrTheme *ob_rr_theme; @@ -148,7 +147,6 @@ gint main(gint argc, gchar **argv) session_startup(argc, argv); } - ob_display = XOpenDisplay(NULL); if (ob_display == NULL) ob_exit_with_error(_("Failed to open the display from the DISPLAY environment variable.")); @@ -223,7 +221,6 @@ gint main(gint argc, gchar **argv) cursors[OB_CURSOR_NORTHWEST] = load_cursor("top_left_corner", XC_top_left_corner); - prop_startup(); /* get atoms values for the display */ extensions_query_all(); /* find which extensions are present */ diff --git a/openbox/prompt.c b/openbox/prompt.c index f531b70c..53ed2d7d 100644 --- a/openbox/prompt.c +++ b/openbox/prompt.c @@ -294,7 +294,6 @@ static void prompt_layout(ObPrompt *self) self->button[i].width = MAX(self->button[i].width, bw); self->button[i].height = MAX(self->button[i].height, bh); - self->button[i].width += BUTTON_HMARGIN * 2; self->button[i].height += BUTTON_VMARGIN * 2; diff --git a/openbox/session.c b/openbox/session.c index ab6864b3..77dc5de0 100644 --- a/openbox/session.c +++ b/openbox/session.c @@ -397,7 +397,6 @@ static void sm_save_yourself_2(SmcConn conn, SmPointer data) SmcSaveYourselfDone(conn, success); } - static void sm_save_yourself(SmcConn conn, SmPointer data, gint save_type, Bool shutdown, gint interact_style, Bool fast) { diff --git a/render/gradient.c b/render/gradient.c index fc75047f..2f9bfd27 100644 --- a/render/gradient.c +++ b/render/gradient.c @@ -659,7 +659,6 @@ static void gradient_vertical(RrSurface *sf, gint w, gint h) } } - static void gradient_diagonal(RrSurface *sf, gint w, gint h) { gint x, y; diff --git a/render/render.c b/render/render.c index fd442d26..7c00c146 100644 --- a/render/render.c +++ b/render/render.c @@ -333,7 +333,6 @@ void RrAppearanceFree(RrAppearance *a) } } - static void pixel_data_to_pixmap(RrAppearance *l, gint x, gint y, gint w, gint h) { diff --git a/render/test.c b/render/test.c index 36c962da..55ab621e 100644 --- a/render/test.c +++ b/render/test.c @@ -90,7 +90,6 @@ gint main() exit (0); #endif - RrPaint(look, win, w, h); done = 0; while (!done) { diff --git a/render/theme.c b/render/theme.c index 8c7393b5..d040c171 100644 --- a/render/theme.c +++ b/render/theme.c @@ -567,7 +567,6 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name, theme->def_win_icon_w = OB_DEFAULT_ICON_WIDTH; theme->def_win_icon_h = OB_DEFAULT_ICON_HEIGHT; - /* read the decoration textures */ if (!read_appearance(db, inst, "window.active.title.bg", theme->a_focused_title, @@ -1763,7 +1762,6 @@ static void parse_appearance(gchar *tex, RrSurfaceColorType *grad, *interlaced = FALSE; } - static gboolean read_appearance(XrmDatabase db, const RrInstance *inst, const gchar *rname, RrAppearance *value, gboolean allow_trans) diff --git a/tests/usertimewin.c b/tests/usertimewin.c index 7ef934f2..7a2aa973 100644 --- a/tests/usertimewin.c +++ b/tests/usertimewin.c @@ -66,7 +66,6 @@ int main () { PropModeReplace, (unsigned char*)&num, 1); XFlush(display); - while (1) { XNextEvent(display, &report); }