From cd4f325ee7a3a64eb986931a0575e5f1c3c587c3 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Fri, 22 Feb 2008 10:38:14 -0500 Subject: Let ObPrompts be modal dialogs, and when they are transient for a window, make it transient for its entire group, so it can be stacked at the highest level above other transients --- openbox/client.c | 2 +- openbox/prompt.c | 32 +++++++++++++++++++++++++++++--- openbox/prompt.h | 2 +- openbox/prop.c | 1 + openbox/prop.h | 1 + 5 files changed, 33 insertions(+), 5 deletions(-) diff --git a/openbox/client.c b/openbox/client.c index 9fa311cf..32daf663 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -3442,7 +3442,7 @@ static void client_prompt_kill(ObClient *self) g_free(m); } - prompt_show(self->kill_prompt, self); + prompt_show(self->kill_prompt, self, TRUE); } void client_kill(ObClient *self) diff --git a/openbox/prompt.c b/openbox/prompt.c index 84fe2d0d..d3a1ab7b 100644 --- a/openbox/prompt.c +++ b/openbox/prompt.c @@ -21,6 +21,7 @@ #include "screen.h" #include "openbox.h" #include "client.h" +#include "group.h" #include "prop.h" #include "modkeys.h" #include "event.h" @@ -435,7 +436,7 @@ static void render_all(ObPrompt *self) render_button(self, &self->button[i]); } -void prompt_show(ObPrompt *self, ObClient *parent) +void prompt_show(ObPrompt *self, ObClient *parent, gboolean modal) { gint i; @@ -457,8 +458,33 @@ void prompt_show(ObPrompt *self, ObClient *parent) break; } - XSetTransientForHint(ob_display, self->super.window, - (parent ? parent->window : 0)); + if (parent) { + Atom states[1]; + gint nstates; + Window p; + XWMHints h; + + if (parent->group) { + /* make it transient for the window's group */ + h.flags = WindowGroupHint; + h.window_group = parent->group->leader; + p = RootWindow(ob_display, ob_screen); + } + else { + /* make it transient for the window directly */ + h.flags = 0; + p = parent->window; + } + + XSetWMHints(ob_display, self->super.window, &h); + PROP_SET32(self->super.window, wm_transient_for, window, p); + + states[0] = prop_atoms.net_wm_state_modal; + nstates = (modal ? 1 : 0); + PROP_SETA32(self->super.window, net_wm_state, atom, states, nstates); + } + else + PROP_ERASE(self->super.window, wm_transient_for); /* set up the dialog and render it */ prompt_layout(self); diff --git a/openbox/prompt.h b/openbox/prompt.h index c24f0448..89d3d598 100644 --- a/openbox/prompt.h +++ b/openbox/prompt.h @@ -100,7 +100,7 @@ void prompt_ref(ObPrompt *self); void prompt_unref(ObPrompt *self); /*! Show the prompt. It will be centered within the given area rectangle */ -void prompt_show(ObPrompt *self, struct _ObClient *parent); +void prompt_show(ObPrompt *self, struct _ObClient *parent, gboolean modal); void prompt_hide(ObPrompt *self); gboolean prompt_key_event(ObPrompt *self, XEvent *e); diff --git a/openbox/prop.c b/openbox/prop.c index 695e441f..5dc4a2fa 100644 --- a/openbox/prop.c +++ b/openbox/prop.c @@ -51,6 +51,7 @@ void prop_startup(void) CREATE(wm_client_machine, "WM_CLIENT_MACHINE"); CREATE(wm_command, "WM_COMMAND"); CREATE(wm_client_leader, "WM_CLIENT_LEADER"); + CREATE(wm_transient_for, "WM_TRANSIENT_FOR"); CREATE(motif_wm_hints, "_MOTIF_WM_HINTS"); CREATE(sm_client_id, "SM_CLIENT_ID"); diff --git a/openbox/prop.h b/openbox/prop.h index ae423271..46c93017 100644 --- a/openbox/prop.h +++ b/openbox/prop.h @@ -53,6 +53,7 @@ typedef struct Atoms { Atom wm_client_machine; Atom wm_command; Atom wm_client_leader; + Atom wm_transient_for; Atom motif_wm_hints; /* SM atoms */ -- cgit v1.2.3 From fadc52e1869fbdda3d30a8131ca5c5c1da7c6e98 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Fri, 22 Feb 2008 10:52:04 -0500 Subject: Allow windows to specify a base-size of 0 This fixes the resize popup for terminal windows, if the base-size was 0, the size popup would be off by one. --- openbox/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openbox/client.c b/openbox/client.c index 32daf663..fbe728d1 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -1621,7 +1621,7 @@ void client_update_normal_hints(ObClient *self) self->min_ratio = 0.0f; self->max_ratio = 0.0f; SIZE_SET(self->size_inc, 1, 1); - SIZE_SET(self->base_size, 0, 0); + SIZE_SET(self->base_size, -1, -1); SIZE_SET(self->min_size, 0, 0); SIZE_SET(self->max_size, G_MAXINT, G_MAXINT); @@ -2895,7 +2895,7 @@ void client_try_configure(ObClient *self, gint *x, gint *y, gint *w, gint *h, 0 : self->max_ratio; /* base size is substituted with min size if not specified */ - if (self->base_size.width || self->base_size.height) { + if (self->base_size.width >= 0 || self->base_size.height >= 0) { basew = self->base_size.width; baseh = self->base_size.height; } else { -- cgit v1.2.3 From d9e6aa5643e74ab84fde0ddb1fcb8418ff212281 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Fri, 22 Feb 2008 12:12:20 -0500 Subject: Add theme options for menu line separators. Added: menu.separator.color menu.separator.width menu.separator.padding.width menu.separator.padding.height --- openbox/menuframe.c | 72 ++++++++++++++++++++++++++++++++++------------------- render/theme.c | 18 ++++++++++++++ render/theme.h | 4 +++ 3 files changed, 68 insertions(+), 26 deletions(-) diff --git a/openbox/menuframe.c b/openbox/menuframe.c index 54f0cdbc..ac1d88d5 100644 --- a/openbox/menuframe.c +++ b/openbox/menuframe.c @@ -30,7 +30,6 @@ #include "render/theme.h" #define PADDING 2 -#define SEPARATOR_HEIGHT 3 #define MAX_MENU_WIDTH 400 #define ITEM_HEIGHT (ob_rr_theme->menu_font_height + 2*PADDING) @@ -41,6 +40,9 @@ ButtonPressMask | ButtonReleaseMask) GList *menu_frame_visible; +GHashTable *menu_frame_map; + +static RrAppearance *a_sep; static ObMenuEntryFrame* menu_entry_frame_new(ObMenuEntry *entry, ObMenuFrame *frame); @@ -57,10 +59,18 @@ static Window createWindow(Window parent, gulong mask, RrVisual(ob_rr_inst), mask, attrib); } -GHashTable *menu_frame_map; - void menu_frame_startup(gboolean reconfig) { + gint i; + + a_sep = RrAppearanceCopy(ob_rr_theme->a_clear); + RrAppearanceAddTextures(a_sep, ob_rr_theme->menu_sep_width); + for (i = 0; i < ob_rr_theme->menu_sep_width; ++i) { + a_sep->texture[i].type = RR_TEXTURE_LINE_ART; + a_sep->texture[i].data.lineart.color = + ob_rr_theme->menu_sep_color; + } + if (reconfig) return; menu_frame_map = g_hash_table_new(g_int_hash, g_int_equal); @@ -68,6 +78,8 @@ void menu_frame_startup(gboolean reconfig) void menu_frame_shutdown(gboolean reconfig) { + RrAppearanceFree(a_sep); + if (reconfig) return; g_hash_table_destroy(menu_frame_map); @@ -333,7 +345,8 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self) th = ob_rr_theme->menu_title_height; } else { item_a = ob_rr_theme->a_menu_normal; - th = SEPARATOR_HEIGHT + 2*PADDING; + th = ob_rr_theme->menu_sep_width + + 2*ob_rr_theme->menu_sep_paddingy; } break; default: @@ -437,26 +450,31 @@ 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); - - clear = ob_rr_theme->a_clear_tex; - RrAppearanceClearTextures(clear); - 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; - 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); + gint i; + + /* unlabeled separator */ + XMoveResizeWindow(ob_display, self->text, 0, 0, + self->area.width, + ob_rr_theme->menu_sep_width + + 2*ob_rr_theme->menu_sep_paddingy); + + a_sep->surface.parent = item_a; + a_sep->surface.parentx = 0; + a_sep->surface.parenty = 0; + for (i = 0; i < ob_rr_theme->menu_sep_width; ++i) { + a_sep->texture[i].data.lineart.x1 = + ob_rr_theme->menu_sep_paddingx; + a_sep->texture[i].data.lineart.y1 = + ob_rr_theme->menu_sep_paddingy + i; + a_sep->texture[i].data.lineart.x2 = + self->area.width - ob_rr_theme->menu_sep_paddingx - 1; + a_sep->texture[i].data.lineart.y2 = + ob_rr_theme->menu_sep_paddingy + i; + } + + RrPaint(a_sep, self->text, self->area.width, + ob_rr_theme->menu_sep_width + + 2*ob_rr_theme->menu_sep_paddingy); } break; } @@ -592,7 +610,8 @@ static gint menu_entry_frame_get_height(ObMenuEntryFrame *self, if (last_entry) h -= ob_rr_theme->mbwidth; } else { - h += SEPARATOR_HEIGHT; + h += ob_rr_theme->menu_sep_width + + 2*ob_rr_theme->menu_sep_paddingy - PADDING * 2; } break; } @@ -723,7 +742,8 @@ void menu_frame_render(ObMenuFrame *self) (ob_rr_theme->mbwidth - PADDING) *2; } else { tw = 0; - th = SEPARATOR_HEIGHT; + th = ob_rr_theme->menu_sep_width + + 2*ob_rr_theme->menu_sep_paddingy - 2*PADDING; } break; } diff --git a/render/theme.c b/render/theme.c index 8428f1d9..8c7393b5 100644 --- a/render/theme.c +++ b/render/theme.c @@ -211,6 +211,17 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name, if (!read_int(db, "window.client.padding.height", &theme->cbwidthy) || theme->cbwidthy < 0 || theme->cbwidthy > 100) theme->cbwidthy = theme->cbwidthx; + if (!read_int(db, "menu.separator.width", &theme->menu_sep_width) || + theme->menu_sep_width < 1 || theme->menu_sep_width > 100) + theme->menu_sep_width = 1; + if (!read_int(db, "menu.separator.padding.width", + &theme->menu_sep_paddingx) || + theme->menu_sep_paddingx < 0 || theme->menu_sep_paddingx > 100) + theme->menu_sep_paddingx = 6; + if (!read_int(db, "menu.separator.padding.height", + &theme->menu_sep_paddingy) || + theme->menu_sep_paddingy < 0 || theme->menu_sep_paddingy > 100) + theme->menu_sep_paddingy = 3; /* load colors */ if (!read_color(db, inst, @@ -408,6 +419,12 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name, "menu.items.active.text.color", &theme->menu_selected_color)) theme->menu_selected_color = RrColorNew(inst, 0, 0, 0); + if (!read_color(db, inst, + "menu.separator.color", &theme->menu_sep_color)) + theme->menu_sep_color = RrColorNew(inst, + theme->menu_color->r, + theme->menu_color->g, + theme->menu_color->b); /* load the image masks */ @@ -1408,6 +1425,7 @@ void RrThemeFree(RrTheme *theme) RrColorFree(theme->titlebut_focused_unpressed_color); RrColorFree(theme->titlebut_unfocused_unpressed_color); RrColorFree(theme->menu_title_color); + RrColorFree(theme->menu_sep_color); RrColorFree(theme->menu_color); RrColorFree(theme->menu_selected_color); RrColorFree(theme->menu_disabled_color); diff --git a/render/theme.h b/render/theme.h index 1940970a..a14dac29 100644 --- a/render/theme.h +++ b/render/theme.h @@ -47,6 +47,9 @@ struct _RrTheme { gint cbwidthy; gint menu_overlap_x; gint menu_overlap_y; + gint menu_sep_width; + gint menu_sep_paddingx; + gint menu_sep_paddingy; /* these ones are calculated, not set directly by the theme file */ gint win_font_height; gint menu_title_font_height; @@ -84,6 +87,7 @@ struct _RrTheme { RrColor *titlebut_focused_unpressed_color; RrColor *titlebut_unfocused_unpressed_color; RrColor *menu_title_color; + RrColor *menu_sep_color; RrColor *menu_color; RrColor *menu_selected_color; RrColor *menu_disabled_color; -- cgit v1.2.3