Commit 3004bc34 authored by Artyom Zorin's avatar Artyom Zorin Committed by David Keogh
Browse files

Anchor group menu to center of app icon

parent 091441e5
Pipeline #12315 passed with stages
in 2 minutes and 20 seconds
......@@ -98,7 +98,7 @@ void GroupMenu::popup()
});
xfce_panel_plugin_position_widget(Plugin::mXfPlugin, mWindow, mGroup->mButton, &wx, &wy);
gtk_window_move(GTK_WINDOW(mWindow), wx, wy);
updatePosition(wx, wy);
gtk_widget_show(mWindow);
}
}
......@@ -113,6 +113,42 @@ void GroupMenu::updateOrientation()
gtk_orientable_set_orientation(GTK_ORIENTABLE(mBox), GTK_ORIENTATION_VERTICAL);
}
void GroupMenu::updatePosition(gint wx, gint wy)
{
GdkScreen *screen;
GdkRectangle geometry;
GdkDisplay *display;
GdkMonitor *monitor;
screen = gtk_widget_get_screen(mGroup->mButton);
display = gdk_screen_get_display(screen);
monitor = gdk_display_get_monitor_at_window(display, gtk_widget_get_window(mGroup->mButton));
gdk_monitor_get_geometry(monitor, &geometry);
gint window_width, window_height;
gtk_window_get_size(GTK_WINDOW(mWindow), &window_width, &window_height);
gint button_width = gtk_widget_get_allocated_width(mGroup->mButton);
gint button_height = gtk_widget_get_allocated_height(mGroup->mButton);
XfcePanelPluginMode panelMode = xfce_panel_plugin_get_mode(Plugin::mXfPlugin);
if (panelMode == XFCE_PANEL_PLUGIN_MODE_HORIZONTAL)
{
if (wx != geometry.x + geometry.width - window_width) {
wx -= (window_width/2) - (button_width/2);
wx = wx < geometry.x ? geometry.x : wx;
}
} else {
if (wy != geometry.y + geometry.height - window_height) {
wy -= (window_height/2) - (button_height/2);
wy = wy < geometry.y ? geometry.y : wy;
}
}
gtk_window_move(GTK_WINDOW(mWindow), wx, wy);
}
void GroupMenu::hide()
{
mVisible = false;
......
......@@ -25,6 +25,7 @@ class GroupMenu
void popup();
void updateOrientation();
void updatePosition(gint wx, gint wy);
void hide();
uint getPointerDistance();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment