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,
235 static void observer(void *self
, WMNotification
*notif
);
236 static void wsobserver(void *self
, WMNotification
*notif
);
241 getSimpleHint(Window win
, Atom atom
, long *retval
)
247 data
= (long*)PropGetCheckProperty(win
, atom
, atom
, 32, 1, NULL
);
262 setSimpleHint(Window win
, Atom atom
, long value
)
265 XChangeProperty(dpy
, win
, atom
, atom
,
266 32, PropModeReplace
, (unsigned char*)&value
, 1);
271 sendClientMessage(WScreen
*scr
, Window window
, Atom atom
, long value
)
278 memset(&event
, 0, sizeof(XEvent
));
279 event
.xclient
.type
= ClientMessage
;
280 event
.xclient
.message_type
= atom
;
281 event
.xclient
.window
= window
;
282 event
.xclient
.format
= 32;
283 event
.xclient
.data
.l
[0] = value
;
284 event
.xclient
.data
.l
[1] = LastTimestamp
;
286 if (scr
&& scr
->root_win
== window
)
287 mask
= SubstructureRedirectMask
;
289 XSendEvent(dpy
, window
, False
, mask
, &event
);
294 sendTextMessage(WScreen
*scr
, Window window
, Atom atom
, char *text
)
302 memset(&event
, 0, sizeof(XEvent
));
303 event
.xclient
.type
= ClientMessage
;
304 event
.xclient
.message_type
= atom
;
305 event
.xclient
.window
= window
;
306 event
.xclient
.format
= 8;
308 for (i
=0; i
<20 && text
[i
]; i
++)
309 event
.xclient
.data
.b
[i
] = text
[i
];
311 if (scr
&& scr
->root_win
== window
)
312 mask
= SubstructureRedirectMask
;
314 XSendEvent(dpy
, window
, False
, mask
, &event
);
319 getAreaHint(Window win
, Atom atom
, WArea
*area
)
323 data
= (long*)PropGetCheckProperty(win
, atom
, atom
, 32, 4, NULL
);
330 area
->x2
= data
[2] + area
->x1
;
331 area
->y2
= data
[3] + area
->y1
;
340 setAreaHint(Window win
, Atom atom
, WArea area
)
347 value
[2] = area
.x2
- area
.x1
;
348 value
[3] = area
.y2
- area
.y1
;
349 XChangeProperty(dpy
, win
, atom
, atom
, 32, PropModeReplace
,
350 (unsigned char*)&value
, 4);
355 addModule(WScreen
*scr
, Window window
)
361 node
= malloc(sizeof(KWMModuleList
));
363 wwarning("out of memory while registering KDE module");
367 node
->next
= KWMModules
;
368 node
->window
= window
;
371 sendClientMessage(scr
, window
, _XA_KWM_MODULE_INIT
, 0);
373 if (getSimpleHint(window
, _XA_KWM_MODULE
, &val
) && val
==2) {
374 if (scr
->kwm_dock
!= None
) {
375 setSimpleHint(window
, _XA_KWM_MODULE
, 1);
379 scr
->kwm_dock
= window
;
381 for (ptr
= KWMDockWindows
; ptr
!=NULL
; ptr
= ptr
->next
) {
382 sendClientMessage(scr
, scr
->kwm_dock
, _XA_KWM_MODULE_DOCKWIN_ADD
,
388 /* send list of windows */
389 for (ptr
= scr
->focused_window
; ptr
!=NULL
; ptr
= ptr
->prev
) {
390 if (!ptr
->flags
.kwm_hidden_for_modules
391 && !WFLAGP(ptr
, skip_window_list
)) {
392 sendClientMessage(scr
, window
, _XA_KWM_MODULE_WIN_ADD
,
397 /* send window stacking order */
398 wKWMSendStacking(scr
, window
);
400 /* send focused window */
401 if (scr
->focused_window
&& scr
->focused_window
->flags
.focused
) {
402 sendClientMessage(scr
, window
, _XA_KWM_MODULE_WIN_ACTIVATE
,
403 scr
->focused_window
->client_win
);
406 /* tell who we are */
407 sendTextMessage(scr
, window
, _XA_KWM_COMMAND
, "wm:wmaker");
410 sendClientMessage(scr
, window
, _XA_KWM_MODULE_INITIALIZED
, 0);
412 KWMModules
->title
= NULL
;
413 XFetchName(dpy
, window
, &KWMModules
->title
);
414 printf("NEW MODULE %s\n", KWMModules
->title
);
420 removeModule(WScreen
*scr
, Window window
)
428 if (KWMModules
->window
== window
) {
429 next
= KWMModules
->next
;
431 printf("REMOVING MODULE %s\n", KWMModules
->title
);
432 if (KWMModules
->title
)
433 XFree(KWMModules
->title
);
442 if (ptr
->next
->window
== window
) {
443 next
= ptr
->next
->next
;
445 printf("REMOVING MODULE %s\n", ptr
->next
->title
);
446 if (ptr
->next
->title
)
447 XFree(ptr
->next
->title
);
450 ptr
->next
->next
= next
;
453 ptr
->next
= ptr
->next
->next
;
457 if (scr
->kwm_dock
== window
)
458 scr
->kwm_dock
= None
;
464 addDockWindow(WScreen
*scr
, Window window
)
468 for (ptr
= KWMDockWindows
; ptr
!= NULL
; ptr
= ptr
->next
) {
469 if (ptr
->window
== window
)
475 node
= malloc(sizeof(KWMModuleList
));
477 wwarning("out of memory while processing KDE dock window");
480 node
->next
= KWMDockWindows
;
481 KWMDockWindows
= node
;
482 node
->window
= window
;
483 XSelectInput(dpy
, window
, StructureNotifyMask
);
485 sendClientMessage(scr
, scr
->kwm_dock
, _XA_KWM_MODULE_DOCKWIN_ADD
,
492 removeDockWindow(WScreen
*scr
, Window window
)
497 if (KWMDockWindows
->window
== window
) {
500 sendClientMessage(scr
, scr
->kwm_dock
, _XA_KWM_MODULE_DOCKWIN_REMOVE
,
503 next
= KWMDockWindows
->next
;
504 wfree(KWMDockWindows
);
505 KWMDockWindows
= next
;
508 KWMModuleList
*ptr
, *next
;
510 ptr
= KWMDockWindows
;
512 if (ptr
->next
->window
== window
) {
513 sendClientMessage(scr
, scr
->kwm_dock
,
514 _XA_KWM_MODULE_DOCKWIN_REMOVE
, window
);
515 next
= ptr
->next
->next
;
527 sendToModules(WScreen
*scr
, Atom atom
, WWindow
*wwin
, long data
)
534 if (wwin
->flags
.kwm_hidden_for_modules
535 || WFLAGP(wwin
, skip_window_list
))
537 data
= wwin
->client_win
;
540 printf("notifying %s\n",XGetAtomName(dpy
, atom
));
542 memset(&event
, 0, sizeof(XEvent
));
543 event
.xclient
.type
= ClientMessage
;
544 event
.xclient
.message_type
= atom
;
545 event
.xclient
.format
= 32;
546 event
.xclient
.data
.l
[1] = LastTimestamp
;
549 if (scr
&& scr
->root_win
== data
)
550 mask
= SubstructureRedirectMask
;
552 for (ptr
= KWMModules
; ptr
!=NULL
; ptr
= ptr
->next
) {
553 event
.xclient
.window
= ptr
->window
;
554 event
.xclient
.data
.l
[0] = data
;
555 XSendEvent(dpy
, ptr
->window
, False
, mask
, &event
);
561 wKWMInitStuff(WScreen
*scr
)
563 if (!_XA_KWM_WIN_STICKY
) {
564 _XA_KWM_WIN_UNSAVED_DATA
= XInternAtom(dpy
, "KWM_WIN_UNSAVED_DATA",
567 _XA_KWM_WIN_DECORATION
= XInternAtom(dpy
, "KWM_WIN_DECORATION", False
);
569 _XA_KWM_WIN_DESKTOP
= XInternAtom(dpy
, "KWM_WIN_DESKTOP", False
);
571 _XA_KWM_WIN_GEOMETRY_RESTORE
= XInternAtom(dpy
,
572 "KWM_WIN_GEOMETRY_RESTORE",
575 _XA_KWM_WIN_STICKY
= XInternAtom(dpy
, "KWM_WIN_STICKY", False
);
577 _XA_KWM_WIN_ICONIFIED
= XInternAtom(dpy
, "KWM_WIN_ICONIFIED", False
);
579 _XA_KWM_WIN_MAXIMIZED
= XInternAtom(dpy
, "KWM_WIN_MAXIMIZED", False
);
581 _XA_KWM_WIN_ICON_GEOMETRY
= XInternAtom(dpy
, "KWM_WIN_ICON_GEOMETRY",
584 _XA_KWM_COMMAND
= XInternAtom(dpy
, "KWM_COMMAND", False
);
586 _XA_KWM_ACTIVE_WINDOW
= XInternAtom(dpy
, "KWM_ACTIVE_WINDOW", False
);
588 _XA_KWM_ACTIVATE_WINDOW
= XInternAtom(dpy
, "KWM_ACTIVATE_WINDOW",
591 _XA_KWM_DO_NOT_MANAGE
= XInternAtom(dpy
, "KWM_DO_NOT_MANAGE", False
);
593 _XA_KWM_CURRENT_DESKTOP
= XInternAtom(dpy
, "KWM_CURRENT_DESKTOP",
596 _XA_KWM_NUMBER_OF_DESKTOPS
= XInternAtom(dpy
, "KWM_NUMBER_OF_DESKTOPS",
599 _XA_KWM_DOCKWINDOW
= XInternAtom(dpy
, "KWM_DOCKWINDOW", False
);
601 _XA_KWM_RUNNING
= XInternAtom(dpy
, "KWM_RUNNING", False
);
603 _XA_KWM_MODULE
= XInternAtom(dpy
, "KWM_MODULE", False
);
605 _XA_KWM_MODULE_INIT
= XInternAtom(dpy
, "KWM_MODULE_INIT", False
);
606 _XA_KWM_MODULE_INITIALIZED
= XInternAtom(dpy
, "KWM_MODULE_INITIALIZED", False
);
608 /* dunno what these do, but Matthias' patch contains it... */
609 _XA_KWM_MODULE_DESKTOP_CHANGE
= XInternAtom(dpy
, "KWM_MODULE_DESKTOP_CHANGE", False
);
610 _XA_KWM_MODULE_DESKTOP_NAME_CHANGE
= XInternAtom(dpy
, "KWM_MODULE_DESKTOP_NAME_CHANGE", False
);
611 _XA_KWM_MODULE_DESKTOP_NUMBER_CHANGE
= XInternAtom(dpy
, "KWM_MODULE_DESKTOP_NUMBER_CHANGE", False
);
613 _XA_KWM_MODULE_WIN_ADD
= XInternAtom(dpy
, "KWM_MODULE_WIN_ADD", False
);
614 _XA_KWM_MODULE_WIN_REMOVE
= XInternAtom(dpy
, "KWM_MODULE_WIN_REMOVE", False
);
615 _XA_KWM_MODULE_WIN_CHANGE
= XInternAtom(dpy
, "KWM_MODULE_WIN_CHANGE", False
);
616 _XA_KWM_MODULE_WIN_RAISE
= XInternAtom(dpy
, "KWM_MODULE_WIN_RAISE", False
);
617 _XA_KWM_MODULE_WIN_LOWER
= XInternAtom(dpy
, "KWM_MODULE_WIN_LOWER", False
);
618 _XA_KWM_MODULE_WIN_ACTIVATE
= XInternAtom(dpy
, "KWM_MODULE_WIN_ACTIVATE", False
);
619 _XA_KWM_MODULE_WIN_ICON_CHANGE
= XInternAtom(dpy
, "KWM_MODULE_WIN_ICON_CHANGE", False
);
620 _XA_KWM_MODULE_DOCKWIN_ADD
= XInternAtom(dpy
, "KWM_MODULE_DOCKWIN_ADD", False
);
621 _XA_KWM_MODULE_DOCKWIN_REMOVE
= XInternAtom(dpy
, "KWM_MODULE_DOCKWIN_REMOVE", False
);
623 memset(_XA_KWM_WINDOW_REGION_
, 0, sizeof(_XA_KWM_WINDOW_REGION_
));
625 memset(_XA_KWM_DESKTOP_NAME_
, 0, sizeof(_XA_KWM_DESKTOP_NAME_
));
628 #define SETSTR(hint, str) {\
629 static Atom a = 0; if (!a) a = XInternAtom(dpy, #hint, False);\
630 XChangeProperty(dpy, scr->root_win, a, XA_STRING, 8, PropModeReplace,\
631 (unsigned char*)str, strlen(str));}
633 SETSTR(KWM_STRING_MAXIMIZE
, _("Maximize"));
634 SETSTR(KWM_STRING_UNMAXIMIZE
, _("Unmaximize"));
635 SETSTR(KWM_STRING_ICONIFY
, _("Miniaturize"));
636 SETSTR(KWM_STRING_UNICONIFY
, _("Deminiaturize"));
637 SETSTR(KWM_STRING_STICKY
, _("Omnipresent"));
638 SETSTR(KWM_STRING_UNSTICKY
, _("Not Omnipresent"));
639 SETSTR(KWM_STRING_STRING_MOVE
, _("Move"));
640 SETSTR(KWM_STRING_STRING_RESIZE
, _("Resize"));
641 SETSTR(KWM_STRING_CLOSE
, _("Close"));
642 SETSTR(KWM_STRING_TODESKTOP
, _("Move To"));
643 SETSTR(KWM_STRING_ONTOCURRENTDESKTOP
, _("Bring Here"));
646 /* catch any notifications from any objects */
648 WMAddNotificationObserver(observer
, scr
, WMNManaged
, NULL
);
649 WMAddNotificationObserver(observer
, scr
, WMNUnmanaged
, NULL
);
650 WMAddNotificationObserver(observer
, scr
, WMNChangedWorkspace
, NULL
);
651 WMAddNotificationObserver(observer
, scr
, WMNChangedState
, NULL
);
652 WMAddNotificationObserver(observer
, scr
, WMNChangedFocus
, NULL
);
653 WMAddNotificationObserver(observer
, scr
, WMNChangedStacking
, NULL
);
654 WMAddNotificationObserver(observer
, scr
, WMNChangedName
, NULL
);
656 WMAddNotificationObserver(wsobserver
, scr
, WMNWorkspaceCreated
, NULL
);
657 WMAddNotificationObserver(wsobserver
, scr
, WMNWorkspaceDestroyed
, NULL
);
658 WMAddNotificationObserver(wsobserver
, scr
, WMNWorkspaceChanged
, NULL
);
659 WMAddNotificationObserver(wsobserver
, scr
, WMNWorkspaceNameChanged
, NULL
);
661 WMAddNotificationObserver(wsobserver
, scr
, WMNResetStacking
, NULL
);
666 wKWMSendStacking(WScreen
*scr
, Window module
)
671 WM_ITERATE_BAG(scr
->stacking_list
, core
, i
) {
672 for (; core
!= NULL
; core
= core
->stacking
->under
) {
675 wwin
= wWindowFor(core
->window
);
677 sendClientMessage(scr
, module
, _XA_KWM_MODULE_WIN_RAISE
,
685 wKWMBroadcastStacking(WScreen
*scr
)
687 KWMModuleList
*ptr
= KWMModules
;
690 wKWMSendStacking(scr
, ptr
->window
);
698 wKWMGetWorkspaceName(WScreen
*scr
, int workspace
)
702 unsigned long nitems_ret
;
703 unsigned long bytes_after_ret
;
704 char *data
= NULL
, *tmp
;
707 assert(workspace
>= 0 && workspace
< MAX_WORKSPACES
);
709 if (_XA_KWM_DESKTOP_NAME_
[workspace
]==0) {
710 snprintf(buffer
, sizeof(buffer
), "KWM_DESKTOP_NAME_%d", workspace
+ 1);
712 _XA_KWM_DESKTOP_NAME_
[workspace
] = XInternAtom(dpy
, buffer
, False
);
715 /* What do these people have against correctly using property types? */
716 if (XGetWindowProperty(dpy
, scr
->root_win
,
717 _XA_KWM_DESKTOP_NAME_
[workspace
], 0, 128, False
,
719 &type_ret
, &fmt_ret
, &nitems_ret
, &bytes_after_ret
,
720 (unsigned char**)&data
)!=Success
|| !data
)
731 wKWMSetInitializedHint(WScreen
*scr
)
733 setSimpleHint(scr
->root_win
, _XA_KWM_RUNNING
, 1);
738 wKWMShutdown(WScreen
*scr
, Bool closeModules
)
742 XDeleteProperty(dpy
, scr
->root_win
, _XA_KWM_RUNNING
);
745 for (ptr
= KWMModules
; ptr
!= NULL
; ptr
= ptr
->next
) {
746 XKillClient(dpy
, ptr
->window
);
753 wKWMCheckClientHints(WWindow
*wwin
, int *layer
, int *workspace
)
757 if (getSimpleHint(wwin
->client_win
, _XA_KWM_WIN_UNSAVED_DATA
, &val
)
760 wwin
->client_flags
.broken_close
= 1;
762 if (getSimpleHint(wwin
->client_win
, _XA_KWM_WIN_DECORATION
, &val
)) {
763 if (val
& KWMnoFocus
) {
764 wwin
->client_flags
.no_focusable
= 1;
766 switch (val
& ~KWMnoFocus
) {
767 case KWMnoDecoration
:
768 wwin
->client_flags
.no_titlebar
= 1;
769 wwin
->client_flags
.no_resizebar
= 1;
771 case KWMtinyDecoration
:
772 wwin
->client_flags
.no_resizebar
= 1;
774 case KWMstandaloneMenuBar
:
775 wwin
->client_flags
.no_titlebar
= 1;
776 wwin
->client_flags
.no_resizebar
= 1;
777 wwin
->client_flags
.no_resizable
= 1;
778 wwin
->client_flags
.skip_window_list
= 1;
779 wwin
->client_flags
.no_hide_others
= 1;
780 wwin
->flags
.kwm_menubar
= 1;
781 *layer
= WMMainMenuLevel
;
784 *layer
= WMDesktopLevel
;
787 *layer
= WMFloatingLevel
;
789 case KWMnormalDecoration
:
794 if (getSimpleHint(wwin
->client_win
, _XA_KWM_WIN_DESKTOP
, &val
)) {
795 *workspace
= val
- 1;
801 wKWMCheckClientInitialState(WWindow
*wwin
)
806 if (getSimpleHint(wwin
->client_win
, _XA_KWM_WIN_STICKY
, &val
) && val
) {
808 wwin
->client_flags
.omnipresent
= 1;
810 if (getSimpleHint(wwin
->client_win
, _XA_KWM_WIN_ICONIFIED
, &val
) && val
) {
812 wwin
->flags
.miniaturized
= 1;
814 if (getSimpleHint(wwin
->client_win
, _XA_KWM_WIN_MAXIMIZED
, &val
)) {
816 wwin
->flags
.maximized
= MAX_VERTICAL
;
818 wwin
->flags
.maximized
= MAX_HORIZONTAL
;
820 wwin
->flags
.maximized
= MAX_VERTICAL
|MAX_HORIZONTAL
;
822 if (getAreaHint(wwin
->client_win
, _XA_KWM_WIN_GEOMETRY_RESTORE
, &area
)
823 && (wwin
->old_geometry
.x
!= area
.x1
824 || wwin
->old_geometry
.y
!= area
.y1
825 || wwin
->old_geometry
.width
!= area
.x2
- area
.x1
826 || wwin
->old_geometry
.height
!= area
.y2
- area
.y1
)) {
828 wwin
->old_geometry
.x
= area
.x1
;
829 wwin
->old_geometry
.y
= area
.y1
;
830 wwin
->old_geometry
.width
= area
.x2
- area
.x1
;
831 wwin
->old_geometry
.height
= area
.y2
- area
.y1
;
837 wKWMCheckClientHintChange(WWindow
*wwin
, XPropertyEvent
*event
)
839 Bool processed
= True
;
848 if (event
->atom
== _XA_KWM_WIN_UNSAVED_DATA
) {
850 printf("got KDE unsaved data change\n");
853 flag
= getSimpleHint(wwin
->client_win
, _XA_KWM_WIN_UNSAVED_DATA
,
856 if (flag
!= wwin
->client_flags
.broken_close
) {
857 wwin
->client_flags
.broken_close
= flag
;
859 wWindowUpdateButtonImages(wwin
);
861 } else if (event
->atom
== _XA_KWM_WIN_STICKY
) {
864 printf("got KDE sticky change\n");
866 flag
= !getSimpleHint(wwin
->client_win
, _XA_KWM_WIN_STICKY
,
869 if (flag
!= wwin
->client_flags
.omnipresent
) {
871 wWindowSetOmnipresent(wwin
, flag
);
873 } else if (event
->atom
== _XA_KWM_WIN_MAXIMIZED
) {
877 printf("got KDE maximize change\n");
879 flag
= getSimpleHint(wwin
->client_win
, _XA_KWM_WIN_MAXIMIZED
, &value
);
883 bla
= MAX_VERTICAL
|MAX_HORIZONTAL
;
887 bla
= MAX_HORIZONTAL
;
890 if (bla
!= wwin
->flags
.maximized
) {
892 wMaximizeWindow(wwin
, bla
);
894 wUnmaximizeWindow(wwin
);
896 } else if (event
->atom
== _XA_KWM_WIN_ICONIFIED
) {
899 printf("got KDE iconify change\n");
901 flag
= !getSimpleHint(wwin
->client_win
, _XA_KWM_WIN_ICONIFIED
,
904 if (flag
!= wwin
->flags
.miniaturized
) {
907 wIconifyWindow(wwin
);
909 wDeiconifyWindow(wwin
);
912 } else if (event
->atom
== _XA_KWM_WIN_DECORATION
) {
913 Bool refresh
= False
;
917 printf("got KDE decoration change\n");
920 oldnofocus
= wwin
->client_flags
.no_focusable
;
922 if (getSimpleHint(wwin
->client_win
, _XA_KWM_WIN_DECORATION
, &value
)) {
923 wwin
->client_flags
.no_focusable
= (value
& KWMnoFocus
)!=0;
925 switch (value
& ~KWMnoFocus
) {
926 case KWMnoDecoration
:
927 if (!WFLAGP(wwin
, no_titlebar
) || !WFLAGP(wwin
, no_resizebar
))
930 wwin
->client_flags
.no_titlebar
= 1;
931 wwin
->client_flags
.no_resizebar
= 1;
934 case KWMtinyDecoration
:
935 if (WFLAGP(wwin
, no_titlebar
) || !WFLAGP(wwin
, no_resizebar
))
938 wwin
->client_flags
.no_titlebar
= 0;
939 wwin
->client_flags
.no_resizebar
= 1;
942 case KWMnormalDecoration
:
944 if (WFLAGP(wwin
, no_titlebar
) || WFLAGP(wwin
, no_resizebar
))
947 wwin
->client_flags
.no_titlebar
= 0;
948 wwin
->client_flags
.no_resizebar
= 0;
952 if (WFLAGP(wwin
, no_titlebar
) || WFLAGP(wwin
, no_resizebar
))
954 wwin
->client_flags
.no_focusable
= (value
& KWMnoFocus
)!=0;
955 wwin
->client_flags
.no_titlebar
= 0;
956 wwin
->client_flags
.no_resizebar
= 0;
960 wWindowConfigureBorders(wwin
);
962 if (wwin
->client_flags
.no_focusable
&& !oldnofocus
) {
964 sendToModules(wwin
->screen_ptr
, _XA_KWM_MODULE_WIN_REMOVE
,
966 wwin
->flags
.kwm_hidden_for_modules
= 1;
968 } else if (!wwin
->client_flags
.no_focusable
&& oldnofocus
) {
970 if (wwin
->flags
.kwm_hidden_for_modules
) {
971 sendToModules(wwin
->screen_ptr
, _XA_KWM_MODULE_WIN_ADD
,
973 wwin
->flags
.kwm_hidden_for_modules
= 0;
976 } else if (event
->atom
== _XA_KWM_WIN_DESKTOP
&& wwin
->frame
) {
978 printf("got KDE workspace change for %s\n", wwin
->frame
->title
);
980 if (getSimpleHint(wwin
->client_win
, _XA_KWM_WIN_DESKTOP
, &value
)
981 && value
-1 != wwin
->frame
->workspace
) {
982 wWindowChangeWorkspace(wwin
, value
-1);
985 } else if (event
->atom
== _XA_KWM_WIN_GEOMETRY_RESTORE
) {
989 printf("got KDE geometry restore change\n");
991 if (getAreaHint(wwin
->client_win
, _XA_KWM_WIN_GEOMETRY_RESTORE
, &area
)
992 && (wwin
->old_geometry
.x
!= area
.x1
993 || wwin
->old_geometry
.y
!= area
.y1
994 || wwin
->old_geometry
.width
!= area
.x2
- area
.x1
995 || wwin
->old_geometry
.height
!= area
.y2
- area
.y1
)) {
997 wwin
->old_geometry
.x
= area
.x1
;
998 wwin
->old_geometry
.y
= area
.y1
;
999 wwin
->old_geometry
.width
= area
.x2
- area
.x1
;
1000 wwin
->old_geometry
.height
= area
.y2
- area
.y1
;
1011 performWindowCommand(WScreen
*scr
, char *command
)
1013 WWindow
*wwin
= NULL
;
1016 wwin
= scr
->focused_window
;
1017 if (!wwin
|| !wwin
->flags
.focused
|| !wwin
->flags
.mapped
) {
1021 CloseWindowMenu(scr
);
1024 if (strcmp(command
, "winMove")==0 || strcmp(command
, "winResize")==0) {
1027 wKeyboardMoveResizeWindow(wwin
);
1029 } else if (strcmp(command
, "winMaximize")==0) {
1032 wMaximizeWindow(wwin
, MAX_VERTICAL
|MAX_HORIZONTAL
);
1034 } else if (strcmp(command
, "winRestore")==0) {
1036 if (wwin
&& wwin
->flags
.maximized
)
1037 wUnmaximizeWindow(wwin
);
1039 } else if (strcmp(command
, "winIconify")==0) {
1042 if (wwin
&& !WFLAGP(wwin
, no_miniaturizable
)) {
1043 if (wwin
->protocols
.MINIATURIZE_WINDOW
)
1044 wClientSendProtocol(wwin
, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
,
1047 wIconifyWindow(wwin
);
1051 } else if (strcmp(command
, "winClose")==0) {
1053 if (wwin
&& !WFLAGP(wwin
, no_closable
)) {
1054 if (wwin
->protocols
.DELETE_WINDOW
)
1055 wClientSendProtocol(wwin
, _XA_WM_DELETE_WINDOW
, LastTimestamp
);
1058 } else if (strcmp(command
, "winSticky")==0) {
1061 wWindowSetOmnipresent(wwin
, !wwin
->client_flags
.omnipresent
);
1064 } else if (strcmp(command
, "winShade")==0) {
1066 if (wwin
&& !WFLAGP(wwin
, no_shadeable
)) {
1067 if (wwin
->flags
.shaded
)
1068 wUnshadeWindow(wwin
);
1073 } else if (strcmp(command
, "winOperation")==0) {
1076 OpenWindowMenu(wwin
, wwin
->frame_x
,
1077 wwin
->frame_y
+wwin
->frame
->top_width
, True
);
1088 performCommand(WScreen
*scr
, char *command
, XClientMessageEvent
*event
)
1090 assert(scr
!= NULL
);
1092 if (strcmp(command
, "commandLine")==0
1093 || strcmp(command
, "execute")==0) {
1096 cmd
= ExpandOptions(scr
, _("%a(Run Command,Type the command to run:)"));
1098 ExecuteShellCommand(scr
, cmd
);
1101 } else if (strcmp(command
, "logout")==0) {
1103 Shutdown(WSLogoutMode
);
1105 } else if (strcmp(command
, "refreshScreen")==0) {
1107 wRefreshDesktop(scr
);
1109 } else if (strncmp(command
, "go:", 3)==0) {
1111 Shutdown(WSRestartPreparationMode
);
1112 Restart(&command
[3], False
);
1113 Restart(NULL
, True
);
1115 } else if (strcmp(command
, "desktop+1")==0) {
1117 wWorkspaceRelativeChange(scr
, 1);
1119 } else if (strcmp(command
, "desktop-1")==0) {
1121 wWorkspaceRelativeChange(scr
, -1);
1123 } else if (strcmp(command
, "desktop+2")==0) {
1125 wWorkspaceRelativeChange(scr
, 2);
1127 } else if (strcmp(command
, "desktop-2")==0) {
1129 wWorkspaceRelativeChange(scr
, -2);
1131 } else if (strcmp(command
, "desktop%%2")==0) {
1133 if (scr
->current_workspace
% 2 == 1)
1134 wWorkspaceRelativeChange(scr
, 1);
1136 wWorkspaceRelativeChange(scr
, -1);
1137 } else if (strncmp(command
, "desktop", 7)==0) {
1140 ws
= atoi(&command
[7]);
1141 wWorkspaceChange(scr
, ws
);
1143 /* wmaker specific stuff */
1144 } else if (strcmp(command
, "wmaker:info")==0) {
1146 wShowInfoPanel(scr
);
1148 } else if (strcmp(command
, "wmaker:legal")==0) {
1150 wShowLegalPanel(scr
);
1152 } else if (strcmp(command
, "wmaker:arrangeIcons")==0) {
1154 wArrangeIcons(scr
, True
);
1156 } else if (strcmp(command
, "wmaker:showAll")==0) {
1158 wShowAllWindows(scr
);
1160 } else if (strcmp(command
, "wmaker:hideOthers")==0) {
1162 wHideOtherApplications(scr
->focused_window
);
1164 } else if (strcmp(command
, "wmaker:restart")==0) {
1166 Shutdown(WSRestartPreparationMode
);
1167 Restart(NULL
, True
);
1169 } else if (strcmp(command
, "wmaker:exit")==0) {
1171 Shutdown(WSExitMode
);
1173 #ifdef UNSUPPORTED_STUFF
1174 } else if (strcmp(command
, "moduleRaised")==0) { /* useless */
1175 } else if (strcmp(command
, "deskUnclutter")==0) {
1176 } else if (strcmp(command
, "deskCascade")==0) {
1177 } else if (strcmp(command
, "configure")==0) {
1178 } else if (strcmp(command
, "taskManager")==0) {
1179 } else if (strcmp(command
, "darkenScreen")==0) { /* breaks consistency */
1181 } else if (!performWindowCommand(scr
, command
)) {
1182 KWMModuleList
*module
;
1185 /* do message relay thing */
1187 ev
.xclient
= *event
;
1188 for (module
= KWMModules
; module
!= NULL
; module
= module
->next
) {
1190 ev
.xclient
.window
= module
->window
;
1191 if (module
->window
== scr
->root_win
)
1192 mask
= SubstructureRedirectMask
;
1196 XSendEvent(dpy
, module
->window
, False
, mask
, &ev
);
1203 wKWMProcessClientMessage(XClientMessageEvent
*event
)
1205 Bool processed
= True
;
1208 printf("CLIENT MESS %s\n", XGetAtomName(dpy
, event
->message_type
));
1210 if (event
->message_type
== _XA_KWM_COMMAND
&& event
->format
==8) {
1214 scr
= wScreenForRootWindow(event
->window
);
1216 for (i
=0; i
<20; i
++) {
1217 buffer
[i
] = event
->data
.b
[i
];
1222 printf("got KDE command %s\n", buffer
);
1224 performCommand(scr
, buffer
, event
);
1226 } else if (event
->message_type
== _XA_KWM_ACTIVATE_WINDOW
) {
1230 printf("got KDE activate internal\n");
1232 wwin
= wWindowFor(event
->data
.l
[0]);
1235 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1237 } else if (event
->message_type
== _XA_KWM_DO_NOT_MANAGE
1238 && event
->format
== 8) {
1239 KWMDoNotManageList
*node
;
1243 printf("got KDE dont manage\n");
1246 node
= malloc(sizeof(KWMDoNotManageList
));
1248 wwarning("out of memory processing KWM_DO_NOT_MANAGE message");
1250 for (i
=0; i
<20 && event
->data
.b
[i
]; i
++)
1251 node
->title
[i
] = event
->data
.b
[i
];
1254 node
->next
= KWMDoNotManageCrap
;
1255 KWMDoNotManageCrap
= node
;
1257 } else if (event
->message_type
== _XA_KWM_MODULE
) {
1259 Window modwin
= event
->data
.l
[0];
1261 scr
= wScreenForRootWindow(event
->window
);
1263 if (getSimpleHint(modwin
, _XA_KWM_MODULE
, &val
) && val
) {
1265 puts("got KDE module startup");
1267 addModule(scr
, modwin
);
1270 puts("got KDE module finish");
1272 removeModule(scr
, modwin
);
1283 wKWMCheckModule(WScreen
*scr
, Window window
)
1287 if (getSimpleHint(window
, _XA_KWM_MODULE
, &val
) && val
) {
1289 puts("got KDE module startup");
1291 addModule(scr
, window
);
1297 wKWMCheckRootHintChange(WScreen
*scr
, XPropertyEvent
*event
)
1299 Bool processed
= True
;
1302 if (event
->atom
== _XA_KWM_CURRENT_DESKTOP
) {
1303 if (getSimpleHint(scr
->root_win
, _XA_KWM_CURRENT_DESKTOP
, &value
)) {
1305 printf("got KDE workspace switch to %li\n", value
);
1307 if (value
-1 != scr
->current_workspace
) {
1308 wWorkspaceChange(scr
, value
-1);
1311 } else if (event
->atom
== _XA_KWM_NUMBER_OF_DESKTOPS
) {
1313 printf("got KDE workspace number change\n");
1316 if (getSimpleHint(scr
->root_win
, _XA_KWM_NUMBER_OF_DESKTOPS
, &value
)) {
1318 /* increasing is easy... */
1319 if (value
> scr
->workspace_count
) {
1320 scr
->flags
.kwm_syncing_count
= 1;
1322 wWorkspaceMake(scr
, value
- scr
->workspace_count
);
1324 scr
->flags
.kwm_syncing_count
= 0;
1326 } else if (value
< scr
->workspace_count
) {
1328 Bool rebuild
= False
;
1330 scr
->flags
.kwm_syncing_count
= 1;
1332 /* decrease all we can do */
1333 for (i
= scr
->workspace_count
; i
>= value
; i
--) {
1334 if (!wWorkspaceDelete(scr
, i
)) {
1340 scr
->flags
.kwm_syncing_count
= 0;
1342 /* someone destroyed a workspace that can't be destroyed.
1343 * Reset the hints to reflect our internal state.
1346 wKWMUpdateWorkspaceCountHint(scr
);
1355 for (i
= 0; i
< MAX_WORKSPACES
&& i
< scr
->workspace_count
; i
++) {
1356 if (event
->atom
== _XA_KWM_DESKTOP_NAME_
[i
]) {
1359 name
= wKWMGetWorkspaceName(scr
, i
);
1362 printf("got KDE workspace name change to %s\n", name
);
1365 if (name
&& strncmp(name
, scr
->workspaces
[i
]->name
,
1366 MAX_WORKSPACENAME_WIDTH
)!=0) {
1367 scr
->flags
.kwm_syncing_name
= 1;
1368 wWorkspaceRename(scr
, i
, name
);
1369 scr
->flags
.kwm_syncing_name
= 0;
1375 } else if (event
->atom
== _XA_KWM_WINDOW_REGION_
[i
]) {
1378 if (getAreaHint(scr
->root_win
, event
->atom
, &area
)) {
1380 if (scr
->totalUsableArea
.x1
!= area
.x1
1381 || scr
->totalUsableArea
.y1
!= area
.y1
1382 || scr
->totalUsableArea
.x2
!= area
.x2
1383 || scr
->totalUsableArea
.y2
!= area
.y2
) {
1384 wScreenUpdateUsableArea(scr
);
1399 wKWMManageableClient(WScreen
*scr
, Window win
, char *title
)
1401 KWMDoNotManageList
*ptr
, *next
;
1404 if (getSimpleHint(win
, _XA_KWM_DOCKWINDOW
, &val
) && val
) {
1405 addDockWindow(scr
, win
);
1409 ptr
= KWMDoNotManageCrap
;
1411 * TODO: support for glob patterns or regexes
1413 if (ptr
&& strncmp(ptr
->title
, title
, strlen(ptr
->title
))==0) {
1416 KWMDoNotManageCrap
= next
;
1418 printf("window %s not managed per KDE request\n", title
);
1421 sendToModules(scr
, _XA_KWM_MODULE_WIN_ADD
, NULL
, win
);
1422 sendToModules(scr
, _XA_KWM_MODULE_WIN_REMOVE
, NULL
, win
);
1427 if (strncmp(ptr
->next
->title
, title
, strlen(ptr
->next
->title
))==0) {
1429 printf("window %s not managed per KDE request\n", title
);
1431 next
= ptr
->next
->next
;
1435 sendToModules(scr
, _XA_KWM_MODULE_WIN_ADD
, NULL
, win
);
1436 sendToModules(scr
, _XA_KWM_MODULE_WIN_REMOVE
, NULL
, win
);
1450 wKWMUpdateCurrentWorkspaceHint(WScreen
*scr
)
1452 setSimpleHint(scr
->root_win
, _XA_KWM_CURRENT_DESKTOP
,
1453 scr
->current_workspace
+1);
1455 sendToModules(scr
, _XA_KWM_MODULE_DESKTOP_CHANGE
, NULL
,
1456 scr
->current_workspace
+1);
1461 wKWMUpdateActiveWindowHint(WScreen
*scr
)
1464 WWindow
*wwin
, *tmp
;
1466 if (!scr
->focused_window
|| !scr
->focused_window
->flags
.focused
)
1469 val
= (long)(scr
->focused_window
->client_win
);
1471 /* raise the menubar thing */
1472 wwin
= scr
->focused_window
;
1475 if (tmp
->flags
.kwm_menubar
1476 && tmp
->transient_for
== wwin
->client_win
) {
1477 wRaiseFrame(tmp
->frame
->core
);
1484 XChangeProperty(dpy
, scr
->root_win
, _XA_KWM_ACTIVE_WINDOW
,
1485 _XA_KWM_ACTIVE_WINDOW
, 32, PropModeReplace
,
1486 (unsigned char*)&val
, 1);
1492 wKWMUpdateWorkspaceCountHint(WScreen
*scr
)
1494 if (scr
->flags
.kwm_syncing_count
)
1497 setSimpleHint(scr
->root_win
, _XA_KWM_NUMBER_OF_DESKTOPS
,
1498 scr
->workspace_count
);
1500 sendToModules(scr
, _XA_KWM_MODULE_DESKTOP_NUMBER_CHANGE
, NULL
,
1501 scr
->workspace_count
);
1506 wKWMCheckDestroy(XDestroyWindowEvent
*event
)
1510 if (event
->event
== event
->window
) {
1514 scr
= wScreenSearchForRootWindow(event
->event
);
1519 removeModule(scr
, event
->window
);
1520 removeDockWindow(scr
, event
->window
);
1525 wKWMUpdateWorkspaceNameHint(WScreen
*scr
, int workspace
)
1529 assert(workspace
>= 0 && workspace
< MAX_WORKSPACES
);
1531 if (_XA_KWM_DESKTOP_NAME_
[workspace
]==0) {
1532 snprintf(buffer
, sizeof(buffer
), "KWM_DESKTOP_NAME_%d", workspace
+ 1);
1534 _XA_KWM_DESKTOP_NAME_
[workspace
] = XInternAtom(dpy
, buffer
, False
);
1537 XChangeProperty(dpy
, scr
->root_win
, _XA_KWM_DESKTOP_NAME_
[workspace
],
1538 XA_STRING
, 8, PropModeReplace
,
1539 (unsigned char*)scr
->workspaces
[workspace
]->name
,
1540 strlen(scr
->workspaces
[workspace
]->name
)+1);
1542 sendToModules(scr
, _XA_KWM_MODULE_DESKTOP_NAME_CHANGE
, NULL
, workspace
+1);
1548 wKWMUpdateClientWorkspace(WWindow
*wwin
)
1551 printf("updating workspace of %s to %i\n",
1552 wwin
->frame
->title
, wwin
->frame
->workspace
+1);
1554 setSimpleHint(wwin
->client_win
, _XA_KWM_WIN_DESKTOP
,
1555 wwin
->frame
->workspace
+1);
1560 wKWMUpdateClientGeometryRestore(WWindow
*wwin
)
1564 rect
.x1
= wwin
->old_geometry
.x
;
1565 rect
.y1
= wwin
->old_geometry
.y
;
1566 rect
.x2
= wwin
->old_geometry
.x
+ wwin
->old_geometry
.width
;
1567 rect
.y2
= wwin
->old_geometry
.y
+ wwin
->old_geometry
.height
;
1569 setAreaHint(wwin
->client_win
, _XA_KWM_WIN_GEOMETRY_RESTORE
, rect
);
1574 wKWMUpdateClientStateHint(WWindow
*wwin
, WKWMStateFlag flags
)
1576 if (flags
& KWMIconifiedFlag
) {
1577 setSimpleHint(wwin
->client_win
, _XA_KWM_WIN_ICONIFIED
,
1578 wwin
->flags
.miniaturized
/*|| wwin->flags.shaded
1579 || wwin->flags.hidden*/);
1581 if (flags
& KWMStickyFlag
) {
1582 setSimpleHint(wwin
->client_win
, _XA_KWM_WIN_STICKY
,
1583 IS_OMNIPRESENT(wwin
));
1585 if (flags
& KWMMaximizedFlag
) {
1588 if (wwin
->flags
.maximized
& MAX_VERTICAL
)
1590 if (wwin
->flags
.maximized
& MAX_HORIZONTAL
)
1593 setSimpleHint(wwin
->client_win
, _XA_KWM_WIN_MAXIMIZED
, value
);
1599 wKWMGetUsableArea(WScreen
*scr
, WArea
*area
)
1603 if (_XA_KWM_WINDOW_REGION_
[0]==0) {
1604 snprintf(buffer
, sizeof(buffer
), "KWM_WINDOW_REGION_%d", 1);
1606 _XA_KWM_WINDOW_REGION_
[0] = XInternAtom(dpy
, buffer
, False
);
1609 return getAreaHint(scr
->root_win
, _XA_KWM_WINDOW_REGION_
[0], area
);
1615 wKWMGetIconGeometry(WWindow
*wwin
, WArea
*area
)
1617 return getAreaHint(wwin
->client_win
, _XA_KWM_WIN_ICON_GEOMETRY
, area
);
1624 wKWMSetUsableAreaHint(WScreen
*scr
, int workspace
)
1626 /* if we set this after making changes of our own to the area,
1627 * the next time the area changes, we won't know what should
1628 * be the new final area. This protocol isn't worth a shit :/
1631 * According to Matthias Ettrich:
1632 * Indeed, there's no protocol to deal with the area yet in case several
1633 * clients want to influence it. It is sufficent, though, if it is clear
1634 * that one process is responsable for the area. For KDE this is kpanel, but
1635 * I see that there might be a conflict with the docking area of windowmaker
1643 assert(workspace
>= 0 && workspace
< MAX_WORKSPACES
);
1645 if (_XA_KWM_WINDOW_REGION_
[workspace
]==0) {
1646 snprintf(buffer
, sizeof(buffer
), "KWM_WINDOW_REGION_%d", workspace
+1);
1648 _XA_KWM_WINDOW_REGION_
[workspace
] = XInternAtom(dpy
, buffer
, False
);
1651 setAreaHint(scr
->root_win
, _XA_KWM_WINDOW_REGION_
[workspace
],
1652 scr
->totalUsableArea
);
1655 #endif /* not_used */
1658 wKWMSendEventMessage(WWindow
*wwin
, WKWMEventMessage message
)
1662 if (wwin
&& (wwin
->flags
.internal_window
1663 || wwin
->flags
.kwm_hidden_for_modules
1664 || !wwin
->flags
.kwm_managed
1665 || WFLAGP(wwin
, skip_window_list
)))
1670 msg
= _XA_KWM_MODULE_WIN_ADD
;
1672 case WKWMRemoveWindow
:
1673 msg
= _XA_KWM_MODULE_WIN_REMOVE
;
1675 case WKWMFocusWindow
:
1676 msg
= _XA_KWM_MODULE_WIN_ACTIVATE
;
1678 case WKWMRaiseWindow
:
1679 msg
= _XA_KWM_MODULE_WIN_RAISE
;
1681 case WKWMLowerWindow
:
1682 msg
= _XA_KWM_MODULE_WIN_LOWER
;
1684 case WKWMChangedClient
:
1685 msg
= _XA_KWM_MODULE_WIN_CHANGE
;
1687 case WKWMIconChange
:
1688 msg
= _XA_KWM_MODULE_WIN_ICON_CHANGE
;
1694 sendToModules(wwin
? wwin
->screen_ptr
: NULL
, msg
, wwin
, 0);
1699 writeSocket(int sock
, char *data
)
1703 snprintf(buffer
, sizeof(buffer
), "%i ", strlen(data
));
1704 write(sock
, buffer
, strlen(buffer
));
1705 write(sock
, data
, strlen(data
));
1710 connectKFM(WScreen
*scr
)
1718 struct sockaddr_un addr
;
1721 path
= wstrconcat(wgethomedir(), "/.kde/share/apps/kfm/pid");
1722 buffer
= wstrdup(getenv("DISPLAY"));
1724 ptr
= strchr(buffer
, ':');
1728 ptr
= strrchr(buffer
, '.');
1734 snprintf(b
, sizeof(b
), ".%i", scr
->screen
);
1736 buffer
= wstrappend(buffer
, b
);
1738 path
= wstrappend(path
, buffer
);
1742 f
= fopen(path
, "r");
1748 fgets(buf
, sizeof(buf
), f
);
1749 buf
[sizeof(buf
)] = 0;
1754 if (kill(pid
, 0) != 0)
1758 fgets(buf
, sizeof(buf
), f
);
1759 buf
[sizeof(buf
)] = 0;
1762 sock
= socket(AF_UNIX
, SOCK_STREAM
, 0);
1765 addr
.sun_family
= AF_UNIX
;
1766 strcpy(addr
.sun_path
, buf
);
1768 if (connect(sock
, (struct sockaddr
*)&addr
, sizeof(addr
)) < 0) {
1773 path
= wstrconcat(wgethomedir(), "/.kde/share/apps/kfm/magic");
1774 f
= fopen(path
, "r");
1779 ptr
= fgets(buf
, sizeof(buf
), f
);
1786 ptr
= wstrconcat("auth", buf
);
1788 writeSocket(sock
, ptr
);
1796 wKWMSelectRootRegion(WScreen
*scr
, int x
, int y
, int w
, int h
, Bool control
)
1803 sock
= connectKFM(scr
);
1806 puts("SENDING DATA");
1808 sprintf(buffer
, "selectRootIcons %i %i %i %i %c", x
, y
, w
, h
, control
);
1809 writeSocket(sock
, buffer
);
1818 static void observer(void *self
, WMNotification
*notif
)
1820 WScreen
*scr
= (WScreen
*)self
;
1821 WWindow
*wwin
= (WWindow
*)WMGetNotificationObject(notif
);
1822 const char *name
= WMGetNotificationName(notif
);
1823 void *data
= WMGetNotificationClientData(notif
);
1825 if (strcmp(name
, WMNManaged
) == 0 && wwin
) {
1826 wKWMUpdateClientWorkspace(wwin
);
1827 wKWMUpdateClientStateHint(wwin
, KWMAllFlags
);
1829 wwin
->flags
.kwm_managed
= 1;
1831 wKWMSendEventMessage(wwin
, WKWMAddWindow
);
1833 } else if (strcmp(name
, WMNUnmanaged
) == 0 && wwin
) {
1834 wwin
->frame
->workspace
= -1;
1836 wKWMUpdateClientWorkspace(wwin
);
1838 wKWMSendEventMessage(wwin
, WKWMRemoveWindow
);
1840 } else if (strcmp(name
, WMNChangedWorkspace
) == 0 && wwin
) {
1841 wKWMUpdateClientWorkspace(wwin
);
1842 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
1844 } else if (strcmp(name
, WMNChangedFocus
) == 0) {
1845 wKWMUpdateActiveWindowHint(scr
);
1846 wKWMSendEventMessage(wwin
, WKWMFocusWindow
);
1848 } else if (strcmp(name
, WMNChangedName
) == 0) {
1849 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
1851 } else if (strcmp(name
, WMNChangedState
) == 0) {
1852 char *detail
= (char*)data
;
1854 if (strcmp(detail
, "shade") == 0) {
1855 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
1856 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
1857 } else if (strcmp(detail
, "omnipresent") == 0) {
1858 wKWMUpdateClientStateHint(wwin
, KWMStickyFlag
);
1859 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
1860 } else if (strcmp(detail
, "maximize") == 0) {
1861 wKWMUpdateClientStateHint(wwin
, KWMMaximizedFlag
);
1862 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
1863 } else if (strcmp(detail
, "iconify-transient") == 0) {
1864 if (wwin
->flags
.miniaturized
) {
1865 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
1866 wKWMSendEventMessage(wwin
, WKWMRemoveWindow
);
1867 wwin
->flags
.kwm_hidden_for_modules
= 1;
1869 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
1870 if (wwin
->flags
.kwm_hidden_for_modules
) {
1871 wKWMSendEventMessage(wwin
, WKWMAddWindow
);
1872 wwin
->flags
.kwm_hidden_for_modules
= 0;
1875 } else if (strcmp(detail
, "iconify") == 0) {
1876 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
1877 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
1878 } else if (strcmp(detail
, "hide") == 0) {
1879 wKWMUpdateClientStateHint(wwin
, KWMIconifiedFlag
);
1880 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
1883 } else if (strcmp(name
, WMNChangedStacking
) == 0 && wwin
) {
1885 wKWMBroadcastStacking(wwin
->screen_ptr
);
1886 else if (strcmp(data
, "lower") == 0)
1887 wKWMSendEventMessage(wwin
, WKWMLowerWindow
);
1888 else if (strcmp(data
, "raise") == 0)
1889 wKWMSendEventMessage(wwin
, WKWMRaiseWindow
);
1894 static void wsobserver(void *self
, WMNotification
*notif
)
1896 WScreen
*scr
= (WScreen
*)WMGetNotificationObject(notif
);
1897 const char *name
= WMGetNotificationName(notif
);
1898 void *data
= WMGetNotificationClientData(notif
);
1900 if (strcmp(name
, WMNWorkspaceCreated
) == 0) {
1901 if (!scr
->flags
.kwm_syncing_count
) {
1902 wKWMUpdateWorkspaceCountHint(scr
);
1903 wKWMUpdateWorkspaceNameHint(scr
, (int)data
);
1906 wKWMSetUsableAreaHint(scr
, scr
->workspace_count
-1);
1908 } else if (strcmp(name
, WMNWorkspaceDestroyed
) == 0) {
1909 wKWMUpdateWorkspaceCountHint(scr
);
1910 } else if (strcmp(name
, WMNWorkspaceNameChanged
) == 0) {
1911 wKWMUpdateWorkspaceNameHint(scr
, (int)data
);
1912 } else if (strcmp(name
, WMNWorkspaceChanged
) == 0) {
1913 wKWMUpdateCurrentWorkspaceHint(scr
);
1915 } else if (strcmp(name
, WMNResetStacking
) == 0) {
1916 wKWMBroadcastStacking(scr
);
1921 #endif /* KWM_HINTS */