Hi all,

I often ssh from the desktop machine (screen size of 2560x1440) into
my laptop (1200x800) and X-Display geany from my laptop back to the
desktop. If I then place the geany window in the bottom right hand
corner of the screen, exit geany and then reopen geany on the laptop,
the geany window ends up off screen.

The included patch checks the window position read from the preferences
file, checks to see if its off either the right hand side or bottom
of the screen and moves it back into a sensible position.

Cheers,
Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
>From 21b8281b559facd2da9f888a960eab6f97ae70e1 Mon Sep 17 00:00:00 2001
From: Erik de Castro Lopo <[email protected]>
Date: Thu, 26 Apr 2012 21:49:39 +1000
Subject: [PATCH] On start up, if the window position read from the
 preferences file is beyond the right hand side or bottom of
 the screen, replace the X and Y positions to move the
 window into the top left hand side of the screen.

---
 src/main.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/main.c b/src/main.c
index 88034e9..ae84fdd 100644
--- a/src/main.c
+++ b/src/main.c
@@ -150,10 +150,29 @@ static GOptionEntry entries[] =
 
 static void setup_window_position(void)
 {
+	GdkScreen *screen;
+
 	/* interprets the saved window geometry */
 	if (!prefs.save_winpos)
 		return;
 
+	/* If we can find the current sceen and the window's X and Y position
+	 * is beyond the right hand side or bottom of the screen, move the
+	 * window back into sensible position in the top left hand side of
+	 * the screen. */
+	screen = gtk_window_get_screen (GTK_WINDOW(main_widgets.window));
+	if (screen)
+	{
+		gint screen_width = gdk_screen_get_width (screen);
+		gint screen_height = gdk_screen_get_height (screen);
+
+		if (ui_prefs.geometry[0] > screen_width || ui_prefs.geometry[1] > screen_height)
+		{
+			ui_prefs.geometry[0] = 100 ;
+			ui_prefs.geometry[1] = 100 ;
+		}
+	}
+
 	if (ui_prefs.geometry[0] != -1 && ui_prefs.geometry[1] != -1)
 		gtk_window_move(GTK_WINDOW(main_widgets.window),
 			ui_prefs.geometry[0], ui_prefs.geometry[1]);
-- 
1.7.10

_______________________________________________
Geany-devel mailing list
[email protected]
https://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel

Reply via email to