merge r7484-7491 from trunk
authorDana Jansens <danakj@orodu.net>
Sun, 10 Jun 2007 22:00:46 +0000 (22:00 +0000)
committerDana Jansens <danakj@orodu.net>
Sun, 10 Jun 2007 22:00:46 +0000 (22:00 +0000)
openbox/action.c
openbox/client.c
openbox/menu.c
openbox/menu.h
openbox/screen.c
render/gradient.c
render/render.c
render/render.h
render/theme.c

index bf675233d58e40306bf22d321feb5659b6d13262..4c745b2dafc538f9f62305daa2a81d68fe1b7cee 100644 (file)
@@ -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);
 }
 
index dbe203a61f9645de377c672ff51786eeb08c7f5a..15b613524758ccce29a41d793d18eca394f451a1 100644 (file)
@@ -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.. */
 
index 21c00a314131883bd33ee116fe742e24e2423e59..c82eab8033f323899407e48b88575be0022a8bf1 100644 (file)
@@ -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);
index 591dfb65eb67df1b3f0d824c2f79dfaccc08d828..6288d870e9cd22ea66cf9725b5989e6f221e5223 100644 (file)
@@ -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);
 
index a9b045ff99de68c2d890da82c96e4d2db10fe08c..7e2d8645ce3fd3602f7c1d37615f90246cbfec7e 100644 (file)
@@ -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
index ad126513ff07f63f0777b8a4c99f6c265be313ae..ccfd6071d5c3f5c2e08887331ce939013e99c993 100644 (file)
@@ -23,7 +23,7 @@
 #include "color.h"
 #include <glib.h>
 
-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);
 }
index e259f622d90e98fbaab2ac13517785baf33e300a..63c1e7245c53b9ef0591122d30dd1fdd3f7ed781 100644 (file)
@@ -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;
index 7a3e596575bfb579e258afaeafe5c87ee6aa0973..8731c8524771a7fdcfb37c74fa432cdec5b157a7 100644 (file)
@@ -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;
index ae2819482703c0ea755575f9a04082fdc67fea84..709449443697aa5052652d42a52592ee70ed47d7 100644 (file)
@@ -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);