/[oroborus]/oroborus/src/hints.c
ViewVC logotype

Diff of /oroborus/src/hints.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.1.1 by dreamind, Thu May 23 19:55:44 2002 UTC revision 1.2 by dreamind, Thu May 30 13:57:51 2002 UTC
# Line 30  Line 30 
30  Atom wm_state, wm_change_state, wm_delete_window, wm_protocols;  Atom wm_state, wm_change_state, wm_delete_window, wm_protocols;
31  Atom motif_wm_hints;  Atom motif_wm_hints;
32  Atom win_hints, win_state, win_client_list, win_layer, win_workspace,  Atom win_hints, win_state, win_client_list, win_layer, win_workspace,
33      win_workspace_count, win_desktop_button_proxy, win_supporting_wm_check,    win_workspace_count, win_desktop_button_proxy, win_supporting_wm_check,
34      gnome_panel_desktop_area;    gnome_panel_desktop_area;
35    
36  void initICCCMHints(Display * dpy)  void
37    initICCCMHints (Display * dpy)
38  {  {
39  #ifdef DEBUG  #ifdef DEBUG
40      printf("entering initICCCMHints\n");    printf ("entering initICCCMHints\n");
41  #endif  #endif
42    
43      wm_state = XInternAtom(dpy, "WM_STATE", False);    wm_state = XInternAtom (dpy, "WM_STATE", False);
44      wm_change_state = XInternAtom(dpy, "WM_CHANGE_STATE", False);    wm_change_state = XInternAtom (dpy, "WM_CHANGE_STATE", False);
45      wm_delete_window = XInternAtom(dpy, "WM_DELETE_WINDOW", False);    wm_delete_window = XInternAtom (dpy, "WM_DELETE_WINDOW", False);
46      wm_protocols = XInternAtom(dpy, "WM_PROTOCOLS", False);    wm_protocols = XInternAtom (dpy, "WM_PROTOCOLS", False);
47      wm_window_type = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE", False);    wm_window_type = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE", False);
48  }  }
49    
50  long getWMState(Display * dpy, Window w)  long
51    getWMState (Display * dpy, Window w)
52  {  {
53      Atom real_type;    Atom real_type;
54      int real_format;    int real_format;
55      unsigned long items_read, items_left;    unsigned long items_read, items_left;
56      long *data = NULL, state = WithdrawnState;    long *data = NULL, state = WithdrawnState;
57    
58  #ifdef DEBUG  #ifdef DEBUG
59      printf("entering getWmState\n");    printf ("entering getWmState\n");
60  #endif  #endif
61    
62      if(XGetWindowProperty    if (XGetWindowProperty
63         (dpy, w, wm_state, 0L, 2L, False, wm_state, &real_type, &real_format,        (dpy, w, wm_state, 0L, 2L, False, wm_state, &real_type, &real_format,
64          &items_read, &items_left, (unsigned char **)&data) == Success &&         &items_read, &items_left, (unsigned char **) &data) == Success &&
65         items_read)        items_read)
66      {      {
67          state = *data;        state = *data;
68          XFree(data);        XFree (data);
69      }      }
70      return state;    return state;
71  }  }
72    
73  void setWMState(Display * dpy, Window w, long state)  void
74    setWMState (Display * dpy, Window w, long state)
75  {  {
76      CARD32 data[2];    CARD32 data[2];
77    
78  #ifdef DEBUG  #ifdef DEBUG
79      printf("entering setWmState\n");    printf ("entering setWmState\n");
80  #endif  #endif
81    
82      data[0] = state;    data[0] = state;
83      data[1] = None;    data[1] = None;
84    
85      XChangeProperty(dpy, w, wm_state, wm_state, 32, PropModeReplace,    XChangeProperty (dpy, w, wm_state, wm_state, 32, PropModeReplace,
86                      (unsigned char *)data, 2);                     (unsigned char *) data, 2);
87  }  }
88    
89  void initMotifHints(Display * dpy)  void
90    initMotifHints (Display * dpy)
91  {  {
92  #ifdef DEBUG  #ifdef DEBUG
93      printf("entering initMotifHints\n");    printf ("entering initMotifHints\n");
94  #endif  #endif
95    
96      motif_wm_hints = XInternAtom(dpy, "_MOTIF_WM_HINTS", False);    motif_wm_hints = XInternAtom (dpy, "_MOTIF_WM_HINTS", False);
97  }  }
98    
99  PropMwmHints *getMotifHints(Display * dpy, Window w)  PropMwmHints *
100    getMotifHints (Display * dpy, Window w)
101  {  {
102      Atom real_type;    Atom real_type;
103      int real_format;    int real_format;
104      unsigned long items_read, items_left;    unsigned long items_read, items_left;
105      PropMwmHints *data = NULL;    PropMwmHints *data = NULL;
106    
107  #ifdef DEBUG  #ifdef DEBUG
108      printf("entering getMotifHints\n");    printf ("entering getMotifHints\n");
109  #endif  #endif
110    
111      if(XGetWindowProperty    if (XGetWindowProperty
112         (dpy, w, motif_wm_hints, 0L, 20L, False, motif_wm_hints, &real_type,        (dpy, w, motif_wm_hints, 0L, 20L, False, motif_wm_hints, &real_type,
113          &real_format, &items_read, &items_left,         &real_format, &items_read, &items_left,
114          (unsigned char **)&data) == Success && items_read)         (unsigned char **) &data) == Success && items_read)
115          return data;      return data;
116      else    else
117          return NULL;      return NULL;
118  }  }
119    
120  void initGnomeHints(Display * dpy)  void
121    initGnomeHints (Display * dpy)
122  {  {
123      Window root;    Window root;
124    
125  #ifdef DEBUG  #ifdef DEBUG
126      printf("entering initGnomeHints\n");    printf ("entering initGnomeHints\n");
127  #endif  #endif
128    
129      root = XDefaultRootWindow(dpy);    root = XDefaultRootWindow (dpy);
130      win_hints = XInternAtom(dpy, "_WIN_HINTS", False);    win_hints = XInternAtom (dpy, "_WIN_HINTS", False);
131      win_state = XInternAtom(dpy, "_WIN_STATE", False);    win_state = XInternAtom (dpy, "_WIN_STATE", False);
132      win_client_list = XInternAtom(dpy, "_WIN_CLIENT_LIST", False);    win_client_list = XInternAtom (dpy, "_WIN_CLIENT_LIST", False);
133      win_layer = XInternAtom(dpy, "_WIN_LAYER", False);    win_layer = XInternAtom (dpy, "_WIN_LAYER", False);
134      win_workspace = XInternAtom(dpy, "_WIN_WORKSPACE", False);    win_workspace = XInternAtom (dpy, "_WIN_WORKSPACE", False);
135      win_workspace_count = XInternAtom(dpy, "_WIN_WORKSPACE_COUNT", False);    win_workspace_count = XInternAtom (dpy, "_WIN_WORKSPACE_COUNT", False);
136      win_desktop_button_proxy =    win_desktop_button_proxy =
137          XInternAtom(dpy, "_WIN_DESKTOP_BUTTON_PROXY", False);      XInternAtom (dpy, "_WIN_DESKTOP_BUTTON_PROXY", False);
138      win_supporting_wm_check =    win_supporting_wm_check =
139          XInternAtom(dpy, "_WIN_SUPPORTING_WM_CHECK", False);      XInternAtom (dpy, "_WIN_SUPPORTING_WM_CHECK", False);
140      gnome_panel_desktop_area =    gnome_panel_desktop_area =
141          XInternAtom(dpy, "GNOME_PANEL_DESKTOP_AREA", False);      XInternAtom (dpy, "GNOME_PANEL_DESKTOP_AREA", False);
142  }  }
143    
144  int getGnomeHint(Display * dpy, Window w, Atom a, long *value)  int
145    getGnomeHint (Display * dpy, Window w, Atom a, long *value)
146  {  {
147      Atom real_type;    Atom real_type;
148      int real_format, success = False;    int real_format, success = False;
149      unsigned long items_read, items_left;    unsigned long items_read, items_left;
150      long *data = NULL;    long *data = NULL;
151    
152  #ifdef DEBUG  #ifdef DEBUG
153      printf("entering getGnomeHint\n");    printf ("entering getGnomeHint\n");
154  #endif  #endif
155    
156      if(a == win_layer)    if (a == win_layer)
157          *value = WIN_LAYER_NORMAL;      *value = WIN_LAYER_NORMAL;
158      else    else
159          *value = 0;      *value = 0;
160    
161      if(XGetWindowProperty    if (XGetWindowProperty
162         (dpy, w, a, 0L, 1L, False, XA_CARDINAL, &real_type, &real_format,        (dpy, w, a, 0L, 1L, False, XA_CARDINAL, &real_type, &real_format,
163          &items_read, &items_left, (unsigned char **)&data) == Success &&         &items_read, &items_left, (unsigned char **) &data) == Success &&
164         items_read)        items_read)
165      {      {
166          *value = *data;        *value = *data;
167          success = True;        success = True;
168          XFree(data);        XFree (data);
169      }      }
170      return success;    return success;
171  }  }
172    
173  void setGnomeHint(Display * dpy, Window w, Atom a, long value)  void
174    setGnomeHint (Display * dpy, Window w, Atom a, long value)
175  {  {
176  #ifdef DEBUG  #ifdef DEBUG
177      printf("entering setGnomeHint\n");    printf ("entering setGnomeHint\n");
178  #endif  #endif
179    
180      XChangeProperty(dpy, w, a, XA_CARDINAL, 32, PropModeReplace,    XChangeProperty (dpy, w, a, XA_CARDINAL, 32, PropModeReplace,
181                      (unsigned char *)&value, 1);                     (unsigned char *) &value, 1);
182  }  }
183    
184  void getGnomeDesktopMargins(Display * dpy, CARD32 * margins)  void
185    getGnomeDesktopMargins (Display * dpy, CARD32 * margins)
186  {  {
187      Atom real_type;    Atom real_type;
188      int real_format;    int real_format;
189      unsigned long items_read, items_left;    unsigned long items_read, items_left;
190      CARD32 *data = NULL;    CARD32 *data = NULL;
191    
192  #ifdef DEBUG  #ifdef DEBUG
193      printf("entering getGnomeDesktopMargins\n");    printf ("entering getGnomeDesktopMargins\n");
194  #endif  #endif
195    
196      if(XGetWindowProperty    if (XGetWindowProperty
197         (dpy, XDefaultRootWindow(dpy), gnome_panel_desktop_area, 0L, 4L, False,        (dpy, XDefaultRootWindow (dpy), gnome_panel_desktop_area, 0L, 4L, False,
198          XA_CARDINAL, &real_type, &real_format, &items_read, &items_left,         XA_CARDINAL, &real_type, &real_format, &items_read, &items_left,
199          (unsigned char **)&data) == Success && items_read >= 4)         (unsigned char **) &data) == Success && items_read >= 4)
200      {      {
201          margins[0] = data[0];        margins[0] = data[0];
202          margins[1] = data[1];        margins[1] = data[1];
203          margins[2] = data[2];        margins[2] = data[2];
204          margins[3] = data[3];        margins[3] = data[3];
205          XFree(data);        XFree (data);
206      }      }
207      else    else
208      {      {
209          margins[0] = 0;        margins[0] = 0;
210          margins[1] = 0;        margins[1] = 0;
211          margins[2] = 0;        margins[2] = 0;
212          margins[3] = 0;        margins[3] = 0;
213      }      }
214  }  }
215    
216  int  int
217  typeDesktop(Display *dpy, Window w)  typeDesktop (Display * dpy, Window w)
218  {  {
219    unsigned long *data;    unsigned long *data;
220    int ret = 0;    int ret = 0;
221      
222  #ifdef DEBUG  #ifdef DEBUG
223    printf("entering typeDesktop\n");    printf ("entering typeDesktop\n");
224  #endif  #endif
225    
226    data = getPropData (dpy, w, wm_window_type, XA_ATOM);    data = getPropData (dpy, w, wm_window_type, XA_ATOM);
227    if (data)    if (data)
228      {      {
229        char *name;        char *name;
230        name = XGetAtomName(dpy, *data);        name = XGetAtomName (dpy, *data);
231  #ifdef DEBUG  #ifdef DEBUG
232        printf("%s\n",name);        printf ("%s\n", name);
233  #endif  #endif
234        if (name && strcmp(name,"_NET_WM_WINDOW_TYPE_DESKTOP") == 0)        if (name && strcmp (name, "_NET_WM_WINDOW_TYPE_DESKTOP") == 0)
235          ret = 1;          ret = 1;
236        XFree (data);        XFree (data);
237      }      }
# Line 231  typeDesktop(Display *dpy, Window w) Line 240  typeDesktop(Display *dpy, Window w)
240  }  }
241    
242  void *  void *
243  getPropData (Display *dpy,Window win, Atom prop, Atom type)  getPropData (Display * dpy, Window win, Atom prop, Atom type)
244  {  {
245    Atom type_ret;    Atom type_ret;
246    int format_ret;    int format_ret;
# Line 240  getPropData (Display *dpy,Window win, At Line 249  getPropData (Display *dpy,Window win, At
249    unsigned char *prop_data;    unsigned char *prop_data;
250    
251  #ifdef DEBUG  #ifdef DEBUG
252    printf("entering getPropData\n");    printf ("entering getPropData\n");
253  #endif  #endif
254    prop_data = 0;    prop_data = 0;
255    
# Line 250  getPropData (Display *dpy,Window win, At Line 259  getPropData (Display *dpy,Window win, At
259    
260    return prop_data;    return prop_data;
261  }  }
   

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26