/* panel_helper_position_menu */ static void _panel_helper_position_menu(Panel * panel, GtkMenu * menu, gint * x, gint * y, gboolean * push_in, PanelPosition position) { GtkRequisition req; PanelWindow * window = panel->windows[position]; if(window == NULL) return; #if GTK_CHECK_VERSION(3, 0, 0) gtk_widget_get_preferred_size(GTK_WIDGET(menu), NULL, &req); #else gtk_widget_size_request(GTK_WIDGET(menu), &req); #endif #ifdef DEBUG fprintf(stderr, "DEBUG: %s() width=%d, height=%d\n", __func__, req.width, req.height); #endif if(req.height <= 0) return; switch(position) { case PANEL_POSITION_TOP: *y = panel_window_get_height(window); break; case PANEL_POSITION_BOTTOM: *y = panel->root_height - panel_window_get_height(window) - req.height; break; case PANEL_POSITION_LEFT: *x = panel_window_get_width(window); break; case PANEL_POSITION_RIGHT: *x = panel->root_width - panel_window_get_width(window) - req.width; break; } *push_in = TRUE; }
/* panel_helper_position_menu */ static void _panel_helper_position_menu(Panel * panel, GtkMenu * menu, gint * x, gint * y, gboolean * push_in, PanelPosition position) { GtkRequisition req; gtk_widget_size_request(GTK_WIDGET(menu), &req); #ifdef DEBUG fprintf(stderr, "DEBUG: %s() width=%d, height=%d\n", __func__, req.width, req.height); #endif if(req.height <= 0) return; *x = (req.width < panel->root_width - PANEL_BORDER_WIDTH) ? PANEL_BORDER_WIDTH : 0; if(position == PANEL_POSITION_TOP) *y = panel_window_get_height(panel->top); else if(position == PANEL_POSITION_BOTTOM) *y = panel->root_height - panel_window_get_height(panel->bottom) - req.height; else /* XXX generic */ *y = panel->root_height - req.height; *push_in = TRUE; }