]> Dogcows Code - chaz/openbox/blobdiff - openbox/popup.c
xinerama support like crazy for struts and everything else too. this probably crashes...
[chaz/openbox] / openbox / popup.c
index bf682aafb6c7a659ddc29b4c3b4336eb3e156ada..f5072748734953f70dff767858596bab3ea6f232 100644 (file)
@@ -39,6 +39,7 @@ ObPopup *popup_new()
     self->x = self->y = self->textw = self->h = 0;
     self->a_bg = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg);
     self->a_text = RrAppearanceCopy(ob_rr_theme->osd_hilite_label);
+    self->iconwm = self->iconhm = 1;
 
     attrib.override_redirect = True;
     self->bg = XCreateWindow(ob_display, RootWindow(ob_display, ob_screen),
@@ -50,8 +51,9 @@ ObPopup *popup_new()
                                0, 0, 1, 1, 0, RrDepth(ob_rr_inst),
                                InputOutput, RrVisual(ob_rr_inst), 0, NULL);
 
-    XSetWindowBorderWidth(ob_display, self->bg, ob_rr_theme->fbwidth);
-    XSetWindowBorder(ob_display, self->bg, ob_rr_theme->frame_b_color->pixel);
+    XSetWindowBorderWidth(ob_display, self->bg, ob_rr_theme->obwidth);
+    XSetWindowBorder(ob_display, self->bg,
+                     RrColorPixel(ob_rr_theme->osd_border_color));
 
     XMapWindow(ob_display, self->text);
 
@@ -152,8 +154,18 @@ void popup_delay_show(ObPopup *self, gulong usec, gchar *text)
     gint emptyx, emptyy; /* empty space between elements */
     gint textx, texty, textw, texth;
     gint iconx, icony, iconw, iconh;
+    Rect *area, mon;
 
-    RrMargins(self->a_bg, &l, &t, &r, &b);
+    RECT_SET(mon, self->x, self->y, 1, 1);
+    area = screen_physical_area_monitor(screen_find_monitor(&mon));
+
+    /* when there is no icon and the text is not parent relative, then 
+       fill the whole dialog with the text appearance, don't use the bg at all
+    */
+    if (self->hasicon || self->a_text->surface.grad == RR_SURFACE_PARENTREL)
+        RrMargins(self->a_bg, &l, &t, &r, &b);
+    else
+        l = t = r = b = 0;
 
     /* set up the textures */
     self->a_text->texture[0].data.text.string = text;
@@ -168,27 +180,39 @@ void popup_delay_show(ObPopup *self, gulong usec, gchar *text)
 
     /* get the height, which is also used for the icon width */
     emptyy = t + b + ob_rr_theme->paddingy * 2;
-    if (self->h) {
-        h = self->h;
-        texth = h - emptyy;
-    } else
-        h = texth + emptyy;
+    if (self->h)
+        texth = self->h - emptyy;
+    h = texth * self->iconhm + emptyy;
 
     if (self->textw)
         textw = self->textw;
 
     iconx = textx = l + ob_rr_theme->paddingx;
-    icony = texty = t + ob_rr_theme->paddingy;
 
     emptyx = l + r + ob_rr_theme->paddingx * 2;
     if (self->hasicon) {
-        iconw = iconh = texth;
+        iconw = texth * self->iconwm;
+        iconh = texth * self->iconhm;
         textx += iconw + ob_rr_theme->paddingx;
         if (textw)
             emptyx += ob_rr_theme->paddingx; /* between the icon and text */
     } else
         iconw = 0;
 
+    texty = (h - texth - emptyy) / 2 + t + ob_rr_theme->paddingy;
+    icony = (h - iconh - emptyy) / 2 + t + ob_rr_theme->paddingy;
+
+    /* when there is no icon, then fill the whole dialog with the text
+       appearance
+    */
+    if (!self->hasicon)
+    {
+        textx = texty = 0;
+        texth += emptyy;
+        textw += emptyx;
+        emptyx = emptyy = 0;
+    }
+
     w = textw + emptyx + iconw;
     /* cap it at maxw/minw */
     if (self->maxw) w = MIN(w, self->maxw);
@@ -222,9 +246,16 @@ void popup_delay_show(ObPopup *self, gulong usec, gchar *text)
         break;
     }
 
