aboutsummaryrefslogtreecommitdiffstats
path: root/matchbox2/mb-window-manager.h
blob: ff22fe5b98ad7e122fe4600eb0c79e0249d708af (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
/*
 *  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_WINDOW_MANAGER_H
#define _HAVE_MB_WM_WINDOW_MANAGER_H

#include <matchbox2/mb-wm-config.h>
#include <matchbox2/mb-wm-object.h>
#include <matchbox2/mb-wm-root-window.h>
#include <matchbox2/xas.h>

typedef struct MBWindowManagerClass   MBWindowManagerClass;
typedef struct MBWindowManagerPriv    MBWindowManagerPriv;

#define MB_WINDOW_MANAGER(c)       ((MBWindowManager*)(c))
#define MB_WINDOW_MANAGER_CLASS(c) ((MBWindowManagerClass*)(c))
#define MB_TYPE_WINDOW_MANAGER     (mb_wm_class_type ())

typedef enum MBWindowManagerFlag
{
  MBWindowManagerFlagDesktop           = (1<<0),
  MBWindowManagerFlagAlwaysReloadTheme = (1<<1),
} MBWindowManagerFlag;

typedef enum
{
  MBWindowManagerSignalThemeChange = 1,
} MBWindowManagerSingal;

typedef enum
{
  MBWindowManagerCursorNone = 0,
  MBWindowManagerCursorLeftPtr,

  _MBWindowManagerCursorLast
} MBWindowManagerCursor;


struct MBWindowManager
{
  MBWMObject                   parent;

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

  MBWindowManagerClient       *stack_top, *stack_bottom;
  MBWMList                    *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;
  MBWMMainContext             *main_ctx;
  MBWindowManagerFlag          flags;
#if ENABLE_COMPOSITE
  MBWMCompMgr                 *comp_mgr;
  int                          damage_event_base;
#endif

  MBWindowManagerCursor        cursor;
  Cursor                       cursors[_MBWindowManagerCursorLast];

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

  MBWMModality                 modality_type;

  char                       **argv;
  int                          argc;
};

struct MBWindowManagerClass
{
  MBWMObjectClass parent;

  void (*process_cmdline) (MBWindowManager * wm);

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

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

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

#if ENABLE_COMPOSITE
  MBWMCompMgr * (*comp_mgr_new) (MBWindowManager *wm);
#endif

  void (*get_desktop_geometry) (MBWindowManager *wm, MBGeometry *geom);

  void (*main) (MBWindowManager *wm);
};

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

MBWindowManager *
mb_wm_new (int argc, char **argv);

MBWindowManager *
mb_wm_new_with_dpy (int argc, char **argv, Display * dpy);

void
mb_wm_init (MBWindowManager * wm);

void
mb_wm_set_layout (MBWindowManager *wm, MBWMLayout *layout);

int
mb_wm_class_type ();

void
mb_wm_main_loop(MBWindowManager *wm);

MBWindowManagerClient*
mb_wm_managed_client_from_xwindow(MBWindowManager *wm, Window win);

MBWindowManagerClient*
mb_wm_managed_client_from_frame (MBWindowManager *wm, Window frame);

int
mb_wm_register_client_type (void);

void
mb_wm_manage_client (MBWindowManager       *wm,
		     MBWindowManagerClient *client,
		     Bool                   activate);

void
mb_wm_unmanage_client (MBWindowManager       *wm,
		       MBWindowManagerClient *client,
		       Bool                   destroy);

void
mb_wm_display_sync_queue (MBWindowManager* wm, MBWMSyncType sync);

void
mb_wm_get_display_geometry (MBWindowManager  *wm,
			    MBGeometry       *geometry);

void
mb_wm_activate_client(MBWindowManager * wm, MBWindowManagerClient *c);

void
mb_wm_handle_ping_reply (MBWindowManager * wm, MBWindowManagerClient *c);

void
mb_wm_handle_hang_client (MBWindowManager * wm, MBWindowManagerClient *c);

void
mb_wm_handle_show_desktop (MBWindowManager * wm, Bool show);

void
mb_wm_toggle_desktop (MBWindowManager * wm);

MBWindowManagerClient*
mb_wm_get_visible_main_client(MBWindowManager *wm);

void
mb_wm_unfocus_client (MBWindowManager *wm, MBWindowManagerClient *client);

void
mb_wm_cycle_apps (MBWindowManager *wm, Bool reverse);

void
mb_wm_set_theme (MBWindowManager *wm, MBWMTheme * theme);

void
mb_wm_set_theme_from_path (MBWindowManager *wm, const char *theme_path);

void
mb_wm_set_cursor (MBWindowManager * wm, MBWindowManagerCursor cursor);

void
mb_wm_compositing_on (MBWindowManager * wm);

void
mb_wm_compositing_off (MBWindowManager * wm);

Bool
mb_wm_compositing_enabled (MBWindowManager * wm);

MBWMModality
mb_wm_get_modality_type (MBWindowManager * wm);

void
mb_wm_sync (MBWindowManager *wm);

void
mb_wm_set_n_desktops (MBWindowManager *wm, int n_desktops);

void
mb_wm_select_desktop (MBWindowManager *wm, int desktop);

#endif