aboutsummaryrefslogtreecommitdiffstats
path: root/matchbox/mb-wm-manager.h
blob: 4f143ab57395f3ea14ef40c9111352d33b4c7507 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
/*
 *  Matchbox Window Manager II - A lightweight window manager not for the
 *                               desktop.
 *
 *  Authored By Matthew Allum <mallum@o-hand.com>
 *
 *  Copyright (c) 2005, 2007 OpenedHand Ltd - http://o-hand.com
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 */

#ifndef _HAVE_MB_WM_MANAGER_H
#define _HAVE_MB_WM_MANAGER_H

#include <matchbox/mb-wm-config.h>
#include <matchbox/mb-wm-types.h>
#include <matchbox/mb-wm-object.h>
#include <matchbox/mb-wm-keys.h>
#include <matchbox/mb-wm-root-window.h>
#include <matchbox/mb-wm-theme.h>
#include <matchbox/mb-wm-layout.h>
#if ENABLE_COMPOSITE
#include <matchbox/mb-wm-comp-mgr.h>
#endif
#include <matchbox/xas.h>

#define MB_WM_MANAGER(c)       ((MBWMManager*)(c))
#define MB_WM_MANAGER_CLASS(c) ((MBWMManagerClass*)(c))
#define MB_WM_TYPE_MANAGER     (mb_wm_manager_class_type ())

typedef struct MBWMManagerClass   MBWMManagerClass;
typedef struct MBWMManagerPriv    MBWMManagerPriv;

typedef enum MBWMManagerFlag
{
  MBWMManagerFlagDesktop           = (1<<0),
  MBWMManagerFlagAlwaysReloadTheme = (1<<1),
} MBWMManagerFlag;

typedef enum
{
  MBWMManagerSignalThemeChange = 1,
} MBWMManagerSingal;

typedef enum
{
  MBWMManagerCursorNone = 0,
  MBWMManagerCursorLeftPtr,

  _MBWMManagerCursorLast
} MBWMManagerCursor;

typedef Bool (*MBWMManagerEventFunc) (XEvent * xev, void * userdata);

typedef struct MBWMEventFuncs
{
  /* FIXME: figure our X wrap / unwrap mechanism */
  GList *map_notify;
  GList *unmap_notify;
  GList *map_request;
  GList *destroy_notify;
  GList *configure_request;
  GList *configure_notify;
  GList *key_press;
  GList *property_notify;
  GList *button_press;
  GList *button_release;
  GList *motion_notify;
  GList *client_message;

#if ENABLE_COMPOSITE
  GList *damage_notify;
#endif
} MBWMEventFuncs;

struct MBWMManager
{
  MBWMObject                   parent;

  Display                     *xdpy;
  unsigned int                 xdpy_width, xdpy_height;
  int                          xscreen;

  GList                       *xlib_event_filters;
  GQueue                      *event_queue;
  gboolean                     event_retrieval_disabled;
  GSource                     *event_source;
  unsigned int                 do_update_idle;
  MBWMEventFuncs               event_funcs;

  MBWindowManagerClient       *stack_top, *stack_bottom;
  GList                    *clients;
  MBWindowManagerClient       *desktop;
  MBWindowManagerClient       *focused_client;

  int                          n_desktops;
  int                          active_desktop;

  Atom                         atoms[MBWM_ATOM_COUNT];

  MBWMKeys                    *keys; /* Keybindings etc */

  XasContext                  *xas_context;

  /* ### Private ### */
  MBWMSyncType                 sync_type;
  int                          client_type_cnt;
  int                          stack_n_clients;
  MBWMRootWindow              *root_win;

  const char                  *sm_client_id;

  MBWMTheme                   *theme;
  MBWMLayout                  *layout;
  MBWMManagerFlag          flags;
#if ENABLE_COMPOSITE
  MBWMCompMgr                 *comp_mgr;
  int                          damage_event_base;
#endif

  MBWMManagerCursor        cursor;
  Cursor                       cursors[_MBWMManagerCursorLast];

  /* Temporary stuff, only valid during object initialization */
  const char                  *theme_path;

  MBWMModality                 modality_type;

  char                       **argv;
  int                          argc;
};

struct MBWMManagerClass
{
  MBWMObjectClass parent;

  void (*process_cmdline) (MBWMManager * wm);

  MBWindowManagerClient* (*client_new) (MBWMManager *wm,
					MBWMClientWindow *w);
  MBWMLayout           * (*layout_new) (MBWMManager *wm);