+    x=MAX(MIN(x, area->width-w),0);
+    y=MAX(MIN(y, area->height-h),0);
+    
     /* set the windows/appearances up */
     XMoveResizeWindow(ob_display, self->bg, x, y, w, h);
-    RrPaint(self->a_bg, self->bg, w, h);
+    /* when there is no icon and the text is not parent relative, then 
+       fill the whole dialog with the text appearance, don't use the bg at all
+    */
+    if (self->hasicon || self->a_text->surface.grad == RR_SURFACE_PARENTREL)
+        RrPaint(self->a_bg, self->bg, w, h);
 
     if (textw) {
         self->a_text->surface.parent = self->a_bg;
@@ -251,16 +282,22 @@ void popup_delay_show(ObPopup *self, gulong usec, gchar *text)
             popup_show_timeout(self);
         }
     }
+
+    g_free(area);
 }
 
 void popup_hide(ObPopup *self)
 {
     if (self->mapped) {
+        gulong ignore_start;
+
+        /* kill enter events cause by this unmapping */
+        ignore_start = event_start_ignore_all_enters();
+
         XUnmapWindow(ob_display, self->bg);
         self->mapped = FALSE;
 
-        /* kill enter events cause by this unmapping */
-        event_ignore_queued_enters();
+        event_end_ignore_all_enters(ignore_start);
     } else if (self->delay_mapped) {
         ob_main_loop_timeout_remove(ob_main_loop, popup_show_timeout);
         self->delay_mapped = FALSE;
@@ -315,6 +352,7 @@ void icon_popup_delay_show(ObIconPopup *self, gulong usec,
         self->a_icon->texture[0].type = RR_TEXTURE_RGBA;
         self->a_icon->texture[0].data.rgba.width = icon->width;
         self->a_icon->texture[0].data.rgba.height = icon->height;
+        self->a_icon->texture[0].data.rgba.alpha = 0xff;
         self->a_icon->texture[0].data.rgba.data = icon->data;
     } else
         self->a_icon->texture[0].type = RR_TEXTURE_NONE;
@@ -322,6 +360,13 @@ void icon_popup_delay_show(ObIconPopup *self, gulong usec,
     popup_delay_show(self->popup, usec, text);
 }
 
+void icon_popup_icon_size_multiplier(ObIconPopup *self, guint wm, guint hm)
+{
+    /* cap them at 1 */
+    self->popup->iconwm = MAX(1, wm);
+    self->popup->iconhm = MAX(1, hm);
+}
+
 static void pager_popup_draw_icon(gint px, gint py, gint w, gint h,
                                   gpointer data)
 {
@@ -334,7 +379,7 @@ static void pager_popup_draw_icon(gint px, gint py, gint w, gint h,
     gint eachw, eachh;
     const guint cols = screen_desktop_layout.columns;
     const guint rows = screen_desktop_layout.rows;
-    const gint linewidth = ob_rr_theme->fbwidth;
+    const gint linewidth = ob_rr_theme->obwidth;
 
     eachw = (w - ((cols + 1) * linewidth)) / cols;
     eachh = (h - ((rows + 1) * linewidth)) / rows;
@@ -478,9 +523,10 @@ void pager_popup_delay_show(ObPagerPopup *self, gulong usec,
         for (i = self->desks; i < screen_num_desktops; ++i) {
             XSetWindowAttributes attr;
 
-            attr.border_pixel = RrColorPixel(ob_rr_theme->frame_b_color);
+            attr.border_pixel = 
+                RrColorPixel(ob_rr_theme->osd_border_color);
             self->wins[i] = XCreateWindow(ob_display, self->popup->bg,
-                                          0, 0, 1, 1, ob_rr_theme->fbwidth,
+                                          0, 0, 1, 1, ob_rr_theme->obwidth,
                                           RrDepth(ob_rr_inst), InputOutput,
                                           RrVisual(ob_rr_inst), CWBorderPixel,
                                           &attr);
@@ -492,3 +538,10 @@ void pager_popup_delay_show(ObPagerPopup *self, gulong usec,
 
     popup_delay_show(self->popup, usec, text);
 }
+
+void pager_popup_icon_size_multiplier(ObPagerPopup *self, guint wm, guint hm)
+{
+    /* cap them at 1 */
+    self->popup->iconwm = MAX(1, wm);
+    self->popup->iconhm = MAX(1, hm);
+}
This page took 0.025632 seconds and 4 git commands to generate.