1 /* -*-c-*- */
2 #ifndef FVWMLIB_FSCRREN_H
3 #define FVWMLIB_FSCRREN_H
4 
5 #include "config.h"
6 #include "fvwm_x11.h"
7 #include "fvwmrect.h"
8 
9 #include <stdbool.h>
10 
11 typedef struct
12 {
13 	XEvent *mouse_ev;
14 	const char *name;
15 	struct
16 	{
17 		int x;
18 		int y;
19 	} xypos;
20 } fscreen_scr_arg;
21 
22 typedef enum
23 {
24 	FSCREEN_GLOBAL  = -1,
25 	FSCREEN_CURRENT = -2,
26 	FSCREEN_PRIMARY = -3,
27 	FSCREEN_XYPOS   = -4,
28 	FSCREEN_BY_NAME = -5
29 } fscreen_scr_t;
30 
31 typedef struct DesktopsInfo
32 {
33 	int desk;
34 	char *name;
35 
36 	struct
37 	{
38 		int x;
39 		int y;
40 		int width;
41 		int height;
42 	} ewmh_working_area;
43 	struct
44 	{
45 		int x;
46 		int y;
47 		int width;
48 		int height;
49 	} ewmh_dyn_working_area;
50 
51 	struct DesktopsInfo *next;
52 } DesktopsInfo;
53 
54 typedef struct
55 {
56 	Window win;
57 	int isMapped;
58 	/* command which is executed when the pan frame is entered */
59 	char *command;
60 	/* command which is executed when the pan frame is left*/
61 	char *command_leave;
62 } PanFrame;
63 
64 enum monitor_tracking
65 {
66 	MONITOR_TRACKING_G = 1,
67 	MONITOR_TRACKING_M,
68 	MONITOR_TRACKING_S,
69 };
70 
71 extern enum monitor_tracking monitor_mode;
72 extern bool is_tracking_shared;
73 
74 struct screen_info {
75 	const char		*name;
76 	int			 x, y, w, h;
77 	RROutput		 rr_output;
78 
79 	TAILQ_ENTRY(screen_info) entry;
80 };
81 TAILQ_HEAD(screen_infos, screen_info);
82 
83 extern struct screen_infos	 screen_info_q;
84 
85 struct screen_info	*screen_info_new(void);
86 struct screen_info	*screen_info_by_name(const char *);
87 
88 #define MONITOR_NEW 0x1
89 #define MONITOR_DISABLED 0x2
90 #define MONITOR_ENABLED 0x4
91 #define MONITOR_PRIMARY 0x8
92 #define MONITOR_CHANGED 0x10
93 #define MONITOR_ALL (MONITOR_DISABLED|MONITOR_ENABLED|MONITOR_CHANGED)
94 
95 #define MONITOR_OUTSIDE_EDGE 0
96 #define MONITOR_INSIDE_EDGE 1
97 
98 struct monitor {
99 	struct screen_info	*si;
100 	int			 flags;
101 	int			 emit;
102 	int			 dx, dy;
103 
104 	/* info for some desktops; the first entries should be generic info
105          * correct for any desktop not in the list
106          */
107 	DesktopsInfo    *Desktops;
108 
109         /* Information about EWMH. */
110         struct {
111                 unsigned NumberOfDesktops;
112                 unsigned MaxDesktops;
113                 unsigned CurrentNumberOfDesktops;
114                 Bool NeedsToCheckDesk;
115 
116                 struct {
117                         int left;
118                         int right;
119                         int top;
120                         int bottom;
121                 } BaseStrut;
122 
123         } ewmhc;
124 
125 	struct {
126 		bool top;
127 		bool bottom;
128 		bool left;
129 		bool right;
130 	} edge;
131 
132         struct {
133                 int VxMax;
134                 int VyMax;
135                 int Vx;
136                 int Vy;
137 
138                 int EdgeScrollX;
139                 int EdgeScrollY;
140 
141                 int CurrentDesk;
142                 int prev_page_x;
143                 int prev_page_y;
144                 int prev_desk;
145                 int prev_desk_and_page_desk;
146                 int prev_desk_and_page_page_x;
147                 int prev_desk_and_page_page_y;
148 
149 		bool is_swapping;
150         } virtual_scr;
151 
152 	PanFrame PanFrameTop;
153 	PanFrame PanFrameLeft;
154 	PanFrame PanFrameRight;
155 	PanFrame PanFrameBottom;
156 
157 	TAILQ_ENTRY(monitor) entry;
158 };
159 TAILQ_HEAD(monitors, monitor);
160 
161 extern struct monitors		monitor_q;
162 
163 struct monitor	*monitor_resolve_name(const char *);
164 struct monitor	*monitor_by_xy(int, int);
165 struct monitor  *monitor_by_output(int);
166 struct monitor  *monitor_by_primary(void);
167 struct monitor  *monitor_get_current(void);
168 void		 monitor_init_contents(struct monitor *);
169 void		 monitor_dump_state(struct monitor *);
170 void		 monitor_output_change(Display *, XRRScreenChangeNotifyEvent *);
171 int		 monitor_get_all_widths(void);
172 int		 monitor_get_all_heights(void);
173 void		 monitor_add_new(void);
174 void		 monitor_assign_virtual(struct monitor *);
175 void		 checkPanFrames(struct monitor *);
176 
177 #define FSCREEN_MANGLE_USPOS_HINTS_MAGIC ((short)-32109)
178 
179 extern int randr_event;
180 extern const char *prev_focused_monitor;
181 
182 /* Control */
183 void FScreenInit(Display *dpy);
184 void FScreenSelect(Display *dpy);
185 void FScreenSetPrimaryScreen(int scr);
186 
187 /* Screen info */
188 Bool FScreenGetScrRect(fscreen_scr_arg *, fscreen_scr_t,
189 	int *, int *, int *, int *);
190 Bool FScreenGetScrId(fscreen_scr_arg *arg);
191 void FScreenTranslateCoordinates(
192 	fscreen_scr_arg *arg_src, fscreen_scr_t screen_src,
193 	fscreen_scr_arg *arg_dest, fscreen_scr_t screen_dest,
194 	int *x, int *y);
195 void FScreenGetResistanceRect(
196 	int wx, int wy, unsigned int ww, unsigned int wh, int *x0, int *y0,
197 	int *x1, int *y1);
198 Bool FScreenIsRectangleOnScreen(fscreen_scr_arg *, fscreen_scr_t,rectangle *);
199 const char	*FScreenOfPointerXY(int, int);
200 int		 monitor_get_count(void);
201 struct monitor	*FindScreenOfXY(int, int);
202 
203 /* Clipping/positioning */
204 int FScreenClipToScreen(fscreen_scr_arg *, fscreen_scr_t,
205 	int *x, int *y, int w, int h);
206 void FScreenCenterOnScreen(fscreen_scr_arg *, fscreen_scr_t,
207 	int *x, int *y, int w, int h);
208 
209 /* Geometry management */
210 int FScreenParseGeometryWithScreen(
211 	char *parsestring, int *x_return, int *y_return,
212 	unsigned int *width_return, unsigned int *height_return,
213 	char **screen_return);
214 int FScreenParseGeometry(
215 	char *parsestring, int *x_return, int *y_return,
216 	unsigned int *width_return, unsigned int *height_return);
217 int  FScreenGetGeometry(
218 	char *parsestring, int *x_return, int *y_return,
219 	int *width_return, int *height_return, XSizeHints *hints, int flags);
220 void FScreenMangleScreenIntoUSPosHints(fscreen_scr_t screen, XSizeHints *hints);
221 int FScreenFetchMangledScreenFromUSPosHints(XSizeHints *hints);
222 
223 #endif /* FVWMLIB_FSCRREN_H */
224