Allow moving fullscreen windows between monitors
[openbox.git] / openbox / screen.h
blob6c26ce89849d46a18ebfd5ddea158aa4b0ca6ecc
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 screen.h for the Openbox window manager
4 Copyright (c) 2003-2007 Dana Jansens
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 See the COPYING file for a copy of the GNU General Public License.
19 #ifndef __screen_h
20 #define __screen_h
22 #include "misc.h"
23 #include "geom.h"
25 struct _ObClient;
27 #define DESKTOP_ALL (0xffffffff)
29 typedef enum {
30 SCREEN_SHOW_DESKTOP_NO,
31 SCREEN_SHOW_DESKTOP_UNTIL_WINDOW,
32 SCREEN_SHOW_DESKTOP_UNTIL_TOGGLE
33 } ObScreenShowDestopMode;
35 /*! The number of available desktops */
36 extern guint screen_num_desktops;
37 /*! The number of virtual "xinerama" screens/heads */
38 extern guint screen_num_monitors;
39 /*! The current desktop */
40 extern guint screen_desktop;
41 /*! The desktop which was last visible */
42 extern guint screen_last_desktop;
43 /*! Are we in showing-desktop mode? */
44 extern ObScreenShowDestopMode screen_show_desktop_mode;
45 /*! The support window also used for focus and stacking */
46 extern Window screen_support_win;
47 /*! The last time at which the user changed desktops */
48 extern Time screen_desktop_user_time;
50 typedef struct ObDesktopLayout {
51 ObOrientation orientation;
52 ObCorner start_corner;
53 guint rows;
54 guint columns;
55 } ObDesktopLayout;
56 extern ObDesktopLayout screen_desktop_layout;
58 /*! An array of gchar*'s which are desktop names in UTF-8 format */
59 extern gchar **screen_desktop_names;
61 /*! Take over the screen, set the basic hints on it claming it as ours */
62 gboolean screen_annex(void);
64 /*! Once the screen is ours, set up its initial state */
65 void screen_startup(gboolean reconfig);
66 /*! Free resources */
67 void screen_shutdown(gboolean reconfig);
69 /*! Figure out the new size of the screen and adjust stuff for it */
70 void screen_resize(void);
72 /*! Change the number of available desktops */
73 void screen_set_num_desktops(guint num);
74 /*! Change the current desktop */
75 void screen_set_desktop(guint num, gboolean dofocus);
76 /*! Add a new desktop either at the end or inserted at the current desktop */
77 void screen_add_desktop(gboolean current);
78 /*! Remove a desktop, either at the end or the current desktop */
79 void screen_remove_desktop(gboolean current);
81 guint screen_find_desktop(guint from, ObDirection dir,
82 gboolean wrap, gboolean linear);
84 /*! Show the desktop popup/notification
85 @permanent If TRUE, the popup will stay on the screen until you call
86 screen_hide_desktop_popup(). Otherwise it will hide after a
87 delay.
89 void screen_show_desktop_popup(guint d, gboolean permanent);
90 /*! Hide it */
91 void screen_hide_desktop_popup(void);
93 /*! Shows and focuses the desktop and hides all the client windows, or
94 returns to the normal state, showing client windows.
95 @param If show_only is non-NULL, then only that client is shown (assuming
96 show is FALSE (restoring from show-desktop mode), and the rest are
97 iconified.
99 void screen_show_desktop(ObScreenShowDestopMode show_mode,
100 struct _ObClient *show_only);
102 /*! Returns true if showing desktop mode is enabled. */
103 gboolean screen_showing_desktop();
105 /*! Updates the desktop layout from the root property if available */
106 void screen_update_layout(void);
108 /*! Get desktop names from the root window property */
109 void screen_update_desktop_names(void);
111 /*! Installs or uninstalls a colormap for a client. If client is NULL, then
112 it handles the root colormap. */
113 void screen_install_colormap(struct _ObClient *client, gboolean install);
115 void screen_update_areas(void);
117 const Rect* screen_physical_area_all_monitors(void);
119 /*! Returns a Rect which is owned by the screen code and should not be freed */
120 const Rect* screen_physical_area_monitor(guint head);
122 /*! Returns the monitor which contains the active window, or the one
123 containing the pointer otherwise. */
124 guint screen_monitor_active(void);
126 /*! Returns a Rect which is owned by the screen code and should not be freed */
127 const Rect* screen_physical_area_active(void);
129 /*! Returns the primary monitor, as specified by the config.
130 @fixed If TRUE, then this will always return a fixed monitor, otherwise
131 it may change based on where focus is, or other heuristics.
133 guint screen_monitor_primary(gboolean fixed);
135 /*! Returns physical area for the primary monitor, as specified by the config.
136 @fixed If TRUE, then this will always use a fixed monitor as primary,
137 otherwise it may change based on where focus is, or other heuristics.
138 See screen_monitor_primary().
139 @return A Rect which is owned by the screen code and should not be freed
141 const Rect* screen_physical_area_primary(gboolean fixed);
143 /* doesn't include struts which the search area is already outside of when
144 'search' is not NULL */
145 #define SCREEN_AREA_ALL_MONITORS ((unsigned)-1)
146 #define SCREEN_AREA_ONE_MONITOR ((unsigned)-2)
148 /*! @param head is the number of the head or one of SCREEN_AREA_ALL_MONITORS,
149 SCREEN_AREA_ONE_MONITOR
150 @param search NULL or the whole monitor(s)
151 @return A Rect allocated with g_slice_new()
153 Rect* screen_area(guint desktop, guint head, Rect *search);
155 gboolean screen_physical_area_monitor_contains(guint head, Rect *search);
157 /*! Determines which physical monitor a rectangle is on by calculating the
158 area of the part of the rectable on each monitor. The number of the
159 monitor containing the greatest area of the rectangle is returned.
161 guint screen_find_monitor(const Rect *search);
163 /*! Finds the monitor which contains the point @x, @y */
164 guint screen_find_monitor_point(guint x, guint y);
166 /*! Sets the root cursor. This function decides which cursor to use, but you
167 gotta call it to let it know it should change. */
168 void screen_set_root_cursor(void);
170 /*! Gives back the pointer's position in x and y. Returns TRUE if the pointer
171 is on this screen and FALSE if it is on another screen. */
172 gboolean screen_pointer_pos(gint *x, gint *y);
174 /*! Returns the monitor which contains the pointer device */
175 guint screen_monitor_pointer(void);
177 /*! Compare the desktop for two windows to see if they are considered on the
178 same desktop.
179 Windows that are on "all desktops" are treated like they are only on the
180 current desktop, so they are only in one place at a time.
181 @return TRUE if they are on the same desktop, FALSE otherwise.
183 gboolean screen_compare_desktops(guint a, guint b);
185 /*! Resolve a gravity point into absolute coordinates.
186 * width and height are the size of the object being placed, used for
187 * aligning to right/bottom edges of the area. */
188 void screen_apply_gravity_point(gint *x, gint *y, gint width, gint height,
189 const GravityPoint *position, const Rect *area);
190 #endif