Commit 80eaf1c4 authored by Christian Hergert's avatar Christian Hergert

completion: remove use of deprecated API

This removes the use of deprecated GdkScreen API in favor of the new
GdkMonitor API. This required bumping to 3.22, which should be enough
in the general case to prepare for 4.x.
parent 1f91fe6a
......@@ -742,21 +742,25 @@ gtk_source_completion_activate_proposal (GtkSourceCompletion *completion)
static void
update_info_position (GtkSourceCompletion *completion)
{
GdkScreen *screen;
GdkDisplay *display;
GdkMonitor *monitor;
GdkWindow *window;
GdkRectangle geom;
gint x, y;
gint width, height;
gint screen_width;
gint info_width;
gtk_window_get_position (GTK_WINDOW (completion->priv->main_window), &x, &y);
gtk_window_get_size (GTK_WINDOW (completion->priv->main_window), &width, &height);
gtk_window_get_size (GTK_WINDOW (completion->priv->info_window), &info_width, NULL);
screen = gtk_window_get_screen (GTK_WINDOW (completion->priv->main_window));
screen_width = gdk_screen_get_width (screen);
display = gtk_widget_get_display (GTK_WIDGET (completion->priv->main_window));
window = gtk_widget_get_window (GTK_WIDGET (completion->priv->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 >= screen_width)
if (x + width + info_width >= geom.width)
{
x -= info_width;
}
......
......@@ -47,18 +47,22 @@ get_max_width (GtkSourceCompletionContainer *container)
{
if (gtk_widget_get_realized (GTK_WIDGET (container)))
{
GdkDisplay *display;
GdkMonitor *monitor;
GtkWidget *toplevel;
GdkWindow *window;
GdkScreen *screen;
GdkRectangle geom;
gint max_width;
gint xorigin;
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (container));
window = gtk_widget_get_window (toplevel);
screen = gdk_window_get_screen (window);
display = gtk_widget_get_display (toplevel);
monitor = gdk_display_get_monitor_at_window (display, window);
gdk_monitor_get_geometry (monitor, &geom);
gdk_window_get_origin (window, &xorigin, NULL);
max_width = gdk_screen_get_width (screen) - xorigin;
max_width = geom.width - xorigin;
return MAX (max_width, UNREALIZED_WIDTH);
}
......
......@@ -461,19 +461,21 @@ move_to_iter (GtkSourceCompletionInfo *window,
GtkTextView *view,
GtkTextIter *iter)
{
GdkScreen *screen;
GdkDisplay *display;
GdkWindow *gdk_window;
GdkMonitor *monitor;
GdkRectangle geom;
gint x, y;
gint w, h;
gint sw, sh;
gint cx, cy;
gint oy;
gint height;
gboolean overlapup;
screen = gtk_window_get_screen (GTK_WINDOW (window));
sw = gdk_screen_get_width (screen);
sh = gdk_screen_get_height (screen);
display = gtk_widget_get_display (GTK_WIDGET (view));
gdk_window = gtk_widget_get_window (GTK_WIDGET (view));
monitor = gdk_display_get_monitor_at_window (display, gdk_window);
gdk_monitor_get_geometry (monitor, &geom);
get_iter_pos (view, iter, &x, &y, &height);
gtk_window_get_size (GTK_WINDOW (window), &w, &h);
......@@ -484,18 +486,18 @@ move_to_iter (GtkSourceCompletionInfo *window,
compensate_for_gravity (window, &cx, &cy, w, h);
/* Push window inside screen */
if (x - cx + w > sw)
if (x - cx + w > geom.width)
{
x = (sw - w) + cx;
x = (geom.width - w) + cx;
}
else if (x - cx < 0)
{
x = cx;
}
if (y - cy + h > sh)
if (y - cy + h > geom.height)
{
y = (sh - h) + cy;
y = (geom.height - h) + cy;
overlapup = TRUE;
}
else if (y - cy < 0)
......
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