]> Dogcows Code - chaz/openbox/blobdiff - src/Basemenu.cc
fixed menu placement on menus with very small windows
[chaz/openbox] / src / Basemenu.cc
index 3556d00a9034bf30fecdf7c7176296f5bd69d197..322576c598d70270d135a53dea4a5107456b80f4 100644 (file)
@@ -619,8 +619,26 @@ void Basemenu::drawItem(int index, bool highlight, bool clear,
       XFillRectangle(display, menu.frame, hipen.gc(),
                      hilite_x, hilite_y, hilite_w, hilite_h);
   }
-  
+
   if (dooppsel && item->isSelected()) {
+#ifdef    BITMAPBUTTONS
+    if ( style->tick_image.mask != None) {
+      XSetClipOrigin(blackbox->getXDisplay(), pen.gc(),
+                     oppsel_x, item_y + menu.item_h/2 - style->tick_image.h/2);
+      XSetClipMask(blackbox->getXDisplay(), pen.gc(),
+                   style->tick_image.mask);
+
+      XFillRectangle(blackbox->getXDisplay(), menu.frame, pen.gc(),
+                     oppsel_x, item_y + menu.item_h/2 - style->tick_image.h/2,
+                     style->tick_image.w,
+                     style->tick_image.h);
+
+      XSetClipMask(blackbox->getXDisplay(), pen.gc(), None);
+      
+      XSetClipOrigin(blackbox->getXDisplay(), pen.gc(),
+                     0, 0);
+    } else {
+#endif // BITMAPBUTTONS
       XPoint pts[6];
 
       pts[0].x = oppsel_x + 0;
@@ -644,6 +662,9 @@ void Basemenu::drawItem(int index, bool highlight, bool clear,
 
       XFillPolygon(display, menu.frame, pen.gc(), pts, 6, Nonconvex,
                    CoordModePrevious);
+#ifdef    BITMAPBUTTONS
+    }
+#endif // BITMAPBUTTONS
   }
 
   if (dotext && text) {
@@ -655,53 +676,73 @@ void Basemenu::drawItem(int index, bool highlight, bool clear,
   }
 
   if (dosel && item->submenu()) {
-    const int bullet_size = 3;
-
-    switch (screen->getMenuStyle()->bullet) {
-    case Square:
-      XDrawRectangle(display, menu.frame, pen.gc(), sel_x, sel_y,
-                     bullet_size * 2, bullet_size * 2);
-      break;
-
-    case Triangle:
-      XPoint tri[3];
+#ifdef    BITMAPBUTTONS
+    if ( style->bullet_image.mask != None) {
+      XSetClipOrigin(blackbox->getXDisplay(), pen.gc(),
+                     sel_x, item_y + menu.item_h/2 - style->bullet_image.h/2);
+      XSetClipMask(blackbox->getXDisplay(), pen.gc(),
+                   style->bullet_image.mask);
+
+      XFillRectangle(blackbox->getXDisplay(), menu.frame, pen.gc(),
+                     sel_x, item_y + menu.item_h/2 - style->bullet_image.h/2,
+                     style->bullet_image.w, style->bullet_image.h);
+
+      XSetClipMask(blackbox->getXDisplay(), pen.gc(), None);
+      
+      XSetClipOrigin(blackbox->getXDisplay(), pen.gc(),
+                     0, 0);
+    } else {
+#endif // BITMAPBUTTONS
+      const int bullet_size = 3;
+
+      switch (screen->getMenuStyle()->bullet) {
+      case Square:
+        XDrawRectangle(display, menu.frame, pen.gc(), sel_x, sel_y,
+                       bullet_size * 2, bullet_size * 2);
+        break;
+
+      case Triangle:
+        XPoint tri[3];
+
+        if (screen->getMenuStyle()->bullet_pos == Right) {
+          tri[0].x = sel_x + quarter_w - bullet_size;
+          tri[0].y = sel_y + quarter_w - bullet_size;
+          tri[1].x = 2 * bullet_size;
+          tri[1].y = bullet_size;
+          tri[2].x = -(2 * bullet_size);
+          tri[2].y = bullet_size;
+        } else {
+          tri[0].x = sel_x + quarter_w - bullet_size;
+          tri[0].y = item_y + half_w;
+          tri[1].x = 2 * bullet_size;
+          tri[1].y = bullet_size;
+          tri[2].x = 0;
+          tri[2].y = -(2 * bullet_size);
+        }
 
-      if (screen->getMenuStyle()->bullet_pos == Right) {
-        tri[0].x = sel_x + quarter_w - bullet_size;
-        tri[0].y = sel_y + quarter_w - bullet_size;
-        tri[1].x = 2 * bullet_size;
-        tri[1].y = bullet_size;
-        tri[2].x = -(2 * bullet_size);
-        tri[2].y = bullet_size;
-      } else {
-        tri[0].x = sel_x + quarter_w - bullet_size;
-        tri[0].y = item_y + half_w;
-        tri[1].x = 2 * bullet_size;
-        tri[1].y = bullet_size;
-        tri[2].x = 0;
-        tri[2].y = -(2 * bullet_size);
+        XFillPolygon(display, menu.frame, pen.gc(), tri, 3, Convex,
+                     CoordModePrevious);
+        break;
+
+      case Diamond:
+        XPoint dia[4];
+
+        dia[0].x = sel_x + quarter_w - bullet_size;
+        dia[0].y = item_y + half_w;
+        dia[1].x = bullet_size;
+        dia[1].y = -bullet_size;
+        dia[2].x = bullet_size;
+        dia[2].y = bullet_size;
+        dia[3].x = -bullet_size;
+        dia[3].y = bullet_size;
+
+        XFillPolygon(display, menu.frame, pen.gc(), dia, 4, Convex,
+                     CoordModePrevious);
+        break;
       }
-
-      XFillPolygon(display, menu.frame, pen.gc(), tri, 3, Convex,
-                   CoordModePrevious);
-      break;
-
-    case Diamond:
-      XPoint dia[4];
-
-      dia[0].x = sel_x + quarter_w - bullet_size;
-      dia[0].y = item_y + half_w;
-      dia[1].x = bullet_size;
-      dia[1].y = -bullet_size;
-      dia[2].x = bullet_size;
-      dia[2].y = bullet_size;
-      dia[3].x = -bullet_size;
-      dia[3].y = bullet_size;
-
-      XFillPolygon(display, menu.frame, pen.gc(), dia, 4, Convex,
-                   CoordModePrevious);
-      break;
+#ifdef    BITMAPBUTTONS
     }
+#endif // BITMAPBUTTONS
   }
 }
 
This page took 0.027725 seconds and 4 git commands to generate.