1 /* kwm.c-- stuff for support for kwm hints
3 * Window Maker window manager
5 * Copyright (c) 1998, 1999 Alfredo K. Kojima
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
28 * kfm icon selection from krootbgwm
30 * kwm.h function/method Notes
31 *----------------------------------------------------------------------------
32 * setUnsavedDataHint() currently, only gives visual clue that
33 * there is unsaved data (broken X close button)
35 * setIcon() std X thing...
39 * setWmCommand() std X thing
43 * isKWMInitialized() not trustworthy
44 * activeWindow() dunno it's use, but since it's easy to
45 * implement it won't hurt to support
47 * (set/get)WindowRegion()
48 * (set)numberOfDesktops() KDE limits to 32, but wmaker is virtually
49 * unlimited. May raise some incompatibility
50 * in badly written KDE modules?
51 * (set/get)DesktopName()
52 * sendKWMCommand() also does the message relay thing
58 * moveToDesktop() WARNING: evil mechanism
59 * setGeometryRestore() WARNING: evil mechanism
60 * setMaximize() woo hoo! wanna race?
61 * setIconify() BAH!: why reinvent the f'ing wheel!?
64 * setGeometry() std X thing
70 * prepareForSwallowing() std X thing
71 * doNotManage() klugy thing...
72 * getBlablablaString()
73 * setKWMDockModule() maybe we can make the Dock behave as the KDE
74 * dock, but must figure where to show the windows
77 * Unsupported stuff (superfluous/not-essential/nonsense):
78 * =======================================================
84 * registerSoundEvent()
85 * unregisterSoundEvent()
88 * geometry() kde lib code makes it unnecessary
94 * These are clientmessage-type messages specific to Window Maker:
95 * wmaker:info - show info panel
96 * wmaker:legal - show legal panel
97 * wmaker:arrangeIcons - arrange icons
98 * wmaker:showAll - show all windows
99 * wmaker:hideOthers - hide others
100 * wmaker:restart - restart wmaker
101 * wmaker:exit - exit wmaker
106 * different WORKAREA for each workspace
114 #include <X11/Xlib.h>
115 #include <X11/Xutil.h>
116 #include <X11/Xatom.h>
123 #include <sys/types.h>
124 #include <sys/socket.h>
129 #include "WindowMaker.h"
133 #include "framewin.h"
135 #include "properties.h"
140 #include "workspace.h"
142 #include "stacking.h"
148 /******* Global ******/
150 extern Time LastFocusChange
;
151 extern Time LastTimestamp
;
154 extern Atom _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
;
155 extern Atom _XA_WM_DELETE_WINDOW
;
159 static Atom _XA_KWM_COMMAND
= 0;
160 static Atom _XA_KWM_ACTIVATE_WINDOW
= 0;
161 static Atom _XA_KWM_ACTIVE_WINDOW
= 0;
162 static Atom _XA_KWM_DO_NOT_MANAGE
= 0;
163 static Atom _XA_KWM_DOCKWINDOW
= 0;
164 static Atom _XA_KWM_RUNNING
= 0;
166 static Atom _XA_KWM_MODULE
= 0;
168 static Atom _XA_KWM_MODULE_INIT
= 0;
169 static Atom _XA_KWM_MODULE_INITIALIZED
= 0;
170 static Atom _XA_KWM_MODULE_DESKTOP_CHANGE
= 0;
171 static Atom _XA_KWM_MODULE_DESKTOP_NAME_CHANGE
= 0;
172 static Atom _XA_KWM_MODULE_DESKTOP_NUMBER_CHANGE
= 0;
173 static Atom _XA_KWM_MODULE_WIN_ADD
= 0;
174 static Atom _XA_KWM_MODULE_WIN_REMOVE
= 0;
175 static Atom _XA_KWM_MODULE_WIN_CHANGE
= 0;
176 static Atom _XA_KWM_MODULE_WIN_RAISE
= 0;
177 static Atom _XA_KWM_MODULE_WIN_LOWER
= 0;
178 static Atom _XA_KWM_MODULE_WIN_ACTIVATE
= 0;
179 static Atom _XA_KWM_MODULE_WIN_ICON_CHANGE
= 0;
180 static Atom _XA_KWM_MODULE_DOCKWIN_ADD
= 0;
181 static Atom _XA_KWM_MODULE_DOCKWIN_REMOVE
= 0;
183 static Atom _XA_KWM_WIN_UNSAVED_DATA
= 0;
184 static Atom _XA_KWM_WIN_DECORATION
= 0;
185 static Atom _XA_KWM_WIN_DESKTOP
= 0;
186 static Atom _XA_KWM_WIN_GEOMETRY_RESTORE
= 0;
187 static Atom _XA_KWM_WIN_ICONIFIED
= 0;
188 static Atom _XA_KWM_WIN_MAXIMIZED
= 0;
189 static Atom _XA_KWM_WIN_STICKY
= 0;
191 static Atom _XA_KWM_WIN_ICON_GEOMETRY
= 0;
193 static Atom _XA_KWM_CURRENT_DESKTOP
= 0;
194 static Atom _XA_KWM_NUMBER_OF_DESKTOPS
= 0;
195 static Atom _XA_KWM_DESKTOP_NAME_
[MAX_WORKSPACES
];
196 static Atom _XA_KWM_WINDOW_REGION_
[MAX_WORKSPACES
];
200 /* list of window titles that must not be managed */
201 typedef struct KWMDoNotManageList
{
203 struct KWMDoNotManageList
*next
;
204 } KWMDoNotManageList
;
206 static KWMDoNotManageList
*KWMDoNotManageCrap
= NULL
;
209 /* list of KWM modules */
210 typedef struct KWMModuleList
{
212 struct KWMModuleList
*next
;
218 static KWMModuleList
*KWMModules
= NULL
;
220 static KWMModuleList
*KWMDockWindows
= NULL
;
222 /* window decoration types */
225 KWMnormalDecoration
= 1,
226 KWMtinyDecoration
= 2,
228 KWMstandaloneMenuBar
= 512,
229 KWMdesktopIcon
= 1024,
236 getSimpleHint(Window win
, Atom atom
, long *retval
)
242 data
= (long*)PropGetCheckProperty(win
, atom
, atom
, 32, 1, NULL
);
257 setSimpleHint(Window win
, Atom atom
, long value
)
260 XChangeProperty(dpy
, win
, atom
, atom
,
261 32, PropModeReplace
, (unsigned char*)&value
, 1);
266 sendClientMessage(WScreen
*scr
, Window window
, Atom atom
, long value
)
273 memset(&event
, 0, sizeof(XEvent
));
274 event
.xclient
.type
= ClientMessage
;
275 event
.xclient
.message_type
= atom
;
276 event
.xclient
.window
= window
;
277 event
.xclient
.format
= 32;
278 event
.xclient
.data
.l
[0] = value
;
279 event
.xclient
.data
.l
[1] = LastTimestamp
;
281 if (scr
&& scr
->root_win
== window
)
282 mask
= SubstructureRedirectMask
;
284 XSendEvent(dpy
, window
, False
, mask
, &event
);
289 sendTextMessage(WScreen
*scr
, Window window
, Atom atom
, char *text
)
297 memset(&event
, 0, sizeof(XEvent
));
298 event
.xclient
.type
= ClientMessage
;
299 event
.xclient
.message_type
= atom
;
300 event
.xclient
.window
= window
;
301 event
.xclient
.format
= 8;
303 for (i
=0; i
<20 && text
[i
]; i
++)
304 event
.xclient
.data
.b
[i
] = text
[i
];
306 if (scr
&& scr
->root_win
== window
)
307 mask
= SubstructureRedirectMask
;
309 XSendEvent(dpy
, window
, False
, mask
, &event
);
314 getAreaHint(Window win
, Atom atom
, WArea
*area
)
318 data
= (long*)PropGetCheckProperty(win
, atom
, atom
, 32, 4, NULL
);
325 area
->x2
= data
[2] + area
->x1
;
326 area
->y2
= data
[3] + area
->y1
;
335 setAreaHint(Window win
, Atom atom
, WArea area
)
342 value
[2] = area
.x2
- area
.x1
;
343 value
[3] = area
.y2
- area
.y1
;
344 XChangeProperty(dpy
, win
, atom
, atom
, 32, PropModeReplace
,
345 (unsigned char*)&value
, 4);
350 addModule(WScreen
*scr
, Window window
)
356 node
= malloc(sizeof(KWMModuleList
));
358 wwarning("out of memory while registering KDE module");
362 node
->next
= KWMModules
;
363 node
->window
= window
;
366 sendClientMessage(scr
, window
, _XA_KWM_MODULE_INIT
, 0);
368 if (getSimpleHint(window
, _XA_KWM_MODULE
, &val
) && val
==2) {
369 if (scr
->kwm_dock
!= None
) {
370 setSimpleHint(window
, _XA_KWM_MODULE
, 1);
374 scr
->kwm_dock
= window
;
376 for (ptr
= KWMDockWindows
; ptr
!=NULL
; ptr
= ptr
->next
) {
377 sendClientMessage(scr
, scr
->kwm_dock
, _XA_KWM_MODULE_DOCKWIN_ADD
,
383 /* send list of windows */
384 for (ptr
= scr
->focused_window
; ptr
!=NULL
; ptr
= ptr
->prev
) {
385 if (!ptr
->flags
.kwm_hidden_for_modules
386 && !WFLAGP(ptr
, skip_window_list
)) {
387 sendClientMessage(scr
, window
, _XA_KWM_MODULE_WIN_ADD
,
392 /* send window stacking order */
393 wKWMSendStacking(scr
, window
);
395 /* send focused window */
396 if (scr
->focused_window
&& scr
->focused_window
->flags
.focused
) {
397 sendClientMessage(scr
, window
, _XA_KWM_MODULE_WIN_ACTIVATE
,
398 scr
->focused_window
->client_win
);
401 /* tell who we are */
402 sendTextMessage(scr
, window
, _XA_KWM_COMMAND
, "wm:wmaker");
405 sendClientMessage(scr
, window
, _XA_KWM_MODULE_INITIALIZED
, 0);
407 KWMModules
->title
= NULL
;
408 XFetchName(dpy
, window
, &KWMModules
->title
);
409 printf("NEW MODULE %s\n", KWMModules
->title
);
415 removeModule(WScreen
*scr
, Window window
)
423 if (KWMModules
->window
== window
) {
424 next
= KWMModules
->next
;
426 printf("REMOVING MODULE %s\n", KWMModules
->title
);
427 if (KWMModules
->title
)
428 XFree(KWMModules
->title
);
437 if (ptr
->next
->window
== window
) {
438 next
= ptr
->next
->next
;
440 printf("REMOVING MODULE %s\n", ptr
->next
->title
);
441 if (ptr
->next
->title
)
442 XFree(ptr
->next
->title
);
445 ptr
->next
->next
= next
;
448 ptr
->next
= ptr
->next
->next
;
452 if (scr
->kwm_dock
== window
)
453 scr
->kwm_dock
= None
;
459 addDockWindow(WScreen
*scr
, Window window
)
463 for (ptr
= KWMDockWindows
; ptr
!= NULL
; ptr
= ptr
->next
) {
464 if (ptr
->window
== window
)
470 node
= malloc(sizeof(KWMModuleList
));
472 wwarning("out of memory while processing KDE dock window");
475 node
->next
= KWMDockWindows
;
476 KWMDockWindows
= node
;
477 node
->window
= window
;
478 XSelectInput(dpy
, window
, StructureNotifyMask
);
480 sendClientMessage(scr
, scr
->kwm_dock
, _XA_KWM_MODULE_DOCKWIN_ADD
,
487 removeDockWindow(WScreen
*scr
, Window window
)
492 if (KWMDockWindows
->window
== window
) {
495 sendClientMessage(scr
, scr
->kwm_dock
, _XA_KWM_MODULE_DOCKWIN_REMOVE
,
498 next
= KWMDockWindows
->next
;
499 free(KWMDockWindows
);
500 KWMDockWindows
= next
;
503 KWMModuleList
*ptr
, *next
;
505 ptr
= KWMDockWindows
;
507 if (ptr
->next
->window
== window
) {
508 sendClientMessage(scr
, scr
->kwm_dock
,
509 _XA_KWM_MODULE_DOCKWIN_REMOVE
, window
);
510 next
= ptr
->next
->next
;
522 sendToModules(WScreen
*scr
, Atom atom
, WWindow
*wwin
, long data
)
529 if (wwin
->flags
.kwm_hidden_for_modules
530 || WFLAGP(wwin
, skip_window_list
))
532 data
= wwin
->client_win
;
535 printf("notifying %s\n",XGetAtomName(dpy
, atom
));
537 memset(&event
, 0, sizeof(XEvent
));
538 event
.xclient
.type
= ClientMessage
;
539 event
.xclient
.message_type
= atom
;
540 event
.xclient
.format
= 32;
541 event
.xclient
.data
.l
[1] = LastTimestamp
;
544 if (scr
&& scr
->root_win
== data
)
545 mask
= SubstructureRedirectMask
;
547 for (ptr
= KWMModules
; ptr
!=NULL
; ptr
= ptr
->next
) {
548 event
.xclient
.window
= ptr
->window
;
549 event
.xclient
.data
.l
[0] = data
;
550 XSendEvent(dpy
, ptr
->window
, False
, mask
, &event
);
556 wKWMInitStuff(WScreen
*scr
)
558 if (!_XA_KWM_WIN_STICKY
) {
559 _XA_KWM_WIN_UNSAVED_DATA
= XInternAtom(dpy
, "KWM_WIN_UNSAVED_DATA",
562 _XA_KWM_WIN_DECORATION
= XInternAtom(dpy
, "KWM_WIN_DECORATION", False
);
564 _XA_KWM_WIN_DESKTOP
= XInternAtom(dpy
, "KWM_WIN_DESKTOP", False
);
566 _XA_KWM_WIN_GEOMETRY_RESTORE
= XInternAtom(dpy
,
567 "KWM_WIN_GEOMETRY_RESTORE",
570 _XA_KWM_WIN_STICKY
= XInternAtom(dpy
, "KWM_WIN_STICKY", False
);
572 _XA_KWM_WIN_ICONIFIED
= XInternAtom(dpy
, "KWM_WIN_ICONIFIED", False
);
574 _XA_KWM_WIN_MAXIMIZED
= XInternAtom(dpy
, "KWM_WIN_MAXIMIZED", False
);
576 _XA_KWM_WIN_ICON_GEOMETRY
= XInternAtom(dpy
, "KWM_WIN_ICON_GEOMETRY",
579 _XA_KWM_COMMAND
= XInternAtom(dpy
, "KWM_COMMAND", False
);
581 _XA_KWM_ACTIVE_WINDOW
= XInternAtom(dpy
, "KWM_ACTIVE_WINDOW", False
);
583 _XA_KWM_ACTIVATE_WINDOW
= XInternAtom(dpy
, "KWM_ACTIVATE_WINDOW",
586 _XA_KWM_DO_NOT_MANAGE
= XInternAtom(dpy
, "KWM_DO_NOT_MANAGE", False
);
588 _XA_KWM_CURRENT_DESKTOP
= XInternAtom(dpy
, "KWM_CURRENT_DESKTOP",
591 _XA_KWM_NUMBER_OF_DESKTOPS
= XInternAtom(dpy
, "KWM_NUMBER_OF_DESKTOPS",
594 _XA_KWM_DOCKWINDOW
= XInternAtom(dpy
, "KWM_DOCKWINDOW", False
);
596 _XA_KWM_RUNNING
= XInternAtom(dpy
, "KWM_RUNNING", False
);
598 _XA_KWM_MODULE
= XInternAtom(dpy
, "KWM_MODULE", False
);
600 _XA_KWM_MODULE_INIT
= XInternAtom(dpy
, "KWM_MODULE_INIT", False
);
601 _XA_KWM_MODULE_INITIALIZED
= XInternAtom(dpy
, "KWM_MODULE_INITIALIZED", False
);
603 /* dunno what these do, but Matthias' patch contains it... */
604 _XA_KWM_MODULE_DESKTOP_CHANGE
= XInternAtom(dpy
, "KWM_MODULE_DESKTOP_CHANGE", False
);
605 _XA_KWM_MODULE_DESKTOP_NAME_CHANGE
= XInternAtom(dpy
, "KWM_MODULE_DESKTOP_NAME_CHANGE", False
);
606 _XA_KWM_MODULE_DESKTOP_NUMBER_CHANGE
= XInternAtom(dpy
, "KWM_MODULE_DESKTOP_NUMBER_CHANGE", False
);
608 _XA_KWM_MODULE_WIN_ADD
= XInternAtom(dpy
, "KWM_MODULE_WIN_ADD", False
);
609 _XA_KWM_MODULE_WIN_REMOVE
= XInternAtom(dpy
, "KWM_MODULE_WIN_REMOVE", False
);
610 _XA_KWM_MODULE_WIN_CHANGE
= XInternAtom(dpy
, "KWM_MODULE_WIN_CHANGE", False
);
611 _XA_KWM_MODULE_WIN_RAISE
= XInternAtom(dpy
, "KWM_MODULE_WIN_RAISE", False
);
612 _XA_KWM_MODULE_WIN_LOWER
= XInternAtom(dpy
, "KWM_MODULE_WIN_LOWER", False
);
613 _XA_KWM_MODULE_WIN_ACTIVATE
= XInternAtom(dpy
, "KWM_MODULE_WIN_ACTIVATE", False
);
614 _XA_KWM_MODULE_WIN_ICON_CHANGE
= XInternAtom(dpy
, "KWM_MODULE_WIN_ICON_CHANGE", False
);
615 _XA_KWM_MODULE_DOCKWIN_ADD
= XInternAtom(dpy
, "KWM_MODULE_DOCKWIN_ADD", False
);
616 _XA_KWM_MODULE_DOCKWIN_REMOVE
= XInternAtom(dpy
, "KWM_MODULE_DOCKWIN_REMOVE", False
);
618 memset(_XA_KWM_WINDOW_REGION_
, 0, sizeof(_XA_KWM_WINDOW_REGION_
));
620 memset(_XA_KWM_DESKTOP_NAME_
, 0, sizeof(_XA_KWM_DESKTOP_NAME_
));
623 #define SETSTR(hint, str) {\
624 static Atom a = 0; if (!a) a = XInternAtom(dpy, #hint, False);\
625 XChangeProperty(dpy, scr->root_win, a, XA_STRING, 8, PropModeReplace,\
626 (unsigned char*)str, strlen(str));}
628 SETSTR(KWM_STRING_MAXIMIZE
, _("Maximize"));
629 SETSTR(KWM_STRING_UNMAXIMIZE
, _("Unmaximize"));
630 SETSTR(KWM_STRING_ICONIFY
, _("Miniaturize"));
631 SETSTR(KWM_STRING_UNICONIFY
, _("Deminiaturize"));
632 SETSTR(KWM_STRING_STICKY
, _("Omnipresent"));
633 SETSTR(KWM_STRING_UNSTICKY
, _("Not Omnipresent"));
634 SETSTR(KWM_STRING_STRING_MOVE
, _("Move"));
635 SETSTR(KWM_STRING_STRING_RESIZE
, _("Resize"));
636 SETSTR(KWM_STRING_CLOSE
, _("Close"));
637 SETSTR(KWM_STRING_TODESKTOP
, _("Move To"));
638 SETSTR(KWM_STRING_ONTOCURRENTDESKTOP
, _("Bring Here"));
644 wKWMSendStacking(WScreen
*scr
, Window module
)
649 WM_ITERATE_BAG(scr
->stacking_list
, core
, i
) {
650 for (; core
!= NULL
; core
= core
->stacking
->under
) {
653 wwin
= wWindowFor(core
->window
);
655 sendClientMessage(scr
, module
, _XA_KWM_MODULE_WIN_RAISE
,
663 wKWMBroadcastStacking(WScreen
*scr
)
665 KWMModuleList
*ptr
= KWMModules
;
668 wKWMSendStacking(scr
, ptr
->window
);
676 wKWMGetWorkspaceName(WScreen
*scr
, int workspace
)
680 unsigned long nitems_ret
;
681 unsigned long bytes_after_ret
;
682 char *data
= NULL
, *tmp
;
685 assert(workspace
>= 0 && workspace
< MAX_WORKSPACES
);
687 if (_XA_KWM_DESKTOP_NAME_
[workspace
]==0) {
688 sprintf(buffer
, "KWM_DESKTOP_NAME_%d", workspace
+ 1);
690 _XA_KWM_DESKTOP_NAME_
[workspace
] = XInternAtom(dpy
, buffer
, False
);
693 /* What do these people have against correctly using property types? */
694 if (XGetWindowProperty(dpy
, scr
->root_win
,
695 _XA_KWM_DESKTOP_NAME_
[workspace
], 0, 128, False
,
697 &type_ret
, &fmt_ret
, &nitems_ret
, &bytes_after_ret
,
698 (unsigned char**)&data
)!=Success
|| !data
)
709 wKWMSetInitializedHint(WScreen
*scr
)
711 setSimpleHint(scr
->root_win
, _XA_KWM_RUNNING
, 1);
716 wKWMShutdown(WScreen
*scr
, Bool closeModules
)
720 XDeleteProperty(dpy
, scr
->root_win
, _XA_KWM_RUNNING
);
723 for (ptr
= KWMModules
; ptr
!= NULL
; ptr
= ptr
->next
) {
724 XKillClient(dpy
, ptr
->window
);
731 wKWMCheckClientHints(WWindow
*wwin
, int *layer
, int *workspace
)
735 if (getSimpleHint(wwin
->client_win
, _XA_KWM_WIN_UNSAVED_DATA
, &val
)
738 wwin
->client_flags
.broken_close
= 1;
740 if (getSimpleHint(wwin
->client_win
, _XA_KWM_WIN_DECORATION
, &val
)) {
741 if (val
& KWMnoFocus
) {
742 wwin
->client_flags
.no_focusable
= 1;
744 switch (val
& ~KWMnoFocus
) {
745 case KWMnoDecoration
:
746 wwin
->client_flags
.no_titlebar
= 1;
747 wwin
->client_flags
.no_resizebar
= 1;
749 case KWMtinyDecoration
:
750 wwin
->client_flags
.no_resizebar
= 1;
752 case KWMstandaloneMenuBar
:
753 wwin
->client_flags
.no_titlebar
= 1;
754 wwin
->client_flags
.no_resizebar
= 1;
755 wwin
->client_flags
.no_resizable
= 1;
756 wwin
->client_flags
.skip_window_list
= 1;
757 wwin
->client_flags
.no_hide_others
= 1;
758 wwin
->flags
.kwm_menubar
= 1;
759 *layer
= WMMainMenuLevel
;
762 *layer
= WMDesktopLevel
;
765 *layer
= WMFloatingLevel
;
767 case KWMnormalDecoration
:
772 if (getSimpleHint(wwin
->client_win
, _XA_KWM_WIN_DESKTOP
, &val
)) {
773 *workspace
= val
- 1;
779 wKWMCheckClientInitialState(WWindow
*wwin
)
784 if (getSimpleHint(wwin
->client_win
, _XA_KWM_WIN_STICKY
, &val
) && val
) {
786 wwin
->client_flags
.omnipresent
= 1;
788 if (getSimpleHint(wwin
->client_win
, _XA_KWM_WIN_ICONIFIED
, &val
) && val
) {
790 wwin
->flags
.miniaturized
= 1;
792 if (getSimpleHint(wwin
->client_win
, _XA_KWM_WIN_MAXIMIZED
, &val
) && val
) {
794 wwin
->flags
.maximized
= MAX_VERTICAL
|MAX_HORIZONTAL
;
796 if (getAreaHint(wwin
->client_win
, _XA_KWM_WIN_GEOMETRY_RESTORE
, &area
)
797 && (wwin
->old_geometry
.x
!= area
.x1
798 || wwin
->old_geometry
.y
!= area
.y1
799 || wwin
->old_geometry
.width
!= area
.x2
- area
.x1
800 || wwin
->old_geometry
.height
!= area
.y2
- area
.y1
)) {
802 wwin
->old_geometry
.x
= area
.x1
;
803 wwin
->old_geometry
.y
= area
.y1
;
804 wwin
->old_geometry
.width
= area
.x2
- area
.x1
;
805 wwin
->old_geometry
.height
= area
.y2
- area
.y1
;
811 wKWMCheckClientHintChange(WWindow
*wwin
, XPropertyEvent
*event
)
813 Bool processed
= True
;
822 if (event
->atom
== _XA_KWM_WIN_UNSAVED_DATA
) {
824 printf("got KDE unsaved data change\n");
827 flag
= getSimpleHint(wwin
->client_win
, _XA_KWM_WIN_UNSAVED_DATA
,
830 if (flag
!= wwin
->client_flags
.broken_close
) {
831 wwin
->client_flags
.broken_close
= flag
;
833 wWindowUpdateButtonImages(wwin
);
835 } else if (event
->atom
== _XA_KWM_WIN_STICKY
) {
838 printf("got KDE sticky change\n");
840 flag
= !getSimpleHint(wwin
->client_win
, _XA_KWM_WIN_STICKY
,
843 if (flag
!= wwin
->client_flags
.omnipresent
) {
845 wwin
->client_flags
.omnipresent
= flag
;
847 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_WORKSPACE
);
850 } else if (event
->atom
== _XA_KWM_WIN_MAXIMIZED
) {
853 printf("got KDE maximize change\n");
855 flag
= !getSimpleHint(wwin
->client_win
, _XA_KWM_WIN_MAXIMIZED
,
858 if (flag
!= (wwin
->flags
.maximized
!=0)) {
861 wMaximizeWindow(wwin
, flag
*(MAX_VERTICAL
|MAX_HORIZONTAL
));
863 wUnmaximizeWindow(wwin
);
865 } else if (event
->atom
== _XA_KWM_WIN_ICONIFIED
) {
868 printf("got KDE iconify change\n");
870 flag
= !getSimpleHint(wwin
->client_win
, _XA_KWM_WIN_ICONIFIED
,
873 if (flag
!= wwin
->flags
.miniaturized
) {
876 wIconifyWindow(wwin
);
878 wDeiconifyWindow(wwin
);
881 } else if (event
->atom
== _XA_KWM_WIN_DECORATION
) {
882 Bool refresh
= False
;
886 printf("got KDE decoration change\n");
889 oldnofocus
= wwin
->client_flags
.no_focusable
;
891 if (getSimpleHint(wwin
->client_win
, _XA_KWM_WIN_DECORATION
, &value
)) {
892 wwin
->client_flags
.no_focusable
= (value
& KWMnoFocus
)!=0;
894 switch (value
& ~KWMnoFocus
) {
895 case KWMnoDecoration
:
896 if (!WFLAGP(wwin
, no_titlebar
) || !WFLAGP(wwin
, no_resizebar
))
899 wwin
->client_flags
.no_titlebar
= 1;
900 wwin
->client_flags
.no_resizebar
= 1;
903 case KWMtinyDecoration
:
904 if (WFLAGP(wwin
, no_titlebar
) || !WFLAGP(wwin
, no_resizebar
))
907 wwin
->client_flags
.no_titlebar
= 0;
908 wwin
->client_flags
.no_resizebar
= 1;
911 case KWMnormalDecoration
:
913 if (WFLAGP(wwin
, no_titlebar
) || WFLAGP(wwin
, no_resizebar
))
916 wwin
->client_flags
.no_titlebar
= 0;
917 wwin
->client_flags
.no_resizebar
= 0;
921 if (WFLAGP(wwin
, no_titlebar
) || WFLAGP(wwin
, no_resizebar
))
923 wwin
->client_flags
.no_focusable
= (value
& KWMnoFocus
)!=0;
924 wwin
->client_flags
.no_titlebar
= 0;
925 wwin
->client_flags
.no_resizebar
= 0;
929 wWindowConfigureBorders(wwin
);
931 if (wwin
->client_flags
.no_focusable
&& !oldnofocus
) {
933 sendToModules(wwin
->screen_ptr
, _XA_KWM_MODULE_WIN_REMOVE
,
935 wwin
->flags
.kwm_hidden_for_modules
= 1;
937 } else if (!wwin
->client_flags
.no_focusable
&& oldnofocus
) {
939 if (wwin
->flags
.kwm_hidden_for_modules
) {
940 sendToModules(wwin
->screen_ptr
, _XA_KWM_MODULE_WIN_ADD
,
942 wwin
->flags
.kwm_hidden_for_modules
= 0;
945 } else if (event
->atom
== _XA_KWM_WIN_DESKTOP
&& wwin
->frame
) {
947 printf("got KDE workspace change for %s\n", wwin
->frame
->title
);
949 if (getSimpleHint(wwin
->client_win
, _XA_KWM_WIN_DESKTOP
, &value
)
950 && value
-1 != wwin
->frame
->workspace
) {
951 wWindowChangeWorkspace(wwin
, value
-1);
954 } else if (event
->atom
== _XA_KWM_WIN_GEOMETRY_RESTORE
) {
958 printf("got KDE geometry restore change\n");
960 if (getAreaHint(wwin
->client_win
, _XA_KWM_WIN_GEOMETRY_RESTORE
, &area
)
961 && (wwin
->old_geometry
.x
!= area
.x1
962 || wwin
->old_geometry
.y
!= area
.y1
963 || wwin
->old_geometry
.width
!= area
.x2
- area
.x1
964 || wwin
->old_geometry
.height
!= area
.y2
- area
.y1
)) {
966 wwin
->old_geometry
.x
= area
.x1
;
967 wwin
->old_geometry
.y
= area
.y1
;
968 wwin
->old_geometry
.width
= area
.x2
- area
.x1
;
969 wwin
->old_geometry
.height
= area
.y2
- area
.y1
;
980 performWindowCommand(WScreen
*scr
, char *command
)
982 WWindow
*wwin
= NULL
;
985 wwin
= scr
->focused_window
;
986 if (!wwin
|| !wwin
->flags
.focused
|| !wwin
->flags
.mapped
) {
990 CloseWindowMenu(scr
);
993 if (strcmp(command
, "winMove")==0 || strcmp(command
, "winResize")==0) {
996 wKeyboardMoveResizeWindow(wwin
);
998 } else if (strcmp(command
, "winMaximize")==0) {
1001 wMaximizeWindow(wwin
, MAX_VERTICAL
|MAX_HORIZONTAL
);
1003 } else if (strcmp(command
, "winRestore")==0) {
1005 if (wwin
&& wwin
->flags
.maximized
)
1006 wUnmaximizeWindow(wwin
);
1008 } else if (strcmp(command
, "winIconify")==0) {
1011 if (wwin
&& !WFLAGP(wwin
, no_miniaturizable
)) {
1012 if (wwin
->protocols
.MINIATURIZE_WINDOW
)
1013 wClientSendProtocol(wwin
, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
,
1016 wIconifyWindow(wwin
);
1020 } else if (strcmp(command
, "winClose")==0) {
1022 if (wwin
&& !WFLAGP(wwin
, no_closable
)) {
1023 if (wwin
->protocols
.DELETE_WINDOW
)
1024 wClientSendProtocol(wwin
, _XA_WM_DELETE_WINDOW
, LastTimestamp
);
1027 } else if (strcmp(command
, "winSticky")==0) {
1030 wwin
->client_flags
.omnipresent
^= 1;
1031 UpdateSwitchMenu(scr
, wwin
, ACTION_CHANGE_WORKSPACE
);
1034 } else if (strcmp(command
, "winShade")==0) {
1036 if (wwin
&& !WFLAGP(wwin
, no_shadeable
)) {
1037 if (wwin
->flags
.shaded
)
1038 wUnshadeWindow(wwin
);
1043 } else if (strcmp(command
, "winOperation")==0) {
1046 OpenWindowMenu(wwin
, wwin
->frame_x
,
1047 wwin
->frame_y
+wwin
->frame
->top_width
, True
);
1058 performCommand(WScreen
*scr
, char *command
, XClientMessageEvent
*event
)
1060 assert(scr
!= NULL
);
1062 if (strcmp(command
, "commandLine")==0
1063 || strcmp(command
, "execute")==0) {
1066 cmd
= ExpandOptions(scr
, _("%a(Run Command,Type the command to run:)"));
1068 ExecuteShellCommand(scr
, cmd
);
1071 } else if (strcmp(command
, "logout")==0) {
1073 Shutdown(WSLogoutMode
);
1075 } else if (strcmp(command
, "refreshScreen")==0) {
1077 wRefreshDesktop(scr
);
1079 } else if (strncmp(command
, "go:", 3)==0) {
1081 Shutdown(WSRestartPreparationMode
);
1082 Restart(&command
[3], False
);
1083 Restart(NULL
, True
);
1085 } else if (strcmp(command
, "desktop+1")==0) {
1087 wWorkspaceRelativeChange(scr
, 1);
1089 } else if (strcmp(command
, "desktop-1")==0) {
1091 wWorkspaceRelativeChange(scr
, -1);
1093 } else if (strcmp(command
, "desktop+2")==0) {
1095 wWorkspaceRelativeChange(scr
, 2);
1097 } else if (strcmp(command
, "desktop-2")==0) {
1099 wWorkspaceRelativeChange(scr
, -2);
1101 } else if (strcmp(command
, "desktop%%2")==0) {
1103 if (scr
->current_workspace
% 2 == 1)
1104 wWorkspaceRelativeChange(scr
, 1);
1106 wWorkspaceRelativeChange(scr
, -1);
1107 } else if (strncmp(command
, "desktop", 7)==0) {
1110 ws
= atoi(&command
[7]);
1111 wWorkspaceChange(scr
, ws
);
1113 /* wmaker specific stuff */
1114 } else if (strcmp(command
, "wmaker:info")==0) {
1116 wShowInfoPanel(scr
);
1118 } else if (strcmp(command
, "wmaker:legal")==0) {
1120 wShowLegalPanel(scr
);
1122 } else if (strcmp(command
, "wmaker:arrangeIcons")==0) {
1124 wArrangeIcons(scr
, True
);
1126 } else if (strcmp(command
, "wmaker:showAll")==0) {
1128 wShowAllWindows(scr
);
1130 } else if (strcmp(command
, "wmaker:hideOthers")==0) {
1132 wHideOtherApplications(scr
->focused_window
);
1134 } else if (strcmp(command
, "wmaker:restart")==0) {
1136 Shutdown(WSRestartPreparationMode
);
1137 Restart(NULL
, True
);
1139 } else if (strcmp(command
, "wmaker:exit")==0) {
1141 Shutdown(WSExitMode
);
1143 #ifdef UNSUPPORTED_STUFF
1144 } else if (strcmp(command
, "moduleRaised")==0) { /* useless */
1145 } else if (strcmp(command
, "deskUnclutter")==0) {
1146 } else if (strcmp(command
, "deskCascade")==0) {
1147 } else if (strcmp(command
, "configure")==0) {
1148 } else if (strcmp(command
, "taskManager")==0) {
1149 } else if (strcmp(command
, "darkenScreen")==0) { /* breaks consistency */
1151 } else if (!performWindowCommand(scr
, command
)) {
1152 KWMModuleList
*module
;
1155 /* do message relay thing */
1157 ev
.xclient
= *event
;
1158 for (module
= KWMModules
; module
!= NULL
; module
= module
->next
) {
1160 ev
.xclient
.window
= module
->window
;
1161 if (module
->window
== scr
->root_win
)
1162 mask
= SubstructureRedirectMask
;
1166 XSendEvent(dpy
, module
->window
, False
, mask
, &ev
);
1173 wKWMProcessClientMessage(XClientMessageEvent
*event
)
1175 Bool processed
= True
;
1178 printf("CLIENT MESS %s\n", XGetAtomName(dpy
, event
->message_type
));
1180 if (event
->message_type
== _XA_KWM_COMMAND
&& event
->format
==8) {
1184 scr
= wScreenForRootWindow(event
->window
);
1186 for (i
=0; i
<20; i
++) {
1187 buffer
[i
] = event
->data
.b
[i
];
1192 printf("got KDE command %s\n", buffer
);
1194 performCommand(scr
, buffer
, event
);
1196 } else if (event
->message_type
== _XA_KWM_ACTIVATE_WINDOW
) {
1200 printf("got KDE activate internal\n");
1202 wwin
= wWindowFor(event
->data
.l
[0]);
1205 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1207 } else if (event
->message_type
== _XA_KWM_DO_NOT_MANAGE
1208 && event
->format
== 8) {
1209 KWMDoNotManageList
*node
;
1213 printf("got KDE dont manage\n");
1216 node
= malloc(sizeof(KWMDoNotManageList
));
1218 wwarning("out of memory processing KWM_DO_NOT_MANAGE message");
1220 for (i
=0; i
<20 && event
->data
.b
[i
]; i
++)
1221 node
->title
[i
] = event
->data
.b
[i
];
1224 node
->next
= KWMDoNotManageCrap
;
1225 KWMDoNotManageCrap
= node
;
1227 } else if (event
->message_type
== _XA_KWM_MODULE
) {
1229 Window modwin
= event
->data
.l
[0];
1231 scr
= wScreenForRootWindow(event
->window
);
1233 if (getSimpleHint(modwin
, _XA_KWM_MODULE
, &val
) && val
) {
1235 puts("got KDE module startup");
1237 addModule(scr
, modwin
);
1240 puts("got KDE module finish");
1242 removeModule(scr
, modwin
);
1253 wKWMCheckModule(WScreen
*scr
, Window window
)
1257 if (getSimpleHint(window
, _XA_KWM_MODULE
, &val
) && val
) {
1259 puts("got KDE module startup");
1261 addModule(scr
, window
);
1267 wKWMCheckRootHintChange(WScreen
*scr
, XPropertyEvent
*event
)
1269 Bool processed
= True
;
1272 if (event
->atom
== _XA_KWM_CURRENT_DESKTOP
) {
1273 if (getSimpleHint(scr
->root_win
, _XA_KWM_CURRENT_DESKTOP
, &value
)) {
1275 printf("got KDE workspace switch to %li\n", value
);
1277 if (value
-1 != scr
->current_workspace
) {
1278 wWorkspaceChange(scr
, value
-1);
1281 } else if (event
->atom
== _XA_KWM_NUMBER_OF_DESKTOPS
) {
1283 printf("got KDE workspace number change\n");
1286 if (getSimpleHint(scr
->root_win
, _XA_KWM_NUMBER_OF_DESKTOPS
, &value
)) {
1288 /* increasing is easy... */
1289 if (value
> scr
->workspace_count
) {
1290 scr
->flags
.kwm_syncing_count
= 1;
1292 wWorkspaceMake(scr
, value
- scr
->workspace_count
);
1294 scr
->flags
.kwm_syncing_count
= 0;
1296 } else if (value
< scr
->workspace_count
) {
1298 Bool rebuild
= False
;
1300 scr
->flags
.kwm_syncing_count
= 1;
1302 /* decrease all we can do */
1303 for (i
= scr
->workspace_count
; i
>= value
; i
--) {
1304 if (!wWorkspaceDelete(scr
, i
)) {
1310 scr
->flags
.kwm_syncing_count
= 0;
1312 /* someone destroyed a workspace that can't be destroyed.
1313 * Reset the hints to reflect our internal state.
1316 wKWMUpdateWorkspaceCountHint(scr
);
1325 for (i
= 0; i
< MAX_WORKSPACES
&& i
< scr
->workspace_count
; i
++) {
1326 if (event
->atom
== _XA_KWM_DESKTOP_NAME_
[i
]) {
1329 name
= wKWMGetWorkspaceName(scr
, i
);
1332 printf("got KDE workspace name change to %s\n", name
);
1335 if (name
&& strncmp(name
, scr
->workspaces
[i
]->name
,
1336 MAX_WORKSPACENAME_WIDTH
)!=0) {
1337 scr
->flags
.kwm_syncing_name
= 1;
1338 wWorkspaceRename(scr
, i
, name
);
1339 scr
->flags
.kwm_syncing_name
= 0;
1345 } else if (event
->atom
== _XA_KWM_WINDOW_REGION_
[i
]) {
1348 if (getAreaHint(scr
->root_win
, event
->atom
, &area
)) {
1350 if (scr
->totalUsableArea
.x1
!= area
.x1
1351 || scr
->totalUsableArea
.y1
!= area
.y1
1352 || scr
->totalUsableArea
.x2
!= area
.x2
1353 || scr
->totalUsableArea
.y2
!= area
.y2
) {
1354 wScreenUpdateUsableArea(scr
);
1369 wKWMManageableClient(WScreen
*scr
, Window win
, char *title
)
1371 KWMDoNotManageList
*ptr
, *next
;
1374 if (getSimpleHint(win
, _XA_KWM_DOCKWINDOW
, &val
) && val
) {
1375 addDockWindow(scr
, win
);
1379 ptr
= KWMDoNotManageCrap
;
1381 * TODO: support for glob patterns or regexes
1383 if (ptr
&& strncmp(ptr
->title
, title
, strlen(ptr
->title
))==0) {
1386 KWMDoNotManageCrap
= next
;
1388 printf("window %s not managed per KDE request\n", title
);
1391 sendToModules(scr
, _XA_KWM_MODULE_WIN_ADD
, NULL
, win
);
1392 sendToModules(scr
, _XA_KWM_MODULE_WIN_REMOVE
, NULL
, win
);
1397 if (strncmp(ptr
->next
->title
, title
, strlen(ptr
->next
->title
))==0) {
1399 printf("window %s not managed per KDE request\n", title
);
1401 next
= ptr
->next
->next
;
1405 sendToModules(scr
, _XA_KWM_MODULE_WIN_ADD
, NULL
, win
);
1406 sendToModules(scr
, _XA_KWM_MODULE_WIN_REMOVE
, NULL
, win
);
1420 wKWMUpdateCurrentWorkspaceHint(WScreen
*scr
)
1422 setSimpleHint(scr
->root_win
, _XA_KWM_CURRENT_DESKTOP
,
1423 scr
->current_workspace
+1);
1425 sendToModules(scr
, _XA_KWM_MODULE_DESKTOP_CHANGE
, NULL
,
1426 scr
->current_workspace
+1);
1431 wKWMUpdateActiveWindowHint(WScreen
*scr
)
1434 WWindow
*wwin
, *tmp
;
1436 if (!scr
->focused_window
|| !scr
->focused_window
->flags
.focused
)
1439 val
= (long)(scr
->focused_window
->client_win
);
1441 /* raise the menubar thing */
1442 wwin
= scr
->focused_window
;
1445 if (tmp
->flags
.kwm_menubar
1446 && tmp
->transient_for
== wwin
->client_win
) {
1447 wRaiseFrame(tmp
->frame
->core
);
1454 XChangeProperty(dpy
, scr
->root_win
, _XA_KWM_ACTIVE_WINDOW
,
1455 _XA_KWM_ACTIVE_WINDOW
, 32, PropModeReplace
,
1456 (unsigned char*)&val
, 1);
1462 wKWMUpdateWorkspaceCountHint(WScreen
*scr
)
1464 if (scr
->flags
.kwm_syncing_count
)
1467 setSimpleHint(scr
->root_win
, _XA_KWM_NUMBER_OF_DESKTOPS
,
1468 scr
->workspace_count
);
1470 sendToModules(scr
, _XA_KWM_MODULE_DESKTOP_NUMBER_CHANGE
, NULL
,
1471 scr
->workspace_count
);
1476 wKWMCheckDestroy(XDestroyWindowEvent
*event
)
1480 if (event
->event
== event
->window
) {
1484 scr
= wScreenSearchForRootWindow(event
->event
);
1489 removeModule(scr
, event
->window
);
1490 removeDockWindow(scr
, event
->window
);
1495 wKWMUpdateWorkspaceNameHint(WScreen
*scr
, int workspace
)
1499 assert(workspace
>= 0 && workspace
< MAX_WORKSPACES
);
1501 if (_XA_KWM_DESKTOP_NAME_
[workspace
]==0) {
1502 sprintf(buffer
, "KWM_DESKTOP_NAME_%d", workspace
+ 1);
1504 _XA_KWM_DESKTOP_NAME_
[workspace
] = XInternAtom(dpy
, buffer
, False
);
1507 XChangeProperty(dpy
, scr
->root_win
, _XA_KWM_DESKTOP_NAME_
[workspace
],
1508 XA_STRING
, 8, PropModeReplace
,
1509 (unsigned char*)scr
->workspaces
[workspace
]->name
,
1510 strlen(scr
->workspaces
[workspace
]->name
)+1);
1512 sendToModules(scr
, _XA_KWM_MODULE_DESKTOP_NAME_CHANGE
, NULL
, workspace
+1);
1518 wKWMUpdateClientWorkspace(WWindow
*wwin
)
1521 printf("updating workspace of %s to %i\n",
1522 wwin
->frame
->title
, wwin
->frame
->workspace
+1);
1524 setSimpleHint(wwin
->client_win
, _XA_KWM_WIN_DESKTOP
,
1525 wwin
->frame
->workspace
+1);
1530 wKWMUpdateClientGeometryRestore(WWindow
*wwin
)
1534 rect
.x1
= wwin
->old_geometry
.x
;
1535 rect
.y1
= wwin
->old_geometry
.y
;
1536 rect
.x2
= wwin
->old_geometry
.x
+ wwin
->old_geometry
.width
;
1537 rect
.y2
= wwin
->old_geometry
.y
+ wwin
->old_geometry
.height
;
1539 setAreaHint(wwin
->client_win
, _XA_KWM_WIN_GEOMETRY_RESTORE
, rect
);
1544 wKWMUpdateClientStateHint(WWindow
*wwin
, WKWMStateFlag flags
)
1546 if (flags
& KWMIconifiedFlag
) {
1547 setSimpleHint(wwin
->client_win
, _XA_KWM_WIN_ICONIFIED
,
1548 wwin
->flags
.miniaturized
/*|| wwin->flags.shaded
1549 || wwin->flags.hidden*/);
1551 if (flags
& KWMStickyFlag
) {
1552 setSimpleHint(wwin
->client_win
, _XA_KWM_WIN_STICKY
,
1553 IS_OMNIPRESENT(wwin
));
1555 if (flags
& KWMMaximizedFlag
) {
1556 setSimpleHint(wwin
->client_win
, _XA_KWM_WIN_MAXIMIZED
,
1557 wwin
->flags
.maximized
!=0);
1563 wKWMGetUsableArea(WScreen
*scr
, WArea
*area
)
1567 if (_XA_KWM_WINDOW_REGION_
[0]==0) {
1568 sprintf(buffer
, "KWM_WINDOW_REGION_%d", 1);
1570 _XA_KWM_WINDOW_REGION_
[0] = XInternAtom(dpy
, buffer
, False
);
1573 return getAreaHint(scr
->root_win
, _XA_KWM_WINDOW_REGION_
[0], area
);
1579 wKWMGetIconGeometry(WWindow
*wwin
, WArea
*area
)
1581 return getAreaHint(wwin
->client_win
, _XA_KWM_WIN_ICON_GEOMETRY
, area
);
1588 wKWMSetUsableAreaHint(WScreen
*scr
, int workspace
)
1590 /* if we set this after making changes of our own to the area,
1591 * the next time the area changes, we won't know what should
1592 * be the new final area. This protocol isn't worth a shit :/
1595 * According to Matthias Ettrich:
1596 * Indeed, there's no protocol to deal with the area yet in case several
1597 * clients want to influence it. It is sufficent, though, if it is clear
1598 * that one process is responsable for the area. For KDE this is kpanel, but
1599 * I see that there might be a conflict with the docking area of windowmaker
1607 assert(workspace
>= 0 && workspace
< MAX_WORKSPACES
);
1609 if (_XA_KWM_WINDOW_REGION_
[workspace
]==0) {
1610 sprintf(buffer
, "KWM_WINDOW_REGION_%d", workspace
+1);
1612 _XA_KWM_WINDOW_REGION_
[workspace
] = XInternAtom(dpy
, buffer
, False
);
1615 setAreaHint(scr
->root_win
, _XA_KWM_WINDOW_REGION_
[workspace
],
1616 scr
->totalUsableArea
);
1619 #endif /* not_used */
1622 wKWMSendEventMessage(WWindow
*wwin
, WKWMEventMessage message
)
1626 if (wwin
&& (wwin
->flags
.internal_window
1627 || wwin
->flags
.kwm_hidden_for_modules
1628 || !wwin
->flags
.kwm_managed
1629 || WFLAGP(wwin
, skip_window_list
)))
1634 msg
= _XA_KWM_MODULE_WIN_ADD
;
1636 case WKWMRemoveWindow
:
1637 msg
= _XA_KWM_MODULE_WIN_REMOVE
;
1639 case WKWMFocusWindow
:
1640 msg
= _XA_KWM_MODULE_WIN_ACTIVATE
;
1642 case WKWMRaiseWindow
:
1643 msg
= _XA_KWM_MODULE_WIN_RAISE
;
1645 case WKWMLowerWindow
:
1646 msg
= _XA_KWM_MODULE_WIN_LOWER
;
1648 case WKWMChangedClient
:
1649 msg
= _XA_KWM_MODULE_WIN_CHANGE
;
1651 case WKWMIconChange
:
1652 msg
= _XA_KWM_MODULE_WIN_ICON_CHANGE
;
1658 sendToModules(wwin
? wwin
->screen_ptr
: NULL
, msg
, wwin
, 0);
1663 writeSocket(int sock
, char *data
)
1667 sprintf(buffer
, "%i ", strlen(data
));
1668 write(sock
, buffer
, strlen(buffer
));
1669 write(sock
, data
, strlen(data
));
1674 connectKFM(WScreen
*scr
)
1682 struct sockaddr_un addr
;
1684 path
= wstrappend(wgethomedir(), "/.kde/share/apps/kfm/pid");
1685 strcpy(buffer
, getenv("DISPLAY"));
1687 ptr
= strchr(buffer
, ':');
1691 ptr
= strrchr(buffer
, '.');
1697 sprintf(b
, ".%i", scr
->screen
);
1701 path
= wstrappend(ptr
, buffer
);
1705 f
= fopen(path
, "r");
1711 fgets(buffer
, 123, f
);
1716 if (kill(pid
, 0) != 0)
1720 fscanf(f
, "%s", buffer
);
1723 sock
= socket(AF_UNIX
, SOCK_STREAM
, 0);
1726 addr
.sun_family
= AF_UNIX
;
1727 strcpy(addr
.sun_path
, buffer
);
1729 if (connect(sock
, (struct sockaddr
*)&addr
, sizeof(addr
)) < 0) {
1734 path
= wstrappend(wgethomedir(), "/.kde/share/apps/kfm/magic");
1735 f
= fopen(path
, "r");
1739 ptr
= fgets(buffer
, 123, f
);
1746 ptr
= wstrappend("auth", buffer
);
1748 writeSocket(sock
, ptr
);
1756 wKWMSelectRootRegion(WScreen
*scr
, int x
, int y
, int w
, int h
, Bool control
)
1763 sock
= connectKFM(scr
);
1766 puts("SENDING DATA");
1768 sprintf(buffer
, "selectRootIcons %i %i %i %i %c", x
, y
, w
, h
, control
);
1769 writeSocket(sock
, buffer
);
1776 #endif /* KWM_HINTS */