mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-05-08 05:02:09 -05:00
Handle deprecation of gdk_screen_{width,height}
GTK+ 3.22 deprecates gdk_screen_{width,height} on the grounds that the "screen" here actually refers to a virtual screen that may span multiple monitors, and applications should generally be considering the width and height of individual monitors. It's not entirely clear to me how this fits with X geometry specifications, but I've gone with trying to get hold of the geometry of the monitor that the window in question is on.
This commit is contained in:
parent
8833634f47
commit
921afd3716
@ -4302,6 +4302,30 @@ static void start_backend(struct gui_data *inst)
|
|||||||
gtk_widget_set_sensitive(inst->restartitem, FALSE);
|
gtk_widget_set_sensitive(inst->restartitem, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void get_monitor_geometry(GtkWidget *widget, GdkRectangle *geometry)
|
||||||
|
{
|
||||||
|
#if GTK_CHECK_VERSION(3,4,0)
|
||||||
|
GdkDisplay *display = gtk_widget_get_display(widget);
|
||||||
|
GdkWindow *gdkwindow = gtk_widget_get_window(widget);
|
||||||
|
# if GTK_CHECK_VERSION(3,22,0)
|
||||||
|
GdkMonitor *monitor;
|
||||||
|
if (gdkwindow)
|
||||||
|
monitor = gdk_display_get_monitor_at_window(display, gdkwindow);
|
||||||
|
else
|
||||||
|
monitor = gdk_display_get_monitor(display, 0);
|
||||||
|
gdk_monitor_get_geometry(monitor, geometry);
|
||||||
|
# else
|
||||||
|
GdkScreen *screen = gdk_display_get_default_screen(display);
|
||||||
|
gint monitor_num = gdk_screen_get_monitor_at_window(screen, gdkwindow);
|
||||||
|
gdk_screen_get_monitor_geometry(screen, monitor_num, geometry);
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
geometry->x = geometry->y = 0;
|
||||||
|
geometry->width = gdk_screen_width();
|
||||||
|
geometry->height = gdk_screen_height();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
struct gui_data *new_session_window(Conf *conf, const char *geometry_string)
|
struct gui_data *new_session_window(Conf *conf, const char *geometry_string)
|
||||||
{
|
{
|
||||||
struct gui_data *inst;
|
struct gui_data *inst;
|
||||||
@ -4436,9 +4460,11 @@ struct gui_data *new_session_window(Conf *conf, const char *geometry_string)
|
|||||||
};
|
};
|
||||||
int x = inst->xpos, y = inst->ypos;
|
int x = inst->xpos, y = inst->ypos;
|
||||||
int wp, hp;
|
int wp, hp;
|
||||||
|
GdkRectangle monitor_geometry;
|
||||||
compute_whole_window_size(inst, inst->width, inst->height, &wp, &hp);
|
compute_whole_window_size(inst, inst->width, inst->height, &wp, &hp);
|
||||||
if (inst->gravity & 1) x += (gdk_screen_width() - wp);
|
get_monitor_geometry(GTK_WIDGET(inst->window), &monitor_geometry);
|
||||||
if (inst->gravity & 2) y += (gdk_screen_height() - hp);
|
if (inst->gravity & 1) x += (monitor_geometry.width - wp);
|
||||||
|
if (inst->gravity & 2) y += (monitor_geometry.height - hp);
|
||||||
gtk_window_set_gravity(GTK_WINDOW(inst->window),
|
gtk_window_set_gravity(GTK_WINDOW(inst->window),
|
||||||
gravities[inst->gravity & 3]);
|
gravities[inst->gravity & 3]);
|
||||||
gtk_window_move(GTK_WINDOW(inst->window), x, y);
|
gtk_window_move(GTK_WINDOW(inst->window), x, y);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user