]> Dogcows Code - chaz/openbox/blobdiff - openbox/popup.c
super amazing enter event skipping.
[chaz/openbox] / openbox / popup.c
index 5c96f073a90b71d68ac449c0bdf605eff33e8714..86d4fb4dec6bd01549542236fa5cb589a281e705 100644 (file)
@@ -52,7 +52,8 @@ ObPopup *popup_new()
                                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);
+    XSetWindowBorder(ob_display, self->bg,
+                     RrColorPixel(ob_rr_theme->frame_focused_border_color));
 
     XMapWindow(ob_display, self->text);
 
@@ -153,6 +154,9 @@ 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;
+
+    area = screen_physical_area();
 
     RrMargins(self->a_bg, &l, &t, &r, &b);
 
@@ -177,7 +181,6 @@ void popup_delay_show(ObPopup *self, gulong usec, gchar *text)
         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) {
@@ -189,6 +192,9 @@ void popup_delay_show(ObPopup *self, gulong usec, gchar *text)
     } else
         iconw = 0;
 
+    texty = (h - texth - emptyy) / 2 + t + ob_rr_theme->paddingy;
+    icony = (h - iconh - emptyy) / 2 + t + ob_rr_theme->paddingy;
+
     w = textw + emptyx + iconw;
     /* cap it at maxw/minw */
     if (self->maxw) w = MIN(w, self->maxw);
@@ -222,6 +228,9 @@ 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);
@@ -256,11 +265,15 @@ void popup_delay_show(ObPopup *self, gulong usec, gchar *text)
 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 +328,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;
@@ -324,8 +338,9 @@ void icon_popup_delay_show(ObIconPopup *self, gulong usec,
 
 void icon_popup_icon_size_multiplier(ObIconPopup *self, guint wm, guint hm)
 {
-    if (wm != 0) self->popup->iconwm = wm;
-    if (hm != 0) self->popup->iconhm = 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,
@@ -484,7 +499,8 @@ 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->frame_focused_border_color);
             self->wins[i] = XCreateWindow(ob_display, self->popup->bg,
                                           0, 0, 1, 1, ob_rr_theme->fbwidth,
                                           RrDepth(ob_rr_inst), InputOutput,
@@ -501,6 +517,7 @@ void pager_popup_delay_show(ObPagerPopup *self, gulong usec,
 
 void pager_popup_icon_size_multiplier(ObPagerPopup *self, guint wm, guint hm)
 {
-    if (wm != 0) self->popup->iconwm = wm;
-    if (hm != 0) self->popup->iconhm = hm;
+    /* cap them at 1 */
+    self->popup->iconwm = MAX(1, wm);
+    self->popup->iconhm = MAX(1, hm);
 }
This page took 0.024757 seconds and 4 git commands to generate.