Do not create windows bigger than the monitor size
This commit is contained in:
parent
fb1e3ec7fe
commit
fef4563122
15
src/view.c
15
src/view.c
@ -189,8 +189,8 @@ static GtkWidget * _new_image(View * view, char const * path)
|
|||||||
int pw;
|
int pw;
|
||||||
int ph;
|
int ph;
|
||||||
GdkScreen * screen;
|
GdkScreen * screen;
|
||||||
int sw;
|
gint monitor;
|
||||||
int sh;
|
GdkRectangle rect;
|
||||||
|
|
||||||
window = gtk_scrolled_window_new(NULL, NULL);
|
window = gtk_scrolled_window_new(NULL, NULL);
|
||||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(window),
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(window),
|
||||||
@ -206,10 +206,15 @@ static GtkWidget * _new_image(View * view, char const * path)
|
|||||||
widget);
|
widget);
|
||||||
pw = gdk_pixbuf_get_width(pixbuf) + 4;
|
pw = gdk_pixbuf_get_width(pixbuf) + 4;
|
||||||
ph = gdk_pixbuf_get_height(pixbuf) + 4;
|
ph = gdk_pixbuf_get_height(pixbuf) + 4;
|
||||||
|
/* get the current monitor size */
|
||||||
screen = gdk_screen_get_default();
|
screen = gdk_screen_get_default();
|
||||||
sw = gdk_screen_get_width(screen);
|
gtk_widget_realize(view->window);
|
||||||
sh = gdk_screen_get_height(screen);
|
monitor = gdk_screen_get_monitor_at_window(screen,
|
||||||
gtk_widget_set_size_request(window, min(pw, sw), min(ph, sh));
|
gtk_widget_get_window(view->window));
|
||||||
|
gdk_screen_get_monitor_geometry(screen, monitor, &rect);
|
||||||
|
/* set an upper bound to the size of the window */
|
||||||
|
gtk_widget_set_size_request(window, min(pw, rect.width), min(ph,
|
||||||
|
rect.height));
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user