+ menu_frame_visible = g_list_prepend(menu_frame_visible, self);
+
+ if (self->menu->show_func)
+ self->menu->show_func(self, self->menu->data);
+
+ return TRUE;
+}
+
+gboolean menu_frame_show_topmenu(ObMenuFrame *self, gint x, gint y,
+ gboolean mouse)
+{
+ gint px, py;
+ guint i;
+
+ if (menu_frame_is_visible(self))
+ return TRUE;
+ if (!menu_frame_show(self))
+ return FALSE;
+
+ /* find the monitor the menu is on */
+ for (i = 0; i < screen_num_monitors; ++i) {
+ Rect *a = screen_physical_area_monitor(i);
+ gboolean contains = RECT_CONTAINS(*a, x, y);
+ g_free(a);
+ if (contains) {
+ self->monitor = i;
+ break;
+ }
+ }
+
+ if (self->menu->place_func)
+ self->menu->place_func(self, &x, &y, mouse, self->menu->data);
+ else
+ menu_frame_place_topmenu(self, &x, &y);
+
+ menu_frame_move(self, x, y);
+
+ XMapWindow(obt_display, self->window);
+
+ if (screen_pointer_pos(&px, &py)) {
+ ObMenuEntryFrame *e = menu_entry_frame_under(px, py);
+ if (e && e->frame == self)
+ e->ignore_enters++;
+ }
+
+ return TRUE;
+}
+
+gboolean menu_frame_show_submenu(ObMenuFrame *self, ObMenuFrame *parent,
+ ObMenuEntryFrame *parent_entry)
+{
+ gint x, y, dx, dy;
+ gint px, py;
+
+ if (menu_frame_is_visible(self))
+ return TRUE;
+
+ self->monitor = parent->monitor;
+ self->parent = parent;
+ self->parent_entry = parent_entry;
+
+ /* set up parent's child to be us */
+ if (parent->child)
+ menu_frame_hide(parent->child);
+ parent->child = self;
+
+ if (!menu_frame_show(self))
+ return FALSE;
+
+ menu_frame_place_submenu(self, &x, &y);
+ menu_frame_move_on_screen(self, x, y, &dx, &dy);
+
+ if (dx != 0) {
+ /*try the other side */
+ self->direction_right = !self->direction_right;
+ menu_frame_place_submenu(self, &x, &y);
+ menu_frame_move_on_screen(self, x, y, &dx, &dy);
+ }
+ menu_frame_move(self, x + dx, y + dy);
+
+ XMapWindow(obt_display, self->window);
+
+ if (screen_pointer_pos(&px, &py)) {
+ ObMenuEntryFrame *e = menu_entry_frame_under(px, py);
+ if (e && e->frame == self)
+ e->ignore_enters++;
+ }