2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* E-mail : see the 'copyright' file.
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 3
10
* of the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
/******************************************************************************
22
This file is a part of the cairo-dock program,
23
released under the terms of the GNU General Public License.
25
Written by Rémy Robertson (for any bug report, please mail me to changfu@cairo-dock.org)
26
Fabrice Rey <fabounet@users.berlios.de>
28
******************************************************************************/
34
#include <glib/gstdio.h>
35
#include <cairo-dock.h>
37
#include "applet-struct.h"
38
#include "applet-load-icon.h"
39
#include "applet-compiz.h"
42
//static char *s_cTmpFile = NULL;
44
void cd_compiz_start_system_wm (void) {
45
const gchar * cCommand = NULL;
46
if (myConfig.cUserWMCommand != NULL) {
47
cCommand = myConfig.cUserWMCommand;
50
switch (g_iDesktopEnv) {
51
case CAIRO_DOCK_GNOME :
52
case CAIRO_DOCK_XFCE :
53
cCommand = "metacity --replace";
56
cCommand = "kwin --replace";
59
cd_warning ("couldn't guess system WM");
63
myData.bCompizRestarted = TRUE;
64
cd_compiz_kill_compmgr(); //On tue tout les compositing managers
66
cd_message ("Compiz - Run: %s ", cCommand);
67
cairo_dock_launch_command (cCommand);
70
void cd_compiz_start_compiz (void) {
71
GString *sCommand = g_string_new ("");
73
gchar *cCompizBin = NULL; //On cherche
74
if (g_file_test ("/usr/bin/compiz.real", G_FILE_TEST_EXISTS))
75
cCompizBin = "compiz.real";
77
cCompizBin = "compiz";
79
g_string_printf (sCommand, "%s --replace --ignore-desktop-hints ccp", cCompizBin);
80
if (myConfig.lBinding) {
81
g_string_append (sCommand, " --loose-binding");
83
if (myConfig.iRendering) {
84
g_string_append (sCommand, " --indirect-rendering");
86
if (myConfig.uLocalScreen) {
87
g_string_append (sCommand, " --only-current-screen");
90
if (strcmp (myConfig.cWindowDecorator, "emerald") != 0)
91
g_string_append (sCommand, " --sm-disable");
93
cd_debug ("%s (%s)", __func__, sCommand->str);
95
myData.bCompizRestarted = TRUE;
96
cd_compiz_kill_compmgr(); //On tue tout les compositing managers
97
cairo_dock_launch_command (sCommand->str);
99
g_string_free (sCommand, TRUE);
101
cd_compiz_start_favorite_decorator ();
104
void cd_compiz_switch_manager(void) {
105
cd_compiz_read_data ();
106
if (myData.bAcquisitionOK) {
107
if (myData.bCompizIsRunning)
108
cd_compiz_start_system_wm ();
110
cd_compiz_start_compiz ();
115
void cd_compiz_start_favorite_decorator (void) {
116
cd_debug ("%s (%s)", __func__, myConfig.cWindowDecorator);
117
gchar *cCommand = g_strdup_printf ("%s --replace", myConfig.cWindowDecorator);
118
myData.bDecoratorRestarted = TRUE;
119
cairo_dock_launch_command (cCommand);
123
void cd_compiz_start_decorator (compizDecorator iDecorator) {
124
cd_debug ("%s (%d)", __func__, iDecorator);
125
g_return_if_fail (iDecorator >= 0 && iDecorator < COMPIZ_NB_DECORATORS && myConfig.cDecorators[iDecorator] != NULL);
126
gchar *cCommand = g_strdup_printf ("%s --replace", myConfig.cDecorators[iDecorator]);
127
myData.bDecoratorRestarted = TRUE;
128
cairo_dock_launch_command (cCommand);
132
void cd_compiz_kill_compmgr(void) {
133
gchar *cCommand = g_strdup_printf("bash %s/compiz-kill", MY_APPLET_SHARE_DATA_DIR);
134
int r = system (cCommand);
139
void cd_compiz_read_data(void) {
140
gchar *cCommand = g_strdup_printf("sh %s/compiz %s", MY_APPLET_SHARE_DATA_DIR, myConfig.cWindowDecorator); // truc de ouf : sans le 'sh' devant ca renvoit toujours '10' !
141
gchar *cResult = cairo_dock_launch_command_sync (cCommand);
145
myData.bAcquisitionOK = FALSE;
149
myData.bCompizIsRunning = (cResult[0] == '1');
150
myData.bDecoratorIsRunning = (cResult[0] != '\0' && cResult[1] == '1');
151
//g_print ("compiz : '%s' => %d/%d\n", standard_output, myData.bCompizIsRunning, myData.bDecoratorIsRunning);
152
myData.bAcquisitionOK = TRUE;
155
gboolean cd_compiz_update_from_data (void) {
156
cd_compiz_update_main_icon ();
157
cd_debug ("Compiz: %d - Decorator: %d", myData.bCompizIsRunning, myData.bDecoratorIsRunning);
158
if (! myData.bCompizIsRunning && myConfig.bAutoReloadCompiz) {
159
if (! myData.bCompizRestarted) {
160
myData.bCompizRestarted = TRUE; // c'est nous qui l'avons change.
161
cd_compiz_start_compiz (); // relance compiz.
164
if (! myData.bDecoratorIsRunning && myConfig.bAutoReloadDecorator) {
165
if (! myData.bDecoratorRestarted) {
166
myData.bDecoratorRestarted = TRUE; // c'est nous qui l'avons change.
167
cd_compiz_start_favorite_decorator (); // relance aussi le decorateur.
171
if (myData.bCompizIsRunning)
172
myData.bCompizRestarted = FALSE; // Compiz tourne, on le relancera s'il plante.
173
if (myData.bDecoratorIsRunning)
174
myData.bDecoratorRestarted = FALSE; // le decorateur tourne, on le relancera s'il plante.
175
return myData.bAcquisitionOK;