  /* These return True if now further action to be taken */
  Bool (*client_activate)   (MBWMManager *wm, MBWindowManagerClient *c);
  Bool (*client_responding) (MBWMManager *wm, MBWindowManagerClient *c);
  Bool (*client_hang)       (MBWMManager *wm, MBWindowManagerClient *c);

  MBWMTheme * (*theme_new)  (MBWMManager *wm, const char * path);

  void (*get_desktop_geometry) (MBWMManager *wm, MBGeometry *geom);
};

/**
 * SECTION:matchbox2
 * @short_description: Core functions for creating and manipulating a
 *                     #MBWMManager
 *
 * The core object of Matchbox2 is the #MBWMManager object, which
 * is the first thing you would instantiate when implementing a new
 * window manager.
 */

MBWMManager *
mb_wm_manager_new (int argc, char **argv);

MBWMManager *
mb_wm_manager_new_with_dpy (int argc, char **argv, Display * dpy);

void
mb_wm_manager_disable_x11_event_retrieval (MBWMManager *wm);

void
mb_wm_manager_xlib_add_filter (MBWMManager *wm,
                               MBWMXlibFilterFunc filter,
                               void *data);

void
mv_wm_manager_xlib_remove_filter (MBWMManager *wm,
                                  MBWMXlibFilterFunc func,
                                  void *data);

gboolean
mb_wm_manager_handle_xlib_event (MBWMManager *wm, XEvent *xev);

void
mb_wm_manager_start (MBWMManager * wm);

void
mb_wm_manager_start_with_compositor (MBWMManager * wm, MBWMCompMgr *compositor);

void
mb_wm_manager_set_layout (MBWMManager *wm, MBWMLayout *layout);

int
mb_wm_manager_class_type ();

void
mb_wm_manager_main_loop(MBWMManager *wm);

MBWindowManagerClient*
mb_wm_manager_managed_window_from_xwindow(MBWMManager *wm, Window win);

MBWindowManagerClient*
mb_wm_manager_managed_window_from_frame (MBWMManager *wm, Window frame);

int
mb_wm_manager_register_window_type (void);

void
mb_wm_manager_manage_window (MBWMManager       *wm,
		     MBWindowManagerClient *client,
		     Bool                   activate);

void
mb_wm_manager_unmanage_window (MBWMManager       *wm,
		       MBWindowManagerClient *client,
		       Bool                   destroy);

void
mb_wm_manager_display_sync_queue (MBWMManager* wm, MBWMSyncType sync);

void
mb_wm_manager_get_display_geometry (MBWMManager  *wm,
			    MBGeometry       *geometry);

void
mb_wm_manager_activate_window(MBWMManager * wm, MBWindowManagerClient *c);

void
mb_wm_manager_handle_ping_reply (MBWMManager * wm, MBWindowManagerClient *c);

void
mb_wm_manager_handle_hung_window (MBWMManager * wm, MBWindowManagerClient *c);

void
mb_wm_manager_handle_show_desktop (MBWMManager * wm, Bool show);

void
mb_wm_manager_toggle_desktop (MBWMManager * wm);

MBWindowManagerClient*
mb_wm_manager_manager_get_visible_main_window(MBWMManager *wm);

void
mb_wm_manager_unfocus_window (MBWMManager *wm, MBWindowManagerClient *client);

void
mb_wm_manager_cycle_apps (MBWMManager *wm, Bool reverse);

void
mb_wm_manager_set_theme (MBWMManager *wm, MBWMTheme * theme);

void
mb_wm_manager_set_theme_from_path (MBWMManager *wm, const char *theme_path);

void
mb_wm_manager_set_cursor (MBWMManager * wm, MBWMManagerCursor cursor);

void
mb_wm_manager_set_compositing_on (MBWMManager * wm);

void
mb_wm_manager_set_compositing_off (MBWMManager * wm);

Bool
mb_wm_manager_compositing_enabled (MBWMManager * wm);

MBWMModality
mb_wm_manager_get_modality_type (MBWMManager * wm);

unsigned long
mb_wm_manager_add_event_handler (MBWMManager     *wm,
				 Window           xwin,
				 int              type,
				 MBWMXEventFunc   func,
				 void            *userdata);

void
mb_wm_manager_remove_event_handler (MBWMManager     *wm,
				    int              type,
				    unsigned long    id);

void
mb_wm_manager_sync (MBWMManager *wm);

void
mb_wm_manager_set_n_desktops (MBWMManager *wm, int n_desktops);

void
mb_wm_manager_select_desktop (MBWMManager *wm, int desktop);

int
mb_wm_manager_util_pixels_to_points (MBWMManager *wm, int pixels);

#endif