2 Copyright (C) 2001-2006, William Joseph.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include "debugging/debugging.h"
26 #include "gtkutil/window.h"
27 #include "preferences.h"
30 multimon_globals_t g_multimon_globals;
32 LatchedBool g_Multimon_enableSysMenuPopups(false, "Floating windows sysmenu icons");
34 void MultiMonitor_constructPreferences(PreferencesPage& page)
36 GtkWidget* primary_monitor = page.appendCheckBox("Multi Monitor", "Start on Primary Monitor", g_multimon_globals.m_bStartOnPrimMon);
37 GtkWidget* popup = page.appendCheckBox(
38 "", "Disable system menu on popup windows",
39 LatchedBoolImportCaller(g_Multimon_enableSysMenuPopups),
40 BoolExportCaller(g_Multimon_enableSysMenuPopups.m_latched)
42 Widget_connectToggleDependency(popup, primary_monitor);
45 #include "preferencesystem.h"
48 #include <gdk/gdkdisplay.h>
52 GdkRectangle primaryMonitor;
55 void PositionWindowOnPrimaryScreen(WindowPosition& position)
57 if( position.w >= primaryMonitor.width - 12 )
59 position.w = primaryMonitor.width - 12;
61 if( position.h >= primaryMonitor.height - 24 )
63 position.h = primaryMonitor.height - 48;
65 if( position.x <= primaryMonitor.x || position.x + position.w >= (primaryMonitor.x + primaryMonitor.width) - 12 )
67 position.x = primaryMonitor.x + 6;
69 if( position.y <= primaryMonitor.y || position.y + position.h >= (primaryMonitor.y + primaryMonitor.height) - 48 )
71 position.y = primaryMonitor.y + 24;
75 void MultiMon_Construct()
77 // detect multiple monitors
79 GdkScreen* screen = gdk_display_get_default_screen(gdk_display_get_default());
80 gint m = gdk_screen_get_n_monitors(screen);
81 globalOutputStream() << "default screen has " << m << " monitors\n";
82 for(int j = 0; j != m; ++j)
85 gdk_screen_get_monitor_geometry(screen, j, &geom);
86 globalOutputStream() << "monitor " << j << " geometry: " << geom.x << ", " << geom.y << ", " << geom.width << ", " << geom.height << "\n";
89 // I am making the assumption that monitor 0 is always the primary monitor on win32. Tested on WinXP with gtk+-2.4.
90 primaryMonitor = geom;
96 g_multimon_globals.m_bStartOnPrimMon = true;
99 GlobalPreferenceSystem().registerPreference("StartOnPrimMon", BoolImportStringCaller(g_multimon_globals.m_bStartOnPrimMon), BoolExportStringCaller(g_multimon_globals.m_bStartOnPrimMon));
100 GlobalPreferenceSystem().registerPreference("NoSysMenuPopups", BoolImportStringCaller(g_Multimon_enableSysMenuPopups.m_latched), BoolExportStringCaller(g_Multimon_enableSysMenuPopups.m_latched));
102 g_Multimon_enableSysMenuPopups.useLatched();
104 PreferencesDialog_addInterfacePreferences(FreeCaller1<PreferencesPage&, MultiMonitor_constructPreferences>());
106 void MultiMon_Destroy()