chiark / gitweb /
Imported Upstream version 1.0.0
[e16] / src / ewins.h
1 /*
2  * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
3  * Copyright (C) 2004-2009 Kim Woelders
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy
6  * of this software and associated documentation files (the "Software"), to
7  * deal in the Software without restriction, including without limitation the
8  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9  * sell copies of the Software, and to permit persons to whom the Software is
10  * furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies of the Software, its documentation and marketing & publicity
14  * materials, and acknowledgment shall be given in the documentation, materials
15  * and software packages that this Software was used.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20  * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 #ifndef _EWIN_H_
25 #define _EWIN_H_
26
27 #include "eobj.h"
28 #include "etypes.h"
29 #include "xwin.h"
30
31 /* Window operation sources */
32 #define OPSRC_NA        0
33 #define OPSRC_APP       1
34 #define OPSRC_USER      2
35 #define OPSRC_WM        3
36
37 typedef union {
38    unsigned char       all:8;
39    struct {
40       unsigned char       rsvd:2;
41       unsigned char       border:1;     /* W   */
42       unsigned char       close:1;      /*  AU */
43       unsigned char       focus:1;      /* WA  */
44       unsigned char       iconify:1;    /* W U */
45       unsigned char       move:1;       /*  AU */
46       unsigned char       size:1;       /*  AU */
47    } b;
48 } EWinInhibit;
49
50 #define EwinInhGetApp(ewin, item)      (ewin->inh_app.b.item)
51 #define EwinInhSetApp(ewin, item, on)  ewin->inh_app.b.item = (on)
52 #define EwinInhGetUser(ewin, item)     (ewin->inh_user.b.item)
53 #define EwinInhSetUser(ewin, item, on) ewin->inh_user.b.item = (on)
54 #define EwinInhGetWM(ewin, item)       (ewin->inh_wm.b.item)
55 #define EwinInhSetWM(ewin, item, on)   ewin->inh_wm.b.item = (on)
56
57 typedef struct {
58    void                (*Init) (EWin * ewin);
59    void                (*Layout) (EWin * ewin, int *px, int *py, int *pw,
60                                   int *ph);
61    void                (*MoveResize) (EWin * ewin, int resize);
62    void                (*Close) (EWin * ewin);
63 } EWinOps;
64
65 struct _ewin {
66    EObj                o;
67    char                type;
68    Win                 win_container;
69
70    const Border       *border;
71    const Border       *normal_border;
72    EWinBit            *bits;
73
74    struct {
75       Win                 win;
76       int                 x, y, w, h, bw;
77       Colormap            cmap;
78       long                event_mask;
79    } client;
80
81    struct {
82       char                state;
83       char                visibility;
84       char                shaped;
85       char                shaded;
86
87       unsigned            identified:1;
88       unsigned            placed:1;
89       unsigned            iconified:1;
90       unsigned            docked:1;
91
92       unsigned            click_grab_isset:1;
93       unsigned            maximized_horz:1;
94       unsigned            maximized_vert:1;
95       unsigned            fullscreen:1;
96
97       unsigned            active:1;
98       unsigned            modal:1;
99       unsigned            attention:1;
100
101       unsigned            showingdesk:1;        /* Iconified by show desktop */
102       unsigned            animated:1;
103       unsigned            moving:1;
104       unsigned            resizing:1;
105       unsigned            show_coords:1;
106       unsigned            maximizing:1;
107       unsigned            shading:1;
108       unsigned            in_action:1;
109
110       /* Derived state flags. Change only in EwinStateUpdate() */
111       unsigned            no_border:1;
112       unsigned            donthide:1;   /* Don't hide on show desktop */
113
114       unsigned            inhibit_move:1;
115       unsigned            inhibit_resize:1;
116       unsigned            inhibit_iconify:1;
117       unsigned            inhibit_shade:1;
118       unsigned            inhibit_stick:1;
119       unsigned            inhibit_max_hor:1;
120       unsigned            inhibit_max_ver:1;
121       unsigned            inhibit_fullscreeen:1;
122       unsigned            inhibit_change_desk:1;
123       unsigned            inhibit_close:1;
124       unsigned            inhibit_stacking:1;
125
126       unsigned            inhibit_actions:1;
127       unsigned            inhibit_focus:1;
128    } state;
129    struct {
130       /* User config */
131       unsigned int        focused_opacity;
132       unsigned            never_use_area:1;
133       unsigned            ignorearrange:1;
134       unsigned            skip_ext_task:1;
135       unsigned            skip_ext_pager:1;
136       unsigned            skip_focuslist:1;
137       unsigned            skip_winlist:1;
138       unsigned            focusclick:1; /* Click to focus */
139       unsigned            no_button_grabs:1;
140       unsigned            autoshade:1;  /* Autoshade on mouse in/out */
141       unsigned            no_argb:1;    /* Do not use ARGB frame */
142
143       /* Derived from other properties */
144       unsigned            no_border:1;  /* Never apply border (MWM/netwm type) */
145       unsigned            no_resize_h:1;        /* ICCCM */
146       unsigned            no_resize_v:1;        /* ICCCM */
147
148       /* Internal */
149       unsigned            autosave:1;
150       unsigned            donthide:1;   /* Don't hide on show desktop */
151       unsigned            vroot:1;      /* Virtual root window */
152       unsigned            no_actions:1;
153       unsigned            focus_when_mapped:1;
154    } props;
155    EWinInhibit         inh_app;
156    EWinInhibit         inh_user;
157    EWinInhibit         inh_wm;
158    struct {
159       char               *wm_icon_name;
160       char               *wm_role;
161       char               *wm_command;
162       char               *wm_machine;
163       /* WM_HINTS */
164       char                need_input;
165       char                start_iconified;
166       Pixmap              icon_pmap, icon_mask;
167       Window              icon_win;
168       Window              group;
169       char                urgency;
170       /* WM_PROTOCOLS */
171       char                take_focus;
172       char                delete_window;
173       /* WM_TRANSIENT_FOR */
174       signed char         transient;
175       Window              transient_for;        /* We are a transient for ... */
176       int                 transient_count;      /* We have <N> transients */
177       /* WM_CLIENT_LEADER */
178       Window              client_leader;
179
180       /* WM_NORMAL_HINTS */
181       int                 width_min, width_max;
182       int                 height_min, height_max;
183       int                 base_w, base_h;
184       int                 w_inc, h_inc;
185       int                 grav;
186       double              aspect_min, aspect_max;
187
188       char                is_group_leader;
189    } icccm;
190    struct {
191       unsigned            valid:1;
192       unsigned            decor_border:1;
193       unsigned            decor_resizeh:1;
194       unsigned            decor_title:1;
195       unsigned            decor_menu:1;
196       unsigned            decor_minimize:1;
197       unsigned            decor_maximize:1;
198       unsigned            func_resize:1;
199       unsigned            func_move:1;
200       unsigned            func_minimize:1;
201       unsigned            func_maximize:1;
202       unsigned            func_close:1;
203    } mwm;
204    struct {
205       char               *wm_name;
206       char               *wm_icon_name;
207       unsigned int       *wm_icon, wm_icon_len;
208       unsigned int        opacity;
209 #if USE_XSYNC
210       char                sync_request_enable;
211       XID                 sync_request_counter;
212       long long           sync_request_count;
213 #endif
214       union {
215          unsigned char       all;
216          struct {
217             unsigned            desktop:1;
218             unsigned            dock:1;
219             unsigned            toolbar:1;
220             unsigned            menu:1;
221             unsigned            utility:1;
222             unsigned            splash:1;
223             unsigned            dialog:1;
224             unsigned            normal:1;
225          } b;
226       } type;
227    } ewmh;
228    struct {
229       signed char         gravity;
230       int                 ax, ay;       /* Current placed area */
231       int                 gx, gy;       /* Distance to edge given by gravity */
232    } place;
233    struct {
234       int                 left, right, top, bottom;
235    } strut;
236    struct {
237       char                shape;
238       char                border;
239    } update;
240
241    int                 num_groups;
242    Group             **groups;
243    int                 area_x, area_y;
244    char               *session_id;
245    PmapMask            mini_pmm;
246    int                 mini_w, mini_h;
247
248    int                 shape_x, shape_y, shape_w, shape_h;
249    int                 req_x, req_y;
250
251    Snapshot           *snap;
252    int                 head;    /* Unused? */
253
254    int                 vx, vy;  /* Position in virtual root */
255    struct {                     /* Saved state before maximization */
256       int                 x, y; /* Position */
257       int                 w, h; /* Size */
258    } save_max;
259    struct {                     /* Saved state before fullscreen */
260       int                 x, y; /* Position */
261       int                 w, h; /* Size */
262       int                 layer;        /* Layer */
263    } save_fs;
264
265    void               *data;    /* Data hook for internal windows */
266    const EWinOps      *ops;
267
268    Timer              *timer;   /* Autoshade timer */
269 };
270
271 #define EWIN_STATE_NEW          0       /* New */
272 #define EWIN_STATE_STARTUP      1       /* New - during startup */
273 #define EWIN_STATE_WITHDRAWN    2
274 #define EWIN_STATE_ICONIC       3
275 #define EWIN_STATE_MAPPED       4
276
277 #define EWIN_TYPE_NORMAL        0x00
278 #define EWIN_TYPE_DIALOG        0x01
279 #define EWIN_TYPE_MENU          0x02
280 #define EWIN_TYPE_ICONBOX       0x04
281 #define EWIN_TYPE_PAGER         0x08
282 #define EWIN_TYPE_MISC          0x10
283
284 #define EWIN_GRAVITY_NW         0
285 #define EWIN_GRAVITY_NE         1
286 #define EWIN_GRAVITY_SW         2
287 #define EWIN_GRAVITY_SE         3
288
289 #define EwinGetDesk(ewin)               EoGetDesk(ewin)
290
291 #define EwinIsMapped(ewin)              ((ewin)->state.state >= EWIN_STATE_MAPPED)
292 #define EwinIsInternal(ewin)            ((ewin)->type != EWIN_TYPE_NORMAL)
293 #define EwinIsTransientChild(ewin)      ((ewin)->icccm.transient > 0)
294 #define EwinIsTransient(ewin)           ((ewin)->icccm.transient != 0)
295 #define EwinGetTransientFor(ewin)       ((ewin)->icccm.transient_for)
296 #define EwinGetTransientCount(ewin)     ((ewin)->icccm.transient_count)
297 #define EwinIsWindowGroupLeader(ewin)   ((ewin)->icccm.is_group_leader)
298 #define EwinGetWindowGroup(ewin)        ((ewin)->icccm.group)
299
300 #define EwinGetClientWin(ewin)          ((ewin)->client.win)
301 #define EwinGetContainerWin(ewin)       ((ewin)->win_container)
302
303 #define EwinGetIcccmName(ewin)          EoGetName(ewin)
304 #define EwinGetIcccmCName(ewin)         EoGetCName(ewin)
305 #define EwinGetIcccmClass(ewin)         EoGetClass(ewin)
306
307 /* arrange.c */
308 #define ARRANGE_VERBATIM    0
309 #define ARRANGE_BY_SIZE     1
310 #define ARRANGE_BY_POSITION 2
311
312 void                SnapEwin(EWin * ewin, int dx, int dy, int *new_dx,
313                              int *new_dy);
314 void                ArrangeEwin(EWin * ewin);
315 void                ArrangeEwinCentered(EWin * ewin);
316 void                ArrangeEwinXY(EWin * ewin, int *px, int *py);
317 void                ArrangeEwinCenteredXY(EWin * ewin, int *px, int *py);
318
319 void                ArrangeEwins(const char *params);
320
321 /* coords.c */
322 void                CoordsShow(EWin * ewin);
323 void                CoordsShowOpacity(EWin * ewin);
324 void                CoordsHide(void);
325
326 /* dock.c */
327 void                DockIt(EWin * ewin);
328
329 /* draw.c */
330 void                DrawEwinShape(EWin * ewin, int md, int x, int y, int w,
331                                   int h, int firstlast, int seqno);
332
333 /* ewins.c */
334 #define EWIN_CHANGE_NAME        (1<<0)
335 #define EWIN_CHANGE_ICON_NAME   (1<<1)
336 #define EWIN_CHANGE_ICON_PMAP   (1<<2)
337 #define EWIN_CHANGE_DESKTOP     (1<<3)
338 #define EWIN_CHANGE_LAYER       (1<<4)
339 #define EWIN_CHANGE_OPACITY     (1<<5)
340 #define EWIN_CHANGE_ATTENTION   (1<<6)
341
342 Window              EwinGetClientXwin(const EWin * ewin);
343 Window              EwinGetContainerXwin(const EWin * ewin);
344
345 void                EwinShapeSet(EWin * ewin);
346 void                EwinRaise(EWin * ewin);
347 void                EwinLower(EWin * ewin);
348 void                EwinShow(EWin * ewin);
349 void                EwinHide(EWin * ewin);
350 void                EwinKill(EWin * ewin);
351 void                DetermineEwinFloat(EWin * ewin, int dx, int dy);
352 EWin               *GetEwinPointerInClient(void);
353 EWin               *GetFocusEwin(void);
354 EWin               *GetContextEwin(void);
355 void                SetContextEwin(EWin * ewin);
356 void                EwinGetPosition(const EWin * ewin, int x, int y, int grav,
357                                     int *px, int *py);
358 void                EwinUpdateShapeInfo(EWin * ewin);
359 void                EwinPropagateShapes(EWin * ewin);
360 void                EwinStateUpdate(EWin * ewin);
361 EWin               *AddInternalToFamily(Win win, const char *bname, int type,
362                                         const EWinOps * ops, void *ptr);
363 void                EwinReparent(EWin * ewin, Win parent);
364 void                EwinSetTitle(EWin * ewin, const char *title);
365 void                EwinSetClass(EWin * ewin, const char *name,
366                                  const char *clss);
367 const char         *EwinGetTitle(const EWin * ewin);
368 const char         *EwinGetIconName(const EWin * ewin);
369 const char         *EwinBorderGetName(const EWin * ewin);
370 void                EwinBorderGetSize(const EWin * ewin, int *bl, int *br,
371                                       int *bt, int *bb);
372 void                EwinBorderUpdateState(EWin * ewin);
373 int                 EwinIsOnScreen(const EWin * ewin);
374 void                EwinRememberPositionSet(EWin * ewin);
375 void                EwinRememberPositionGet(EWin * ewin, Desk * dsk,
376                                             int *px, int *py);
377 void                EwinSetPlacementGravity(EWin * ewin, int x, int y);
378 void                EwinReposition(EWin * ewin);
379 void                EwinFlagsEncode(const EWin * ewin, unsigned int *flags);
380 void                EwinFlagsDecode(EWin * ewin, const unsigned int *flags);
381 void                EwinUpdateOpacity(EWin * ewin);
382
383 void                EwinChange(EWin * ewin, unsigned int flag);
384
385 void                EwinWarpTo(EWin * ewin);
386
387 EWin              **EwinListTransients(const EWin * ewin, int *num, int group);
388 EWin              **EwinListTransientFor(const EWin * ewin, int *num);
389
390 void                EwinsManage(void);
391 void                EwinsSetFree(void);
392 void                EwinsShowDesktop(int on);
393 void                EwinsMoveStickyToDesk(Desk * d);
394
395 /* ewin-ops.c */
396 void                SlideEwinTo(EWin * ewin, int fx, int fy, int tx, int ty,
397                                 int speed, int mode);
398 void                SlideEwinsTo(EWin ** ewin, int *fx, int *fy, int *tx,
399                                  int *ty, int num_wins, int speed, int mode);
400 void                EwinMove(EWin * ewin, int x, int y);
401 void                EwinResize(EWin * ewin, int w, int h);
402 void                EwinMoveResize(EWin * ewin, int x, int y, int w, int h);
403 void                EwinMoveResizeWithGravity(EWin * ewin, int x, int y, int w,
404                                               int h, int grav);
405 void                EwinMoveToDesktop(EWin * ewin, Desk * d);
406 void                EwinMoveToDesktopAt(EWin * ewin, Desk * d, int x, int y);
407 void                EwinIconify(EWin * ewin);
408 void                EwinAlone(EWin * ewin);
409 void                EwinDeIconify(EWin * ewin);
410 void                EwinInstantShade(EWin * ewin, int force);
411 void                EwinInstantUnShade(EWin * ewin);
412 void                EwinShade(EWin * ewin);
413 void                EwinUnShade(EWin * ewin);
414 void                EwinMoveToArea(EWin * ewin, int ax, int ay);
415
416 void                EwinOpMove(EWin * ewin, int source, int x, int y);
417 void                EwinOpResize(EWin * ewin, int source, int w, int h);
418 void                EwinOpMoveResize(EWin * ewin, int source, int x, int y,
419                                      int w, int h);
420 void                EwinOpMoveToDesktopAt(EWin * ewin, int source, Desk * dsk,
421                                           int x, int y);
422 void                EwinOpFloatAt(EWin * ewin, int source, int x, int y);
423 void                EwinOpUnfloatAt(EWin * ewin, int source, Desk * d,
424                                     int x, int y);
425 void                EwinOpClose(EWin * ewin, int source);
426 void                EwinOpActivate(EWin * ewin, int source, int raise);
427 void                EwinOpKill(EWin * ewin, int source);
428 void                EwinOpRaise(EWin * ewin, int source);
429 void                EwinOpLower(EWin * ewin, int source);
430 void                EwinOpStick(EWin * ewin, int source, int on);
431 void                EwinOpSkipLists(EWin * ewin, int source, int skip);
432 void                EwinOpIconify(EWin * ewin, int source, int on);
433 void                EwinOpShade(EWin * ewin, int source, int on);
434 void                EwinOpSetLayer(EWin * ewin, int source, int layer);
435 void                EwinOpSetBorder(EWin * ewin, int source, const char *name);
436 void                EwinOpSetOpacity(EWin * ewin, int source, int opacity);
437 void                EwinOpSetFocusedOpacity(EWin * ewin, int source,
438                                             int opacity);
439 void                EwinOpMoveToDesk(EWin * ewin, int source, Desk * dsk,
440                                      int inc);
441 void                EwinOpFullscreen(EWin * ewin, int source, int on);
442
443 /* finders.c */
444 EWin               *EwinFindByPtr(const EWin * ewin);
445 EWin               *EwinFindByClient(Window win);
446 EWin               *EwinFindByChildren(Window win);
447 EWin              **EwinsFindByExpr(const char *match, int *pnum, int *pflags);
448 EWin               *EwinFindByExpr(const char *match);
449
450 /* icccm.c (for now) */
451 #if USE_XSYNC
452 int                 EwinSyncRequestSend(EWin * ewin);
453 void                EwinSyncRequestWait(EWin * ewin);
454 #endif
455
456 /* moveresize.c */
457 int                 ActionMoveStart(EWin * ewin, int kbd, int constrained,
458                                     int nogroup);
459 int                 ActionResizeStart(EWin * ewin, int kbd, int hv);
460
461 int                 ActionsSuspend(void);
462 int                 ActionsResume(void);
463 void                ActionsHandleKey(unsigned int key);
464 void                ActionsHandleMotion(void);
465 int                 ActionsEnd(EWin * ewin);
466
467 /* size.c */
468 void                MaxSizeHV(EWin * ewin, const char *resize_type,
469                               int hor, int ver);
470
471 /* stacking.c */
472 EWin               *const *EwinListStackGet(int *num);
473 EWin               *const *EwinListFocusGet(int *num);
474 EWin               *const *EwinListGetForDesk(int *num, Desk * d);
475 EWin               *const *EwinListOrderGet(int *num);
476 EWin               *EwinListStackGetTop(void);
477 int                 EwinListStackIsRaised(const EWin * ewin);
478
479 #define EwinListGetAll EwinListStackGet
480
481 /* zoom.c */
482 EWin               *GetZoomEWin(void);
483 void                ReZoom(EWin * ewin);
484 char                InZoom(void);
485 char                CanZoom(void);
486 void                ZoomInit(void);
487 void                Zoom(EWin * ewin);
488
489 #endif /* _EWIN_H_ */