1 /* Copyright (C) 1999 Rafal Wierzbicki <rafal@mcss.mcmaster.ca>
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16  *
17  * $Id: Gnome.h,v 1.2 2002/08/04 06:48:07 sashav Exp $
18  */
19 
20 #define WIN_HINTS_SKIP_FOCUS      (1<<0) /*"alt-tab" skips this win*/
21 #define WIN_HINTS_SKIP_WINLIST    (1<<1) /*do not show in window list*/
22 #define WIN_HINTS_SKIP_TASKBAR    (1<<2) /*do not show on taskbar*/
23 #define WIN_HINTS_GROUP_TRANSIENT (1<<3) /*Reserved - definition is unclear*/
24 #define WIN_HINTS_FOCUS_ON_CLICK  (1<<4) /*app only accepts focus if clicked*/
25 #define WIN_HINTS_DO_NOT_COVER    (1<<5) /*attempt to not cover this window */
26 
27 #define WIN_STATE_STICKY          (1<<0) /*everyone knows sticky*/
28 #define WIN_STATE_MINIMIZED       (1<<1) /*Reserved - definition is unclear*/
29 #define WIN_STATE_MAXIMIZED_VERT  (1<<2) /*window in maximized V state*/
30 #define WIN_STATE_MAXIMIZED_HORIZ (1<<3) /*window in maximized H state*/
31 #define WIN_STATE_HIDDEN          (1<<4) /*not on taskbar but window visible*/
32 #define WIN_STATE_SHADED          (1<<5) /*shaded (MacOS / Afterstep style)*/
33 #define WIN_STATE_HID_WORKSPACE   (1<<6) /*not on current desktop*/
34 #define WIN_STATE_HID_TRANSIENT   (1<<7) /*owner of transient is hidden*/
35 #define WIN_STATE_FIXED_POSITION  (1<<8) /*window is fixed in position even*/
36 #define WIN_STATE_ARRANGE_IGNORE  (1<<9) /*ignore for auto arranging*/
37 
38 /*
39 #define WIN_LAYER_DESKTOP    0
40 #define WIN_LAYER_BELOW      2
41 #define WIN_LAYER_NORMAL     4
42 #define WIN_LAYER_ONTOP      6
43 #define WIN_LAYER_DOCK       8
44 #define WIN_LAYER_ABOVE_DOCK 10
45 #define WIN_LAYER_MENU       12
46 */
47 
48 /* flags for the window layer */
49 typedef enum
50 {
51   WIN_APP_STATE_NONE,
52   WIN_APP_STATE_ACTIVE1,
53   WIN_APP_STATE_ACTIVE2,
54   WIN_APP_STATE_ERROR1,
55   WIN_APP_STATE_ERROR2,
56   WIN_APP_STATE_FATAL_ERROR1,
57   WIN_APP_STATE_FATAL_ERROR2,
58   WIN_APP_STATE_IDLE1,
59   WIN_APP_STATE_IDLE2,
60   WIN_APP_STATE_WAITING1,
61   WIN_APP_STATE_WAITING2,
62   WIN_APP_STATE_WORKING1,
63   WIN_APP_STATE_WORKING2,
64   WIN_APP_STATE_NEED_USER_INPUT1,
65   WIN_APP_STATE_NEED_USER_INPUT2,
66   WIN_APP_STATE_STRUGGLING1,
67   WIN_APP_STATE_STRUGGLING2,
68   WIN_APP_STATE_DISK_TRAFFIC1,
69   WIN_APP_STATE_DISK_TRAFFIC2,
70   WIN_APP_STATE_NETWORK_TRAFFIC1,
71   WIN_APP_STATE_NETWORK_TRAFFIC2,
72   WIN_APP_STATE_OVERLOADED1,
73   WIN_APP_STATE_OVERLOADED2,
74   WIN_APP_STATE_PERCENT000_1,
75   WIN_APP_STATE_PERCENT000_2,
76   WIN_APP_STATE_PERCENT010_1,
77   WIN_APP_STATE_PERCENT010_2,
78   WIN_APP_STATE_PERCENT020_1,
79   WIN_APP_STATE_PERCENT020_2,
80   WIN_APP_STATE_PERCENT030_1,
81   WIN_APP_STATE_PERCENT030_2,
82   WIN_APP_STATE_PERCENT040_1,
83   WIN_APP_STATE_PERCENT040_2,
84   WIN_APP_STATE_PERCENT050_1,
85   WIN_APP_STATE_PERCENT050_2,
86   WIN_APP_STATE_PERCENT060_1,
87   WIN_APP_STATE_PERCENT060_2,
88   WIN_APP_STATE_PERCENT070_1,
89   WIN_APP_STATE_PERCENT070_2,
90   WIN_APP_STATE_PERCENT080_1,
91   WIN_APP_STATE_PERCENT080_2,
92   WIN_APP_STATE_PERCENT090_1,
93   WIN_APP_STATE_PERCENT090_2,
94   WIN_APP_STATE_PERCENT100_1,
95   WIN_APP_STATE_PERCENT100_2
96 } GnomeWinAppState;
97 
98 /* masks for AS pipe */
99 #define  mask_reg (M_ADD_WINDOW | M_CONFIGURE_WINDOW | M_DESTROY_WINDOW | M_TOGGLE_PAGING | M_NEW_PAGE | M_NEW_DESK | M_END_WINDOWLIST)
100 
101 typedef struct node
102 {
103     long id;
104     long flags;
105     int workspace;
106     int area_x;
107     int area_y;
108     int old_area_x;
109     int old_area_y;
110     struct node *previous;
111     struct node *next;
112 }list_item;
113 
114 typedef struct
115 {
116     list_item *first, *last;
117 }s_list;
118 
119 int s_list_remove_by_data (s_list *list, long id);
120 list_item * s_list_find_by_data (s_list *list, long id);
121 
122 static void gnome_compliance_init ();
123 static void gnome_get_prop_workspace (Window id);
124 
125 static int list_configure (unsigned long *body);
126 static int list_add_window (unsigned long *body);
127 static int list_window_name  (unsigned long *body);
128 static int list_icon_name (unsigned long *body);
129 static int list_destroy_window (unsigned long *body);
130 static int list_end ();
131 static int list_iconify (unsigned long *body);
132 static int list_deiconify (unsigned long *body);
133 static int list_desk_change (unsigned long *body);
134 static int list_page_change (unsigned long *body);
135 
136 static void read_as_socket ();
137 
138 static Atom _XA_WIN_SUPPORTING_WM_CHECK;
139 static Atom _XA_WIN_PROTOCOLS;
140 static Atom _XA_WIN_LAYER;
141 static Atom _XA_WIN_STATE;
142 static Atom _XA_WIN_HINTS;
143 static Atom _XA_WIN_APP_STATE;
144 /*static Atom _XA_WIN_EXPANDED_SIZE;*/
145 static Atom _XA_WIN_ICONS;
146 static Atom _XA_WIN_WORKSPACE;
147 static Atom _XA_WIN_WORKSPACE_COUNT;
148 static Atom _XA_WIN_WORKSPACE_NAMES;
149 static Atom _XA_WIN_CLIENT_LIST;
150 static Atom _XA_WIN_DESKTOP_BUTTON_PROXY;
151 static Atom _XA_WIN_AREA_COUNT;
152 static Atom _XA_WIN_AREA;
153 
154 char *MyName;
155 Display *dpy;
156 int screen;
157 static int fd[2], x_fd, fd_width;
158 
159 static Window gnome_win, root_win;
160