2 * WindowMaker external notification support
4 * Copyright (c) 1998 Peter Bentley (pete@sorted.org)
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
28 #include <X11/Xutil.h>
29 #include <X11/Xproto.h>
31 #include "WindowMaker.h"
35 #include "properties.h"
40 extern Atom _XA_WINDOWMAKER_NOTIFY
;
42 static LinkedList
*wNotifyWindows
=NULL
;
44 typedef struct WNotifyClient
46 Window not_win
; /* Id of window to send notify events to */
47 int not_mask
; /* Mask of desired notifications */
51 void wNotify( int id
, int a1
, int a2
)
56 void wNotifyWin( int id
, WWindow
*wwin
)
61 int count
= 0, mask
= WMN_ID_TO_MASK( id
);
63 event
.xclient
.type
= ClientMessage
;
64 event
.xclient
.message_type
= _XA_WINDOWMAKER_NOTIFY
;
65 event
.xclient
.format
= 32;
66 event
.xclient
.display
= dpy
;
67 event
.xclient
.data
.l
[0] = id
;
69 event
.xclient
.data
.l
[1] = wwin
->client_win
; /* XXX */
71 event
.xclient
.data
.l
[1] = 0;
72 event
.xclient
.data
.l
[2] = 0;
73 event
.xclient
.data
.l
[3] = 0;
75 for( list
= wNotifyWindows
; list
; list
= list
->tail
)
78 if( clnt
->not_mask
& mask
)
81 printf( "Send event %d to 0x%x\n", id
, (int) clnt
->not_win
);
83 event
.xclient
.window
= clnt
->not_win
;
84 XSendEvent(dpy
, clnt
->not_win
, False
, NoEventMask
, &event
);
93 int wNotifySet(Window window
)
98 if( PropGetNotifyMask( window
, &mask
)) {
99 wNotifyClear( window
); /* Remove any current mask */
101 printf( "Setting notify mask for window 0x%x to 0x%02x\n",
102 (int) window
, mask
);
104 clnt
= wmalloc( sizeof( WNotifyClient
));
107 clnt
->not_win
= window
;
108 clnt
->not_mask
= mask
;
109 wNotifyWindows
= list_cons( clnt
, wNotifyWindows
);
116 int wNotifyClear(Window window
)
121 for( list
= wNotifyWindows
; list
; list
= list
->tail
)
124 if( clnt
->not_win
== window
)
127 printf( "Clearing notify mask for window 0x%x (was 0x%02x)\n",
128 (int) clnt
->not_win
, clnt
->not_mask
);
130 wNotifyWindows
= list_remove_elem( wNotifyWindows
, clnt
);
139 #endif /* WMNOTIFY */