Let the menu placement code know if the position was user specified
[mikachu/openbox.git] / openbox / menuframe.c
index 3252bb3..0c363e7 100644 (file)
@@ -232,10 +232,18 @@ void menu_frame_move(ObMenuFrame *self, gint x, gint y)
     XMoveWindow(obt_display, self->window, self->area.x, self->area.y);
 }
 
-static void menu_frame_place_topmenu(ObMenuFrame *self, gint *x, gint *y)
+static void menu_frame_place_topmenu(ObMenuFrame *self, GravityPoint *pos,
+                                     gint *x, gint *y, gint monitor,
+                                     gboolean user_positioned)
 {
     gint dx, dy;
 
+    screen_apply_gravity_point(x, y, self->area.width, self->area.height,
+                               pos, screen_physical_area_monitor(monitor));
+
+    if (user_positioned)
+        return;
+
     if (config_menu_middle) {
         gint myx;
 
@@ -989,20 +997,26 @@ static gboolean menu_frame_show(ObMenuFrame *self)
     return TRUE;
 }
 
-gboolean menu_frame_show_topmenu(ObMenuFrame *self, gint x, gint y,
-                                 gboolean mouse)
+gboolean menu_frame_show_topmenu(ObMenuFrame *self, GravityPoint pos,
+                                 gint monitor, gboolean mouse,
+                                 gboolean user_positioned)
 {
     gint px, py;
+    gint x, y;
 
     if (menu_frame_is_visible(self))
         return TRUE;
     if (!menu_frame_show(self))
         return FALSE;
 
-    if (self->menu->place_func)
+    if (self->menu->place_func) {
+        x = pos.x.pos;
+        y = pos.y.pos;
         self->menu->place_func(self, &x, &y, mouse, self->menu->data);
-    else
-        menu_frame_place_topmenu(self, &x, &y);
+    } else {
+        menu_frame_place_topmenu(self, &pos, &x, &y, monitor,
+                                 user_positioned);
+    }
 
     menu_frame_move(self, x, y);