From dcb0665e747c8043f4d83c1a192957c946b3bb03 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 10 Jun 2007 22:00:46 +0000 Subject: [PATCH] merge r7484-7491 from trunk --- openbox/action.c | 23 ++++++++++++++++------- openbox/client.c | 8 ++++---- openbox/menu.c | 25 +++++++++++++++++++++---- openbox/menu.h | 4 +++- openbox/screen.c | 12 +++++++----- render/gradient.c | 37 +++++++++++++++++++------------------ render/render.c | 4 ++++ render/render.h | 2 ++ render/theme.c | 11 ++++++++++- 9 files changed, 86 insertions(+), 40 deletions(-) diff --git a/openbox/action.c b/openbox/action.c index bf675233..4c745b2d 100644 --- a/openbox/action.c +++ b/openbox/action.c @@ -1466,21 +1466,30 @@ void action_move_relative(union ActionData *data) void action_resize_relative(union ActionData *data) { ObClient *c = data->relative.any.c; - gint x, y, w1, w2, h1, h2, lw, lh; + gint x, y, ow, xoff, nw, oh, yoff, nh, lw, lh; client_action_start(data); x = c->area.x; y = c->area.y; - w1 = c->area.width + data->relative.deltax * c->size_inc.width; - w2 = c->area.width + data->relative.deltax * c->size_inc.width + ow = c->area.width; + xoff = -data->relative.deltaxl * c->size_inc.width; + nw = ow + data->relative.deltax * c->size_inc.width + data->relative.deltaxl * c->size_inc.width; - h1 = c->area.height + data->relative.deltay * c->size_inc.height; - h2 = c->area.height + data->relative.deltay * c->size_inc.height + oh = c->area.height; + yoff = -data->relative.deltayu * c->size_inc.height; + nh = oh + data->relative.deltay * c->size_inc.height + data->relative.deltayu * c->size_inc.height; + + g_print("deltax %d %d x %d ow %d xoff %d nw %d\n", + data->relative.deltax, + data->relative.deltaxl, + x, ow, xoff, nw); - client_try_configure(c, &x, &y, &w2, &h2, &lw, &lh, TRUE); - client_move_resize(c, x + (w1 - w2), y + (h1 - h2), w2, h2); + client_try_configure(c, &x, &y, &nw, &nh, &lw, &lh, TRUE); + xoff = xoff == 0 ? 0 : (xoff < 0 ? MAX(xoff, ow-nw) : MIN(xoff, ow-nw)); + yoff = yoff == 0 ? 0 : (yoff < 0 ? MAX(yoff, oh-nh) : MIN(yoff, oh-nh)); + client_move_resize(c, x + xoff, y + yoff, nw, nh); client_action_end(data, FALSE); } diff --git a/openbox/client.c b/openbox/client.c index dbe203a6..15b61352 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -2554,10 +2554,10 @@ static void client_apply_startup_state(ObClient *self, */ client_try_configure(self, &x, &y, &w, &h, &l, &l, FALSE); ob_debug("placed window 0x%x at %d, %d with size %d x %d\n", - self->window, self->area.x, self->area.y, - self->area.width, self->area.height); - oldarea = self->area; /* save the area */ - RECT_SET(self->area, x, y, w, h); /* put where it should be for the premax stuff */ + self->window, x, y, w, h); + /* save the area, and make it where it should be for the premax stuff */ + oldarea = self->area; + RECT_SET(self->area, x, y, w, h); /* apply the states. these are in a carefully crafted order.. */ diff --git a/openbox/menu.c b/openbox/menu.c index 21c00a31..c82eab80 100644 --- a/openbox/menu.c +++ b/openbox/menu.c @@ -134,7 +134,22 @@ void menu_shutdown(gboolean reconfig) static gboolean menu_pipe_submenu(gpointer key, gpointer val, gpointer data) { ObMenu *menu = val; - return menu->pipe_creator == data; + return menu->pipe_creator != NULL; +} + +static void clear_cache(gpointer key, gpointer val, gpointer data) +{ + ObMenu *menu = val; + if (menu->execute) + menu_clear_entries(menu); +} + +void menu_clear_pipe_caches() +{ + /* delete any pipe menus' submenus */ + g_hash_table_foreach_remove(menu_hash, menu_pipe_submenu, NULL); + /* empty the top level pipe menus */ + g_hash_table_foreach(menu_hash, clear_cache, NULL); } void menu_pipe_execute(ObMenu *self) @@ -146,6 +161,8 @@ void menu_pipe_execute(ObMenu *self) if (!self->execute) return; + if (self->entries) /* the entries are already created and cached */ + return; if (!g_spawn_command_line_sync(self->execute, &output, NULL, NULL, &err)) { g_message(_("Failed to execute command for pipe-menu '%s': %s"), @@ -157,9 +174,6 @@ void menu_pipe_execute(ObMenu *self) if (parse_load_mem(output, strlen(output), "openbox_pipe_menu", &doc, &node)) { - g_hash_table_foreach_remove(menu_hash, menu_pipe_submenu, self); - menu_clear_entries(self); - menu_parse_state.pipe_creator = self; menu_parse_state.parent = self; parse_tree(menu_parse_inst, doc, node->children); @@ -410,6 +424,9 @@ void menu_show(gchar *name, gint x, gint y, gint button, ObClient *client) menu_frame_hide_all(); + /* clear the pipe menus when showing a new menu */ + menu_clear_pipe_caches(); + frame = menu_frame_new(self, 0, client); if (!menu_frame_show_topmenu(frame, x, y, button)) menu_frame_free(frame); diff --git a/openbox/menu.h b/openbox/menu.h index 591dfb65..6288d870 100644 --- a/openbox/menu.h +++ b/openbox/menu.h @@ -165,8 +165,10 @@ ObMenu* menu_new(const gchar *name, const gchar *title, gboolean allow_shortcut_selection, gpointer data); void menu_free(ObMenu *menu); -/* Repopulate a pipe-menu by running its command */ +/*! Repopulate a pipe-menu by running its command */ void menu_pipe_execute(ObMenu *self); +/*! Clear a pipe-menu's entries */ +void menu_clear_pipe_caches(); void menu_show_all_shortcuts(ObMenu *self, gboolean show); diff --git a/openbox/screen.c b/openbox/screen.c index a9b045ff..7e2d8645 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -543,6 +543,7 @@ void screen_set_desktop(guint num, gboolean dofocus) GList *it; guint old; gulong ignore_start; + gboolean allow_omni; g_assert(num < screen_num_desktops); @@ -574,10 +575,11 @@ void screen_set_desktop(guint num, gboolean dofocus) } } - if (focus_client && ((client_normal(focus_client) && - focus_client->desktop == DESKTOP_ALL) || - focus_client->desktop == screen_desktop)) - dofocus = FALSE; + /* only allow omnipresent windows to get focus on desktop change if + an omnipresent window is already focused (it'll keep focus probably, but + maybe not depending on mouse-focus options) */ + allow_omni = focus_client && (client_normal(focus_client) && + focus_client->desktop == DESKTOP_ALL); /* have to try focus here because when you leave an empty desktop there is no focus out to watch for. also, we have different rules @@ -587,7 +589,7 @@ void screen_set_desktop(guint num, gboolean dofocus) do this before hiding the windows so if helper windows are coming with us, they don't get hidden */ - if (dofocus && (c = focus_fallback(TRUE, !config_focus_last, FALSE))) + if (dofocus && (c = focus_fallback(TRUE, !config_focus_last, allow_omni))) { /* only do the flicker reducing stuff ahead of time if we are going to call xsetinputfocus on the window ourselves. otherwise there is diff --git a/render/gradient.c b/render/gradient.c index ad126513..ccfd6071 100644 --- a/render/gradient.c +++ b/render/gradient.c @@ -23,7 +23,7 @@ #include "color.h" #include -static void highlight(RrPixel32 *x, RrPixel32 *y, gboolean raised); +static void highlight(RrSurface *s, RrPixel32 *x, RrPixel32 *y, gboolean raised); static void gradient_parentrelative(RrAppearance *a, gint w, gint h); static void gradient_solid(RrAppearance *l, gint w, gint h); static void gradient_splitvertical(RrAppearance *a, gint w, gint h); @@ -110,29 +110,29 @@ void RrRender(RrAppearance *a, gint w, gint h) if (a->surface.relief != RR_RELIEF_FLAT) { if (a->surface.bevel == RR_BEVEL_1) { for (off = 1, x = 1; x < w - 1; ++x, off++) - highlight(data + off, + highlight(&a->surface, data + off, data + off + (h-1) * w, a->surface.relief==RR_RELIEF_RAISED); for (off = 0, x = 0; x < h; ++x, off++) - highlight(data + off * w, + highlight(&a->surface, data + off * w, data + off * w + w - 1, a->surface.relief==RR_RELIEF_RAISED); } if (a->surface.bevel == RR_BEVEL_2) { for (off = 2, x = 2; x < w - 2; ++x, off++) - highlight(data + off + w, + highlight(&a->surface, data + off + w, data + off + (h-2) * w, a->surface.relief==RR_RELIEF_RAISED); for (off = 1, x = 1; x < h-1; ++x, off++) - highlight(data + off * w + 1, + highlight(&a->surface, data + off * w + 1, data + off * w + w - 2, a->surface.relief==RR_RELIEF_RAISED); } } } -static void highlight(RrPixel32 *x, RrPixel32 *y, gboolean raised) +static void highlight(RrSurface *s, RrPixel32 *x, RrPixel32 *y, gboolean raised) { gint r, g, b; @@ -144,12 +144,13 @@ static void highlight(RrPixel32 *x, RrPixel32 *y, gboolean raised) up = y; down = x; } + r = (*up >> RrDefaultRedOffset) & 0xFF; - r += r >> 1; + r += (r * s->bevel_light_adjust) >> 8; g = (*up >> RrDefaultGreenOffset) & 0xFF; - g += g >> 1; + g += (g * s->bevel_light_adjust) >> 8; b = (*up >> RrDefaultBlueOffset) & 0xFF; - b += b >> 1; + b += (b * s->bevel_light_adjust) >> 8; if (r > 0xFF) r = 0xFF; if (g > 0xFF) g = 0xFF; if (b > 0xFF) b = 0xFF; @@ -157,11 +158,11 @@ static void highlight(RrPixel32 *x, RrPixel32 *y, gboolean raised) + (b << RrDefaultBlueOffset); r = (*down >> RrDefaultRedOffset) & 0xFF; - r = (r >> 1) + (r >> 2); + r -= (r * s->bevel_dark_adjust) >> 8; g = (*down >> RrDefaultGreenOffset) & 0xFF; - g = (g >> 1) + (g >> 2); + g -= (g * s->bevel_dark_adjust) >> 8; b = (*down >> RrDefaultBlueOffset) & 0xFF; - b = (b >> 1) + (b >> 2); + b -= (b * s->bevel_dark_adjust) >> 8; *down = (r << RrDefaultRedOffset) + (g << RrDefaultGreenOffset) + (b << RrDefaultBlueOffset); } @@ -172,11 +173,11 @@ static void create_bevel_colors(RrAppearance *l) /* light color */ r = l->surface.primary->r; - r += r >> 1; + r += (r * l->surface.bevel_light_adjust) >> 8; g = l->surface.primary->g; - g += g >> 1; + g += (g * l->surface.bevel_light_adjust) >> 8; b = l->surface.primary->b; - b += b >> 1; + b += (b * l->surface.bevel_light_adjust) >> 8; if (r > 0xFF) r = 0xFF; if (g > 0xFF) g = 0xFF; if (b > 0xFF) b = 0xFF; @@ -185,11 +186,11 @@ static void create_bevel_colors(RrAppearance *l) /* dark color */ r = l->surface.primary->r; - r = (r >> 1) + (r >> 2); + r -= (r * l->surface.bevel_dark_adjust) >> 8; g = l->surface.primary->g; - g = (g >> 1) + (g >> 2); + g -= (g * l->surface.bevel_dark_adjust) >> 8; b = l->surface.primary->b; - b = (b >> 1) + (b >> 2); + b -= (b * l->surface.bevel_dark_adjust) >> 8; g_assert(!l->surface.bevel_dark); l->surface.bevel_dark = RrColorNew(l->inst, r, g, b); } diff --git a/render/render.c b/render/render.c index e259f622..63c1e724 100644 --- a/render/render.c +++ b/render/render.c @@ -171,6 +171,8 @@ RrAppearance *RrAppearanceNew(const RrInstance *inst, gint numtex) out = g_new0(RrAppearance, 1); out->inst = inst; out->textures = numtex; + out->surface.bevel_light_adjust = 128; + out->surface.bevel_dark_adjust = 64; if (numtex) out->texture = g_new0(RrTexture, numtex); return out; @@ -240,6 +242,8 @@ RrAppearance *RrAppearanceCopy(RrAppearance *orig) else spc->bevel_light = NULL; spc->interlaced = spo->interlaced; + spc->bevel_light_adjust = spo->bevel_light_adjust; + spc->bevel_dark_adjust = spo->bevel_dark_adjust; spc->border = spo->border; spc->parent = NULL; spc->parentx = spc->parenty = 0; diff --git a/render/render.h b/render/render.h index 7a3e5965..8731c852 100644 --- a/render/render.h +++ b/render/render.h @@ -117,6 +117,8 @@ struct _RrSurface { RrColor *bevel_dark; RrColor *bevel_light; RrColor *interlace_color; + gint bevel_dark_adjust; /* 0-255, default is 64 */ + gint bevel_light_adjust; /* 0-255, default is 128 */ gboolean interlaced; gboolean border; RrAppearance *parent; diff --git a/render/theme.c b/render/theme.c index ae281948..70944944 100644 --- a/render/theme.c +++ b/render/theme.c @@ -1760,14 +1760,17 @@ static gboolean read_appearance(XrmDatabase db, const RrInstance *inst, { gboolean ret = FALSE; gchar *rclass = create_class_name(rname); - gchar *cname, *ctoname, *bcname, *icname; + gchar *cname, *ctoname, *bcname, *icname, *hname, *sname; gchar *rettype; XrmValue retvalue; + gint i; cname = g_strconcat(rname, ".color", NULL); ctoname = g_strconcat(rname, ".colorTo", NULL); bcname = g_strconcat(rname, ".border.color", NULL); icname = g_strconcat(rname, ".interlace.color", NULL); + hname = g_strconcat(rname, ".highlight", NULL); + sname = g_strconcat(rname, ".shadow", NULL); if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) && retvalue.addr != NULL) { @@ -1790,9 +1793,15 @@ static gboolean read_appearance(XrmDatabase db, const RrInstance *inst, if (!read_color(db, inst, icname, &value->surface.interlace_color)) value->surface.interlace_color = RrColorNew(inst, 0, 0, 0); + if (read_int(db, hname, &i) && i >= 0) + value->surface.bevel_light_adjust = i; + if (read_int(db, sname, &i) && i >= 0 && i <= 256) + value->surface.bevel_dark_adjust = i; ret = TRUE; } + g_free(sname); + g_free(hname); g_free(icname); g_free(bcname); g_free(ctoname); -- 2.34.1