Commit 470d1683 authored by Christian Hergert's avatar Christian Hergert

completion: use gdk_surface_move_to_rect()

This avoids manual control over placement and instead relies on the
window manager (or GDK on X11) to place the window in an appropriate
place using relative gravity of windows.
parent ce8cf234
......@@ -738,34 +738,34 @@ gtk_source_completion_activate_proposal (GtkSourceCompletion *completion)
static void
update_info_position (GtkSourceCompletion *completion)
GdkDisplay *display;
GdkMonitor *monitor;
GdkWindow *window;
GdkSurface *main_surface;
GdkSurface *info_surface;
GdkRectangle geom;
gint x, y;
gint width, height;
gint info_width;
gtk_window_get_position (GTK_WINDOW (completion->main_window), &x, &y);
gtk_window_get_size (GTK_WINDOW (completion->main_window), &width, &height);
gtk_window_get_size (GTK_WINDOW (completion->info_window), &info_width, NULL);
display = gtk_widget_get_display (GTK_WIDGET (completion->main_window));
window = gtk_widget_get_window (GTK_WIDGET (completion->main_window));
monitor = gdk_display_get_monitor_at_window (display, window);
gdk_monitor_get_geometry (monitor, &geom);
/* Determine on which side to place it */
if (x + width + info_width >= geom.width)
if (!GTK_IS_NATIVE (completion->main_window) ||
!GTK_IS_NATIVE (completion->info_window))
x -= info_width;
main_surface = gtk_native_get_surface (GTK_NATIVE (completion->main_window));
info_surface = gtk_native_get_surface (GTK_NATIVE (completion->info_window));
if (main_surface == NULL || info_surface == NULL)
x += width;
gtk_window_move (GTK_WINDOW (completion->info_window), x, y);
gdk_surface_get_position (main_surface, &geom.x, &geom.y);
geom.width = gdk_surface_get_width (main_surface);
geom.height = gdk_surface_get_height (main_surface);
gdk_surface_move_to_rect (info_surface,
0, 0);
static GtkSourceCompletionProvider *
......@@ -1261,15 +1261,6 @@ selection_changed_cb (GtkTreeSelection *selection,
static gboolean
gtk_source_completion_configure_event (GtkWidget *widget,
GdkEventConfigure *event,
GtkSourceCompletion *completion)
update_info_position (completion);
return FALSE;
static gboolean
hide_completion_cb (GtkSourceCompletion *completion)
......@@ -2182,11 +2173,6 @@ init_main_window (GtkSourceCompletion *completion,
gtk_window_set_attached_to (GTK_WINDOW (completion->main_window),
GTK_WIDGET (completion->view));
g_signal_connect (completion->main_window,
G_CALLBACK (gtk_source_completion_configure_event),
g_signal_connect_swapped (completion->main_window,
G_CALLBACK (update_window_position),
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