1 /* window object */
2 /* vim: set sw=2 et: */
3 
4 /*
5  * Copyright (C) 2001 Havoc Pennington
6  * Copyright (C) 2006-2007 Vincent Untz
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #if !defined (__LIBWNCK_H_INSIDE__) && !defined (WNCK_COMPILATION)
23 #error "Only <libwnck/libwnck.h> can be included directly."
24 #endif
25 
26 #ifndef WNCK_WINDOW_H
27 #define WNCK_WINDOW_H
28 
29 #ifndef WNCK_I_KNOW_THIS_IS_UNSTABLE
30 #error "libwnck should only be used if you understand that it's subject to frequent change, and is not supported as a fixed API/ABI or as part of the platform"
31 #endif
32 
33 #include <glib-object.h>
34 #include <libwnck/screen.h>
35 #include <gdk-pixbuf/gdk-pixbuf.h>
36 
37 G_BEGIN_DECLS
38 
39 /**
40  * WnckWindowState:
41  * @WNCK_WINDOW_STATE_MINIMIZED: the window is minimized.
42  * @WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY: the window is horizontically
43  * maximized.
44  * @WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY: the window is vertically maximized.
45  * @WNCK_WINDOW_STATE_SHADED: the window is shaded.
46  * @WNCK_WINDOW_STATE_SKIP_PAGER: the window should not be included on pagers.
47  * @WNCK_WINDOW_STATE_SKIP_TASKLIST: the window should not be included on
48  * tasklists.
49  * @WNCK_WINDOW_STATE_STICKY: the window is sticky (see
50  * wnck_window_is_sticky()).
51  * @WNCK_WINDOW_STATE_HIDDEN: the window is not visible on its #WnckWorkspace
52  * and viewport (when minimized, for example).
53  * @WNCK_WINDOW_STATE_FULLSCREEN: the window is fullscreen.
54  * @WNCK_WINDOW_STATE_DEMANDS_ATTENTION: the window needs attention (because
55  * the window requested activation but the window manager refused it, for
56  * example).
57  * @WNCK_WINDOW_STATE_URGENT: the window requires a response from the user.
58  * @WNCK_WINDOW_STATE_ABOVE: the window is above other windows (see
59  * wnck_window_make_above()).
60  * @WNCK_WINDOW_STATE_BELOW: the window is below other windows (see
61  * wnck_window_make_below()).
62  *
63  * Type used as a bitmask to describe the state of a #WnckWindow.
64  */
65 typedef enum
66 {
67   WNCK_WINDOW_STATE_MINIMIZED              = 1 << 0,
68   WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY = 1 << 1,
69   WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY   = 1 << 2,
70   WNCK_WINDOW_STATE_SHADED                 = 1 << 3,
71   WNCK_WINDOW_STATE_SKIP_PAGER             = 1 << 4,
72   WNCK_WINDOW_STATE_SKIP_TASKLIST          = 1 << 5,
73   WNCK_WINDOW_STATE_STICKY                 = 1 << 6,
74   WNCK_WINDOW_STATE_HIDDEN                 = 1 << 7,
75   WNCK_WINDOW_STATE_FULLSCREEN             = 1 << 8,
76   WNCK_WINDOW_STATE_DEMANDS_ATTENTION      = 1 << 9,
77   WNCK_WINDOW_STATE_URGENT                 = 1 << 10,
78   WNCK_WINDOW_STATE_ABOVE                  = 1 << 11,
79   WNCK_WINDOW_STATE_BELOW                  = 1 << 12
80 } WnckWindowState;
81 
82 /**
83  * WnckWindowActions:
84  * @WNCK_WINDOW_ACTION_MOVE: the window may be moved around the screen.
85  * @WNCK_WINDOW_ACTION_RESIZE: the window may be resized.
86  * @WNCK_WINDOW_ACTION_SHADE: the window may be shaded.
87  * @WNCK_WINDOW_ACTION_STICK: the window may be sticked.
88  * @WNCK_WINDOW_ACTION_MAXIMIZE_HORIZONTALLY: the window may be maximized
89  * horizontally.
90  * @WNCK_WINDOW_ACTION_MAXIMIZE_VERTICALLY: the window may be maximized
91  * vertically.
92  * @WNCK_WINDOW_ACTION_CHANGE_WORKSPACE: the window may be moved between
93  * workspaces, or (un)pinned.
94  * @WNCK_WINDOW_ACTION_CLOSE: the window may be closed.
95  * @WNCK_WINDOW_ACTION_UNMAXIMIZE_HORIZONTALLY: the window may be unmaximized
96  * horizontally.
97  * @WNCK_WINDOW_ACTION_UNMAXIMIZE_VERTICALLY: the window may be maximized
98  * vertically.
99  * @WNCK_WINDOW_ACTION_UNSHADE: the window may be unshaded.
100  * @WNCK_WINDOW_ACTION_UNSTICK: the window may be unsticked.
101  * @WNCK_WINDOW_ACTION_MINIMIZE: the window may be minimized.
102  * @WNCK_WINDOW_ACTION_UNMINIMIZE: the window may be unminimized.
103  * @WNCK_WINDOW_ACTION_MAXIMIZE: the window may be maximized.
104  * @WNCK_WINDOW_ACTION_UNMAXIMIZE: the window may be unmaximized.
105  * @WNCK_WINDOW_ACTION_FULLSCREEN: the window may be brought to fullscreen.
106  * @WNCK_WINDOW_ACTION_ABOVE: the window may be made above other windows.
107  * @WNCK_WINDOW_ACTION_BELOW: the window may be made below other windows.
108  *
109  * Type used as a bitmask to describe the actions that can be done for a
110  * #WnckWindow.
111  */
112 typedef enum
113 {
114   WNCK_WINDOW_ACTION_MOVE                    = 1 << 0,
115   WNCK_WINDOW_ACTION_RESIZE                  = 1 << 1,
116   WNCK_WINDOW_ACTION_SHADE                   = 1 << 2,
117   WNCK_WINDOW_ACTION_STICK                   = 1 << 3,
118   WNCK_WINDOW_ACTION_MAXIMIZE_HORIZONTALLY   = 1 << 4,
119   WNCK_WINDOW_ACTION_MAXIMIZE_VERTICALLY     = 1 << 5,
120   WNCK_WINDOW_ACTION_CHANGE_WORKSPACE        = 1 << 6, /* includes pin/unpin */
121   WNCK_WINDOW_ACTION_CLOSE                   = 1 << 7,
122   WNCK_WINDOW_ACTION_UNMAXIMIZE_HORIZONTALLY = 1 << 8,
123   WNCK_WINDOW_ACTION_UNMAXIMIZE_VERTICALLY   = 1 << 9,
124   WNCK_WINDOW_ACTION_UNSHADE                 = 1 << 10,
125   WNCK_WINDOW_ACTION_UNSTICK                 = 1 << 11,
126   WNCK_WINDOW_ACTION_MINIMIZE                = 1 << 12,
127   WNCK_WINDOW_ACTION_UNMINIMIZE              = 1 << 13,
128   WNCK_WINDOW_ACTION_MAXIMIZE                = 1 << 14,
129   WNCK_WINDOW_ACTION_UNMAXIMIZE              = 1 << 15,
130   WNCK_WINDOW_ACTION_FULLSCREEN              = 1 << 16,
131   WNCK_WINDOW_ACTION_ABOVE                   = 1 << 17,
132   WNCK_WINDOW_ACTION_BELOW                   = 1 << 18
133 } WnckWindowActions;
134 
135 /**
136  * WnckWindowType:
137  * @WNCK_WINDOW_NORMAL: the window is a normal window.
138  * @WNCK_WINDOW_DESKTOP: the window is a desktop.
139  * @WNCK_WINDOW_DOCK: the window is a dock or a panel.
140  * @WNCK_WINDOW_DIALOG: the window is a dialog window.
141  * @WNCK_WINDOW_TOOLBAR: the window is a tearoff toolbar.
142  * @WNCK_WINDOW_MENU: the window is a tearoff menu.
143  * @WNCK_WINDOW_UTILITY: the window is a small persistent utility window, such
144  * as a palette or toolbox.
145  * @WNCK_WINDOW_SPLASHSCREEN: the window is a splash screen displayed as an
146  * application is starting up.
147  *
148  * Type describing the semantic type of a #WnckWindow.
149  */
150 typedef enum
151 {
152   WNCK_WINDOW_NORMAL,       /* document/app window */
153   WNCK_WINDOW_DESKTOP,      /* desktop background */
154   WNCK_WINDOW_DOCK,         /* panel */
155   WNCK_WINDOW_DIALOG,       /* dialog */
156   WNCK_WINDOW_TOOLBAR,      /* tearoff toolbar */
157   WNCK_WINDOW_MENU,         /* tearoff menu */
158   WNCK_WINDOW_UTILITY,      /* palette/toolbox window */
159   WNCK_WINDOW_SPLASHSCREEN  /* splash screen */
160 } WnckWindowType;
161 
162 /**
163  * WnckWindowGravity:
164  * @WNCK_WINDOW_GRAVITY_CURRENT: keep the current gravity point.
165  * @WNCK_WINDOW_GRAVITY_NORTHWEST: use the left top corner of the frame window
166  * as gravity point.
167  * @WNCK_WINDOW_GRAVITY_NORTH: use the center of the frame window's top side as
168  * gravity point.
169  * @WNCK_WINDOW_GRAVITY_NORTHEAST: use the right top corner of the frame window
170  * as gravity point.
171  * @WNCK_WINDOW_GRAVITY_WEST: use the center of the frame window's left side as
172  * gravity point.
173  * @WNCK_WINDOW_GRAVITY_CENTER: use the center of the frame window as gravity
174  * point.
175  * @WNCK_WINDOW_GRAVITY_EAST: use the center of the frame window's right side
176  * as gravity point.
177  * @WNCK_WINDOW_GRAVITY_SOUTHWEST: use the left bottom corner of the frame
178  * window as gravity point.
179  * @WNCK_WINDOW_GRAVITY_SOUTH: use the center of the frame window's bottom side
180  * as gravity point.
181  * @WNCK_WINDOW_GRAVITY_SOUTHEAST: use the right bottom corner of the frame
182  * window as gravity point.
183  * @WNCK_WINDOW_GRAVITY_STATIC: use the left top corner of the client window as
184  * gravity point.
185  *
186  * Flag used when changing the geometry of a #WnckWindow. This is the gravity
187  * point to use as a reference for the new position.
188  *
189  * Since: 2.16
190  */
191 typedef enum
192 {
193   WNCK_WINDOW_GRAVITY_CURRENT   = 0,
194   WNCK_WINDOW_GRAVITY_NORTHWEST = 1,
195   WNCK_WINDOW_GRAVITY_NORTH     = 2,
196   WNCK_WINDOW_GRAVITY_NORTHEAST = 3,
197   WNCK_WINDOW_GRAVITY_WEST      = 4,
198   WNCK_WINDOW_GRAVITY_CENTER    = 5,
199   WNCK_WINDOW_GRAVITY_EAST      = 6,
200   WNCK_WINDOW_GRAVITY_SOUTHWEST = 7,
201   WNCK_WINDOW_GRAVITY_SOUTH     = 8,
202   WNCK_WINDOW_GRAVITY_SOUTHEAST = 9,
203   WNCK_WINDOW_GRAVITY_STATIC    = 10
204 } WnckWindowGravity;
205 
206 /**
207  * WnckWindowMoveResizeMask:
208  * @WNCK_WINDOW_CHANGE_X: X coordinate of the window should be changed.
209  * @WNCK_WINDOW_CHANGE_Y: Y coordinate of the window should be changed.
210  * @WNCK_WINDOW_CHANGE_WIDTH: width of the window should be changed.
211  * @WNCK_WINDOW_CHANGE_HEIGHT: height of the window should be changed.
212  *
213  * Flag used as a bitmask when changing the geometry of a #WnckWindow. This
214  * indicates which part of the geometry should be changed.
215  *
216  * Since: 2.16
217  */
218 typedef enum
219 {
220   WNCK_WINDOW_CHANGE_X      = 1 << 0,
221   WNCK_WINDOW_CHANGE_Y      = 1 << 1,
222   WNCK_WINDOW_CHANGE_WIDTH  = 1 << 2,
223   WNCK_WINDOW_CHANGE_HEIGHT = 1 << 3
224 } WnckWindowMoveResizeMask;
225 
226 #define WNCK_TYPE_WINDOW              (wnck_window_get_type ())
227 #define WNCK_WINDOW(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), WNCK_TYPE_WINDOW, WnckWindow))
228 #define WNCK_WINDOW_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), WNCK_TYPE_WINDOW, WnckWindowClass))
229 #define WNCK_IS_WINDOW(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), WNCK_TYPE_WINDOW))
230 #define WNCK_IS_WINDOW_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), WNCK_TYPE_WINDOW))
231 #define WNCK_WINDOW_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), WNCK_TYPE_WINDOW, WnckWindowClass))
232 
233 typedef struct _WnckWindowClass   WnckWindowClass;
234 typedef struct _WnckWindowPrivate WnckWindowPrivate;
235 
236 /**
237  * WnckWindow:
238  *
239  * The #WnckWindow struct contains only private fields and should not be
240  * directly accessed.
241  */
242 struct _WnckWindow
243 {
244   GObject parent_instance;
245 
246   WnckWindowPrivate *priv;
247 };
248 
249 struct _WnckWindowClass
250 {
251   GObjectClass parent_class;
252 
253   /* window name or icon name changed */
254   void (* name_changed) (WnckWindow *window);
255 
256   /* minimized, maximized, sticky, skip pager, skip task, shaded
257    * may have changed
258    */
259   void (* state_changed) (WnckWindow     *window,
260                           WnckWindowState changed_mask,
261                           WnckWindowState new_state);
262 
263   /* Changed workspace or pinned/unpinned state */
264   void (* workspace_changed) (WnckWindow *window);
265 
266   /* Changed icon */
267   void (* icon_changed)      (WnckWindow *window);
268 
269   /* Changed actions */
270   void (* actions_changed)   (WnckWindow       *window,
271                               WnckWindowActions changed_mask,
272                               WnckWindowActions new_actions);
273 
274   /* Changed size/position */
275   void (* geometry_changed)  (WnckWindow       *window);
276 
277   /* Changed class group/instance name */
278   void (* class_changed)     (WnckWindow       *window);
279 
280   /* Changed role */
281   void (* role_changed)      (WnckWindow       *window);
282 
283   void (* type_changed)      (WnckWindow       *window);
284 
285   /* Padding for future expansion */
286   void (* pad1) (void);
287 };
288 
289 GType wnck_window_get_type (void) G_GNUC_CONST;
290 
291 WnckWindow* wnck_window_get (gulong xwindow);
292 
293 WnckScreen* wnck_window_get_screen    (WnckWindow *window);
294 
295 gboolean    wnck_window_has_name      (WnckWindow *window);
296 const char* wnck_window_get_name      (WnckWindow *window);
297 gboolean    wnck_window_has_icon_name (WnckWindow *window);
298 const char* wnck_window_get_icon_name (WnckWindow *window);
299 
300 WnckApplication* wnck_window_get_application  (WnckWindow *window);
301 WnckWindow*      wnck_window_get_transient    (WnckWindow *window);
302 gulong           wnck_window_get_group_leader (WnckWindow *window);
303 gulong           wnck_window_get_xid          (WnckWindow *window);
304 
305 WnckClassGroup *wnck_window_get_class_group   (WnckWindow *window);
306 
307 const char* wnck_window_get_class_group_name    (WnckWindow *window);
308 const char* wnck_window_get_class_instance_name (WnckWindow *window);
309 
310 const char* wnck_window_get_session_id        (WnckWindow *window);
311 const char* wnck_window_get_session_id_utf8   (WnckWindow *window);
312 const char* wnck_window_get_role              (WnckWindow *window);
313 int         wnck_window_get_pid               (WnckWindow *window);
314 gint        wnck_window_get_sort_order        (WnckWindow *window);
315 void        wnck_window_set_sort_order        (WnckWindow *window,
316 						gint order);
317 
318 WnckWindowType wnck_window_get_window_type    (WnckWindow *window);
319 void           wnck_window_set_window_type    (WnckWindow *window,
320                                                WnckWindowType wintype);
321 
322 gboolean wnck_window_is_minimized              (WnckWindow *window);
323 gboolean wnck_window_is_maximized_horizontally (WnckWindow *window);
324 gboolean wnck_window_is_maximized_vertically   (WnckWindow *window);
325 gboolean wnck_window_is_maximized              (WnckWindow *window);
326 gboolean wnck_window_is_shaded                 (WnckWindow *window);
327 gboolean wnck_window_is_above                  (WnckWindow *window);
328 gboolean wnck_window_is_below                  (WnckWindow *window);
329 gboolean wnck_window_is_skip_pager             (WnckWindow *window);
330 gboolean wnck_window_is_skip_tasklist          (WnckWindow *window);
331 gboolean wnck_window_is_fullscreen             (WnckWindow *window);
332 gboolean wnck_window_is_sticky                 (WnckWindow *window);
333 gboolean wnck_window_needs_attention           (WnckWindow *window);
334 gboolean wnck_window_or_transient_needs_attention (WnckWindow *window);
335 
336 void wnck_window_set_skip_pager    (WnckWindow *window,
337                                     gboolean skip);
338 void wnck_window_set_skip_tasklist (WnckWindow *window,
339                                     gboolean skip);
340 void wnck_window_set_fullscreen (WnckWindow *window,
341                                  gboolean fullscreen);
342 
343 void wnck_window_close                   (WnckWindow *window,
344                                           guint32     timestamp);
345 void wnck_window_minimize                (WnckWindow *window);
346 void wnck_window_unminimize              (WnckWindow *window,
347                                           guint32     timestamp);
348 void wnck_window_maximize                (WnckWindow *window);
349 void wnck_window_unmaximize              (WnckWindow *window);
350 void wnck_window_maximize_horizontally   (WnckWindow *window);
351 void wnck_window_unmaximize_horizontally (WnckWindow *window);
352 void wnck_window_maximize_vertically     (WnckWindow *window);
353 void wnck_window_unmaximize_vertically   (WnckWindow *window);
354 void wnck_window_shade                   (WnckWindow *window);
355 void wnck_window_unshade                 (WnckWindow *window);
356 void wnck_window_make_above              (WnckWindow *window);
357 void wnck_window_unmake_above            (WnckWindow *window);
358 void wnck_window_make_below              (WnckWindow *window);
359 void wnck_window_unmake_below            (WnckWindow *window);
360 void wnck_window_stick                   (WnckWindow *window);
361 void wnck_window_unstick                 (WnckWindow *window);
362 void wnck_window_keyboard_move           (WnckWindow *window);
363 void wnck_window_keyboard_size           (WnckWindow *window);
364 
365 WnckWorkspace* wnck_window_get_workspace     (WnckWindow    *window);
366 void           wnck_window_move_to_workspace (WnckWindow    *window,
367                                               WnckWorkspace *space);
368 
369 /* pinned = on all workspaces */
370 gboolean wnck_window_is_pinned (WnckWindow *window);
371 void     wnck_window_pin       (WnckWindow *window);
372 void     wnck_window_unpin     (WnckWindow *window);
373 
374 void     wnck_window_activate  (WnckWindow *window,
375                                 guint32     timestamp);
376 gboolean wnck_window_is_active (WnckWindow *window);
377 gboolean wnck_window_is_most_recently_activated (WnckWindow *window);
378 void     wnck_window_activate_transient (WnckWindow *window,
379                                          guint32     timestamp);
380 gboolean wnck_window_transient_is_most_recently_activated (WnckWindow *window);
381 
382 GdkPixbuf* wnck_window_get_icon      (WnckWindow *window);
383 GdkPixbuf* wnck_window_get_mini_icon (WnckWindow *window);
384 
385 gboolean wnck_window_get_icon_is_fallback (WnckWindow *window);
386 
387 void wnck_window_set_icon_geometry        (WnckWindow *window,
388 					   int         x,
389 					   int         y,
390 					   int         width,
391 					   int         height);
392 
393 WnckWindowActions wnck_window_get_actions (WnckWindow *window);
394 WnckWindowState   wnck_window_get_state   (WnckWindow *window);
395 
396 void wnck_window_get_client_window_geometry (WnckWindow *window,
397                                              int        *xp,
398                                              int        *yp,
399                                              int        *widthp,
400                                              int        *heightp);
401 void wnck_window_get_geometry (WnckWindow *window,
402                                int        *xp,
403                                int        *yp,
404                                int        *widthp,
405                                int        *heightp);
406 void wnck_window_set_geometry (WnckWindow               *window,
407                                WnckWindowGravity         gravity,
408                                WnckWindowMoveResizeMask  geometry_mask,
409                                int                       x,
410                                int                       y,
411                                int                       width,
412                                int                       height);
413 
414 gboolean wnck_window_is_visible_on_workspace (WnckWindow    *window,
415                                               WnckWorkspace *workspace);
416 gboolean wnck_window_is_on_workspace         (WnckWindow    *window,
417                                               WnckWorkspace *workspace);
418 gboolean wnck_window_is_in_viewport          (WnckWindow    *window,
419                                               WnckWorkspace *workspace);
420 
421 G_END_DECLS
422 
423 #endif /* WNCK_WINDOW_H */
424