2
* Copyright © 2005 Novell, Inc.
4
* Permission to use, copy, modify, distribute, and sell this software
5
* and its documentation for any purpose is hereby granted without
6
* fee, provided that the above copyright notice appear in all copies
7
* and that both that copyright notice and this permission notice
8
* appear in supporting documentation, and that the name of
9
* Novell, Inc. not be used in advertising or publicity pertaining to
10
* distribution of the software without specific, written prior permission.
11
* Novell, Inc. makes no representations about the suitability of this
12
* software for any purpose. It is provided "as is" without express or
15
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17
* NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23
* Author: David Reveman <davidr@novell.com>
27
#include <sys/types.h>
30
#include <gconf/gconf-client.h>
32
#include "compiz-window-manager.h"
34
#define COMPIZ_CLICK_TO_FOCUS_KEY \
35
"/apps/compiz/general/allscreens/options/click_to_focus"
37
#define COMPIZ_AUTORAISE_KEY \
38
"/apps/compiz/general/allscreens/options/autoraise"
40
#define COMPIZ_AUTORAISE_DELAY_KEY \
41
"/apps/compiz/general/allscreens/options/autoraise_delay"
43
#define COMPIZ_MOUSE_MOVE_KEY \
44
"/apps/compiz/plugins/move/screen0/options/initiate"
46
#define COMPIZ_DOUBLE_CLICK_TITLEBAR_KEY \
47
"/apps/compiz/general/allscreens/options/action_double_click_titlebar"
53
static GnomeWindowManagerClass *parent_class;
55
struct _CompizWindowManagerPrivate {
61
value_changed (GConfClient *client,
66
CompizWindowManager *wm;
68
wm = COMPIZ_WINDOW_MANAGER (data);
70
gnome_window_manager_settings_changed (GNOME_WINDOW_MANAGER (wm));
73
/* this function is called when the shared lib is loaded */
75
window_manager_new (int expected_interface_version)
79
if (expected_interface_version != GNOME_WINDOW_MANAGER_INTERFACE_VERSION)
81
g_warning ("Compiz window manager module wasn't compiled with the "
82
"current version of gnome-control-center");
86
wm = g_object_new (compiz_window_manager_get_type (), NULL);
92
compiz_change_settings (GnomeWindowManager *wm,
93
const GnomeWMSettings *settings)
95
CompizWindowManager *cwm;
97
cwm = COMPIZ_WINDOW_MANAGER (wm);
99
if (settings->flags & GNOME_WM_SETTING_MOUSE_FOCUS)
100
gconf_client_set_bool (cwm->p->gconf,
101
COMPIZ_CLICK_TO_FOCUS_KEY,
102
settings->focus_follows_mouse == FALSE,
105
if (settings->flags & GNOME_WM_SETTING_AUTORAISE)
106
gconf_client_set_bool (cwm->p->gconf,
107
COMPIZ_AUTORAISE_KEY,
108
settings->autoraise, NULL);
110
if (settings->flags & GNOME_WM_SETTING_AUTORAISE_DELAY)
111
gconf_client_set_int (cwm->p->gconf,
112
COMPIZ_AUTORAISE_DELAY_KEY,
113
settings->autoraise_delay, NULL);
115
if (settings->flags & GNOME_WM_SETTING_MOUSE_MOVE_MODIFIER)
119
value = g_strdup_printf ("<%s>Button1", settings->mouse_move_modifier);
120
gconf_client_set_string (cwm->p->gconf,
121
COMPIZ_MOUSE_MOVE_KEY,
127
if (settings->flags & GNOME_WM_SETTING_DOUBLE_CLICK_ACTION)
129
const char *action = NULL;
131
switch (settings->double_click_action) {
132
case DOUBLE_CLICK_SHADE:
133
action = "toggle_shade";
135
case DOUBLE_CLICK_MAXIMIZE:
136
action = "toggle_maximize";
141
gconf_client_set_string (meta_wm->p->gconf,
142
COMPIZ_DOUBLE_CLICK_TITLEBAR_KEY,
150
compiz_get_settings (GnomeWindowManager *wm,
151
GnomeWMSettings *settings)
153
CompizWindowManager *cwm;
156
cwm = COMPIZ_WINDOW_MANAGER (wm);
158
to_get = settings->flags;
161
if (to_get & GNOME_WM_SETTING_MOUSE_FOCUS)
163
settings->focus_follows_mouse =
164
gconf_client_get_bool (cwm->p->gconf,
165
COMPIZ_CLICK_TO_FOCUS_KEY, NULL) == FALSE;
167
settings->flags |= GNOME_WM_SETTING_MOUSE_FOCUS;
170
if (to_get & GNOME_WM_SETTING_AUTORAISE)
172
settings->autoraise = FALSE;
174
settings->autoraise = gconf_client_get_bool (cwm->p->gconf,
175
COMPIZ_AUTORAISE_KEY,
178
settings->flags |= GNOME_WM_SETTING_AUTORAISE;
181
if (to_get & GNOME_WM_SETTING_AUTORAISE_DELAY)
183
settings->autoraise_delay =
184
gconf_client_get_int (cwm->p->gconf,
185
COMPIZ_AUTORAISE_DELAY_KEY,
188
settings->flags |= GNOME_WM_SETTING_AUTORAISE_DELAY;
191
if (to_get & GNOME_WM_SETTING_MOUSE_MOVE_MODIFIER)
196
str = gconf_client_get_string (cwm->p->gconf,
197
COMPIZ_MOUSE_MOVE_KEY,
201
str = g_strdup ("<Super>");
203
if (strncmp (str, "<Super>", 7) == 0)
205
else if (strncmp (str, "<Alt>", 5) == 0)
207
else if (strncmp (str, "<Meta>", 6) == 0)
209
else if (strncmp (str, "<Hyper>", 7) == 0)
211
else if (strncmp (str, "<Control>", 9) == 0)
216
if (new && cwm->p->mouse_modifier &&
217
strcmp (new, cwm->p->mouse_modifier) == 0)
223
g_free (cwm->p->mouse_modifier);
224
cwm->p->mouse_modifier = g_strdup (new ? new : "");
229
settings->mouse_move_modifier = cwm->p->mouse_modifier;
231
settings->flags |= GNOME_WM_SETTING_MOUSE_MOVE_MODIFIER;
234
if (to_get & GNOME_WM_SETTING_DOUBLE_CLICK_ACTION)
239
str = gconf_client_get_string (cwm->p->gconf,
240
COMPIZ_DOUBLE_CLICK_TITLEBAR_KEY,
244
str = g_strdup ("toggle_shade");
246
if (strcmp (str, "toggle_shade") == 0)
247
settings->double_click_action = DOUBLE_CLICK_SHADE;
248
else if (strcmp (str, "toggle_maximize") == 0)
249
settings->double_click_action = DOUBLE_CLICK_MAXIMIZE;
251
settings->double_click_action = DOUBLE_CLICK_SHADE;
255
settings->flags |= GNOME_WM_SETTING_DOUBLE_CLICK_ACTION;
261
compiz_get_settings_mask (GnomeWindowManager *wm)
264
/* GNOME_WM_SETTING_FONT | */
265
GNOME_WM_SETTING_MOUSE_FOCUS |
266
GNOME_WM_SETTING_AUTORAISE |
267
GNOME_WM_SETTING_AUTORAISE_DELAY |
268
GNOME_WM_SETTING_MOUSE_MOVE_MODIFIER |
269
/* GNOME_WM_SETTING_THEME | */
270
/* GNOME_WM_SETTING_DOUBLE_CLICK_ACTION */ 0;
274
compiz_get_theme_list (GnomeWindowManager *wm)
280
compiz_get_user_theme_folder (GnomeWindowManager *wm)
286
compiz_get_double_click_actions (GnomeWindowManager *wm,
287
const GnomeWMDoubleClickAction **actions_p,
290
static GnomeWMDoubleClickAction actions[] = {
291
{ DOUBLE_CLICK_MAXIMIZE, "Maximize" }
293
static gboolean initialized = FALSE;
300
while (i < (int) G_N_ELEMENTS (actions))
302
g_assert (actions[i].number == i);
303
actions[i].human_readable_name = actions[i].human_readable_name;
309
*actions_p = actions;
310
*n_actions_p = (int) G_N_ELEMENTS (actions);
314
compiz_window_manager_init (CompizWindowManager *cwm,
315
CompizWindowManagerClass *class)
317
cwm->p = g_new0 (CompizWindowManagerPrivate, 1);
318
cwm->p->gconf = gconf_client_get_default ();
319
cwm->p->mouse_modifier = NULL;
321
gconf_client_add_dir (cwm->p->gconf,
323
GCONF_CLIENT_PRELOAD_ONELEVEL,
326
g_signal_connect (G_OBJECT (cwm->p->gconf),
328
G_CALLBACK (value_changed),
333
compiz_window_manager_finalize (GObject *object)
335
CompizWindowManager *cwm;
337
g_return_if_fail (object != NULL);
338
g_return_if_fail (IS_COMPIZ_WINDOW_MANAGER (object));
340
cwm = COMPIZ_WINDOW_MANAGER (object);
342
g_signal_handlers_disconnect_by_func (G_OBJECT (cwm->p->gconf),
343
G_CALLBACK (value_changed),
346
g_object_unref (G_OBJECT (cwm->p->gconf));
349
G_OBJECT_CLASS (parent_class)->finalize (object);
353
compiz_window_manager_class_init (CompizWindowManagerClass *class)
355
GObjectClass *object_class;
356
GnomeWindowManagerClass *wm_class;
358
object_class = G_OBJECT_CLASS (class);
359
wm_class = GNOME_WINDOW_MANAGER_CLASS (class);
361
object_class->finalize = compiz_window_manager_finalize;
363
wm_class->change_settings = compiz_change_settings;
364
wm_class->get_settings = compiz_get_settings;
365
wm_class->get_settings_mask = compiz_get_settings_mask;
366
wm_class->get_theme_list = compiz_get_theme_list;
367
wm_class->get_user_theme_folder = compiz_get_user_theme_folder;
368
wm_class->get_double_click_actions = compiz_get_double_click_actions;
370
parent_class = g_type_class_peek_parent (class);
374
compiz_window_manager_get_type (void)
376
static GType compiz_window_manager_type = 0;
378
if (!compiz_window_manager_type)
380
static GTypeInfo compiz_window_manager_info = {
381
sizeof (CompizWindowManagerClass),
384
(GClassInitFunc) compiz_window_manager_class_init,
387
sizeof (CompizWindowManager),
389
(GInstanceInitFunc) compiz_window_manager_init,
393
compiz_window_manager_type =
394
g_type_register_static (gnome_window_manager_get_type (),
395
"CompizWindowManager",
396
&compiz_window_manager_info, 0);
399
return compiz_window_manager_type;