gnome-shell-3.6.3.1/src/shell-wm.c

No issues found

  1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
  2 
  3 #include "config.h"
  4 
  5 #include <string.h>
  6 
  7 #include <meta/keybindings.h>
  8 
  9 #include "shell-wm-private.h"
 10 #include "shell-global.h"
 11 
 12 struct _ShellWM {
 13   GObject parent;
 14 
 15   MetaPlugin *plugin;
 16 };
 17 
 18 /* Signals */
 19 enum
 20 {
 21   MINIMIZE,
 22   MAXIMIZE,
 23   UNMAXIMIZE,
 24   MAP,
 25   DESTROY,
 26   SWITCH_WORKSPACE,
 27   KILL_SWITCH_WORKSPACE,
 28   KILL_WINDOW_EFFECTS,
 29 
 30   LAST_SIGNAL
 31 };
 32 
 33 G_DEFINE_TYPE(ShellWM, shell_wm, G_TYPE_OBJECT);
 34 
 35 static guint shell_wm_signals [LAST_SIGNAL] = { 0 };
 36 
 37 static void
 38 shell_wm_init (ShellWM *wm)
 39 {
 40 }
 41 
 42 static void
 43 shell_wm_finalize (GObject *object)
 44 {
 45   G_OBJECT_CLASS (shell_wm_parent_class)->finalize (object);
 46 }
 47 
 48 static void
 49 shell_wm_class_init (ShellWMClass *klass)
 50 {
 51   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
 52 
 53   gobject_class->finalize = shell_wm_finalize;
 54 
 55   shell_wm_signals[MINIMIZE] =
 56     g_signal_new ("minimize",
 57                   G_TYPE_FROM_CLASS (klass),
 58                   G_SIGNAL_RUN_LAST,
 59                   0,
 60                   NULL, NULL, NULL,
 61                   G_TYPE_NONE, 1,
 62                   META_TYPE_WINDOW_ACTOR);
 63   shell_wm_signals[MAXIMIZE] =
 64     g_signal_new ("maximize",
 65                   G_TYPE_FROM_CLASS (klass),
 66                   G_SIGNAL_RUN_LAST,
 67                   0,
 68                   NULL, NULL, NULL,
 69                   G_TYPE_NONE, 5,
 70                   META_TYPE_WINDOW_ACTOR, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
 71   shell_wm_signals[UNMAXIMIZE] =
 72     g_signal_new ("unmaximize",
 73                   G_TYPE_FROM_CLASS (klass),
 74                   G_SIGNAL_RUN_LAST,
 75                   0,
 76                   NULL, NULL, NULL,
 77                   G_TYPE_NONE, 5,
 78                   META_TYPE_WINDOW_ACTOR, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
 79   shell_wm_signals[MAP] =
 80     g_signal_new ("map",
 81                   G_TYPE_FROM_CLASS (klass),
 82                   G_SIGNAL_RUN_LAST,
 83                   0,
 84                   NULL, NULL, NULL,
 85                   G_TYPE_NONE, 1,
 86                   META_TYPE_WINDOW_ACTOR);
 87   shell_wm_signals[DESTROY] =
 88     g_signal_new ("destroy",
 89                   G_TYPE_FROM_CLASS (klass),
 90                   G_SIGNAL_RUN_LAST,
 91                   0,
 92                   NULL, NULL, NULL,
 93                   G_TYPE_NONE, 1,
 94                   META_TYPE_WINDOW_ACTOR);
 95   shell_wm_signals[SWITCH_WORKSPACE] =
 96     g_signal_new ("switch-workspace",
 97 		  G_TYPE_FROM_CLASS (klass),
 98 		  G_SIGNAL_RUN_LAST,
 99 		  0,
100           NULL, NULL, NULL,
101 		  G_TYPE_NONE, 3,
102                   G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
103   shell_wm_signals[KILL_SWITCH_WORKSPACE] =
104     g_signal_new ("kill-switch-workspace",
105 		  G_TYPE_FROM_CLASS (klass),
106 		  G_SIGNAL_RUN_LAST,
107 		  0,
108           NULL, NULL, NULL,
109 		  G_TYPE_NONE, 0);
110   shell_wm_signals[KILL_WINDOW_EFFECTS] =
111     g_signal_new ("kill-window-effects",
112 		  G_TYPE_FROM_CLASS (klass),
113 		  G_SIGNAL_RUN_LAST,
114 		  0,
115           NULL, NULL, NULL,
116 		  G_TYPE_NONE, 1,
117 		  META_TYPE_WINDOW_ACTOR);
118 }
119 
120 void
121 _shell_wm_switch_workspace (ShellWM      *wm,
122                             gint          from,
123                             gint          to,
124                             MetaMotionDirection direction)
125 {
126   g_signal_emit (wm, shell_wm_signals[SWITCH_WORKSPACE], 0,
127                  from, to, direction);
128 }
129 
130 /**
131  * shell_wm_completed_switch_workspace:
132  * @wm: the ShellWM
133  *
134  * The plugin must call this when it has finished switching the
135  * workspace.
136  **/
137 void
138 shell_wm_completed_switch_workspace (ShellWM *wm)
139 {
140   meta_plugin_switch_workspace_completed (wm->plugin);
141 }
142 
143 /**
144  * shell_wm_completed_minimize:
145  * @wm: the ShellWM
146  * @actor: the MetaWindowActor actor
147  *
148  * The plugin must call this when it has completed a window minimize effect.
149  **/
150 void
151 shell_wm_completed_minimize (ShellWM         *wm,
152                              MetaWindowActor *actor)
153 {
154   meta_plugin_minimize_completed (wm->plugin, actor);
155 }
156 
157 /**
158  * shell_wm_completed_maximize:
159  * @wm: the ShellWM
160  * @actor: the MetaWindowActor actor
161  *
162  * The plugin must call this when it has completed a window maximize effect.
163  **/
164 void
165 shell_wm_completed_maximize (ShellWM         *wm,
166                              MetaWindowActor *actor)
167 {
168   meta_plugin_maximize_completed (wm->plugin, actor);
169 }
170 
171 /**
172  * shell_wm_completed_unmaximize:
173  * @wm: the ShellWM
174  * @actor: the MetaWindowActor actor
175  *
176  * The plugin must call this when it has completed a window unmaximize effect.
177  **/
178 void
179 shell_wm_completed_unmaximize (ShellWM         *wm,
180                                MetaWindowActor *actor)
181 {
182   meta_plugin_unmaximize_completed (wm->plugin, actor);
183 }
184 
185 /**
186  * shell_wm_completed_map:
187  * @wm: the ShellWM
188  * @actor: the MetaWindowActor actor
189  *
190  * The plugin must call this when it has completed a window map effect.
191  **/
192 void
193 shell_wm_completed_map (ShellWM         *wm,
194                         MetaWindowActor *actor)
195 {
196   meta_plugin_map_completed (wm->plugin, actor);
197 }
198 
199 /**
200  * shell_wm_completed_destroy:
201  * @wm: the ShellWM
202  * @actor: the MetaWindowActor actor
203  *
204  * The plugin must call this when it has completed a window destroy effect.
205  **/
206 void
207 shell_wm_completed_destroy (ShellWM         *wm,
208                             MetaWindowActor *actor)
209 {
210   meta_plugin_destroy_completed (wm->plugin, actor);
211 }
212 
213 void
214 _shell_wm_kill_switch_workspace (ShellWM      *wm)
215 {
216   g_signal_emit (wm, shell_wm_signals[KILL_SWITCH_WORKSPACE], 0);
217 }
218 
219 void
220 _shell_wm_kill_window_effects (ShellWM         *wm,
221                                MetaWindowActor *actor)
222 {
223   g_signal_emit (wm, shell_wm_signals[KILL_WINDOW_EFFECTS], 0, actor);
224 }
225 
226 
227 void
228 _shell_wm_minimize (ShellWM         *wm,
229                     MetaWindowActor *actor)
230 {
231   g_signal_emit (wm, shell_wm_signals[MINIMIZE], 0, actor);
232 }
233 
234 void
235 _shell_wm_maximize (ShellWM         *wm,
236                     MetaWindowActor *actor,
237                     int              target_x,
238                     int              target_y,
239                     int              target_width,
240                     int              target_height)
241 {
242   g_signal_emit (wm, shell_wm_signals[MAXIMIZE], 0, actor, target_x, target_y, target_width, target_height);
243 }
244 
245 void
246 _shell_wm_unmaximize (ShellWM         *wm,
247                       MetaWindowActor *actor,
248                       int              target_x,
249                       int              target_y,
250                       int              target_width,
251                       int              target_height)
252 {
253   g_signal_emit (wm, shell_wm_signals[UNMAXIMIZE], 0, actor, target_x, target_y, target_width, target_height);
254 }
255 
256 void
257 _shell_wm_map (ShellWM         *wm,
258                MetaWindowActor *actor)
259 {
260   g_signal_emit (wm, shell_wm_signals[MAP], 0, actor);
261 }
262 
263 void
264 _shell_wm_destroy (ShellWM         *wm,
265                    MetaWindowActor *actor)
266 {
267   g_signal_emit (wm, shell_wm_signals[DESTROY], 0, actor);
268 }
269 
270 /**
271  * shell_wm_new:
272  * @plugin: the #MetaPlugin
273  *
274  * Creates a new window management interface by hooking into @plugin.
275  *
276  * Return value: the new window-management interface
277  **/
278 ShellWM *
279 shell_wm_new (MetaPlugin *plugin)
280 {
281   ShellWM *wm;
282 
283   wm = g_object_new (SHELL_TYPE_WM, NULL);
284   wm->plugin = plugin;
285 
286   return wm;
287 }