1 /* screen.c - screen management
3 * Window Maker window manager
5 * Copyright (c) 1997, 1998 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,
30 #include <X11/Xutil.h>
32 #include <X11/extensions/shape.h>
37 #include "WindowMaker.h"
38 #include "def_pixmaps.h"
45 #include "properties.h"
47 #include "resources.h"
48 #include "workspace.h"
64 #define EVENT_MASK (LeaveWindowMask|EnterWindowMask|PropertyChangeMask\
65 |SubstructureNotifyMask|PointerMotionMask \
66 |SubstructureRedirectMask|KeyPressMask|KeyReleaseMask)
68 #define EVENT_MASK (LeaveWindowMask|EnterWindowMask|PropertyChangeMask\
69 |SubstructureNotifyMask|PointerMotionMask \
70 |SubstructureRedirectMask|ButtonPressMask|ButtonReleaseMask\
71 |KeyPressMask|KeyReleaseMask)
74 /**** Global variables ****/
76 extern Cursor wCursor
[WCUR_LAST
];
77 extern WPreferences wPreferences
;
78 extern Atom _XA_WINDOWMAKER_STATE
;
81 extern int wScreenCount
;
83 extern WDDomain
*WDWindowMaker
;
88 #define STIPPLE_WIDTH 2
89 #define STIPPLE_HEIGHT 2
90 static char STIPPLE_DATA
[] = {0x02, 0x01};
92 static int CantManageScreen
= 0;
94 static proplist_t dApplications
= NULL
;
95 static proplist_t dWorkspace
;
96 static proplist_t dDock
;
97 static proplist_t dClip
;
103 if (dApplications
!=NULL
)
106 dApplications
= PLMakeString("Applications");
107 dWorkspace
= PLMakeString("Workspace");
108 dDock
= PLMakeString("Dock");
109 dClip
= PLMakeString("Clip");
114 *----------------------------------------------------------------------
115 * alreadyRunningError--
116 * X error handler used to catch errors when trying to do
117 * XSelectInput() on the root window. These errors probably mean that
118 * there already is some other window manager running.
121 * Nothing, unless something really evil happens...
124 * CantManageScreen is set to 1;
125 *----------------------------------------------------------------------
128 alreadyRunningError(Display
*dpy
, XErrorEvent
*error
)
130 CantManageScreen
= 1;
136 *----------------------------------------------------------------------
137 * allocButtonPixmaps--
138 * Allocate pixmaps used on window operation buttons (those in the
139 * titlebar). The pixmaps are linked to the program. If XPM is supported
140 * XPM pixmaps are used otherwise, equivalent bitmaps are used.
146 * Allocates shared pixmaps for the screen. These pixmaps should
147 * not be freed by anybody.
148 *----------------------------------------------------------------------
151 allocButtonPixmaps(WScreen
*scr
)
155 /* create predefined pixmaps */
156 pix
= wPixmapCreateFromXPMData(scr
, PRED_CLOSE_XPM
);
159 scr
->b_pixmaps
[WBUT_CLOSE
] = pix
;
161 pix
= wPixmapCreateFromXPMData(scr
, PRED_BROKEN_CLOSE_XPM
);
164 scr
->b_pixmaps
[WBUT_BROKENCLOSE
] = pix
;
166 pix
= wPixmapCreateFromXPMData(scr
, PRED_ICONIFY_XPM
);
169 scr
->b_pixmaps
[WBUT_ICONIFY
] = pix
;
171 pix
= wPixmapCreateFromXPMData(scr
, PRED_KILL_XPM
);
174 scr
->b_pixmaps
[WBUT_KILL
] = pix
;
180 draw_dot(WScreen
*scr
, Drawable d
, int x
, int y
, GC gc
)
182 XSetForeground(dpy
, gc
, scr
->black_pixel
);
183 XDrawLine(dpy
, d
, gc
, x
, y
, x
+1, y
);
184 XDrawPoint(dpy
, d
, gc
, x
, y
+1);
185 XSetForeground(dpy
, gc
, scr
->white_pixel
);
186 XDrawLine(dpy
, d
, gc
, x
+2, y
, x
+2, y
+1);
187 XDrawPoint(dpy
, d
, gc
, x
+1, y
+1);
192 make3Dots(WScreen
*scr
)
200 pix
= XCreatePixmap(dpy
, scr
->w_win
, wPreferences
.icon_size
,
201 wPreferences
.icon_size
, scr
->w_depth
);
202 XSetForeground(dpy
, gc
, scr
->black_pixel
);
203 XFillRectangle(dpy
, pix
, gc
, 0, 0, wPreferences
.icon_size
,
204 wPreferences
.icon_size
);
205 XSetForeground(dpy
, gc
, scr
->white_pixel
);
206 draw_dot(scr
, pix
, 4, wPreferences
.icon_size
-6, gc
);
207 draw_dot(scr
, pix
, 9, wPreferences
.icon_size
-6, gc
);
208 draw_dot(scr
, pix
, 14, wPreferences
.icon_size
-6, gc
);
210 mask
= XCreatePixmap(dpy
, scr
->w_win
, wPreferences
.icon_size
,
211 wPreferences
.icon_size
, 1);
213 gcv
.graphics_exposures
= False
;
214 gc2
= XCreateGC(dpy
, mask
, GCForeground
|GCGraphicsExposures
, &gcv
);
215 XFillRectangle(dpy
, mask
, gc2
, 0, 0, wPreferences
.icon_size
,
216 wPreferences
.icon_size
);
217 XSetForeground(dpy
, gc2
, 1);
218 XFillRectangle(dpy
, mask
, gc2
, 4, wPreferences
.icon_size
-6, 3, 2);
219 XFillRectangle(dpy
, mask
, gc2
, 9, wPreferences
.icon_size
-6, 3, 2);
220 XFillRectangle(dpy
, mask
, gc2
, 14, wPreferences
.icon_size
-6, 3, 2);
224 wpix
= wPixmapCreate(scr
, pix
, mask
);
232 allocGCs(WScreen
*scr
)
236 unsigned long mtextcolor
;
239 scr
->stipple_bitmap
=
240 XCreateBitmapFromData(dpy
, scr
->w_win
, STIPPLE_DATA
, STIPPLE_WIDTH
,
243 gcv
.stipple
= scr
->stipple_bitmap
;
244 gcv
.foreground
= scr
->white_pixel
;
245 gcv
.fill_style
= FillStippled
;
246 gcv
.graphics_exposures
= False
;
247 gcm
= GCForeground
|GCStipple
|GCFillStyle
|GCGraphicsExposures
;
248 scr
->stipple_gc
= XCreateGC(dpy
, scr
->w_win
, gcm
, &gcv
);
251 /* selected icon border GCs */
252 gcv
.function
= GXcopy
;
253 gcv
.foreground
= scr
->white_pixel
;
254 gcv
.background
= scr
->black_pixel
;
256 gcv
.line_style
= LineDoubleDash
;
257 gcv
.fill_style
= FillSolid
;
260 gcv
.graphics_exposures
= False
;
262 gcm
= GCFunction
| GCGraphicsExposures
;
263 gcm
|= GCForeground
| GCBackground
;
264 gcm
|= GCLineWidth
| GCLineStyle
;
266 gcm
|= GCDashOffset
| GCDashList
;
268 scr
->icon_select_gc
= XCreateGC(dpy
, scr
->w_win
, gcm
, &gcv
);
270 gcm
= GCForeground
|GCGraphicsExposures
;
272 scr
->menu_title_pixel
[0] = scr
->white_pixel
;
273 gcv
.foreground
= scr
->white_pixel
;
274 gcv
.graphics_exposures
= False
;
275 scr
->menu_title_gc
= XCreateGC(dpy
, scr
->w_win
, gcm
, &gcv
);
277 scr
->mtext_pixel
= scr
->black_pixel
;
278 mtextcolor
= gcv
.foreground
= scr
->black_pixel
;
279 scr
->menu_entry_gc
= XCreateGC(dpy
, scr
->w_win
, gcm
, &gcv
);
281 /* selected menu entry GC */
282 gcm
= GCForeground
|GCBackground
|GCGraphicsExposures
;
283 gcv
.foreground
= scr
->white_pixel
;
284 gcv
.background
= scr
->white_pixel
;
285 gcv
.graphics_exposures
= False
;
286 scr
->select_menu_gc
= XCreateGC(dpy
, scr
->w_win
, gcm
, &gcv
);
288 /* disabled menu entry GC */
289 scr
->dtext_pixel
= scr
->black_pixel
;
290 gcm
= GCForeground
|GCBackground
|GCStipple
|GCGraphicsExposures
;
291 gcv
.stipple
= scr
->stipple_bitmap
;
292 gcv
.graphics_exposures
= False
;
293 scr
->disabled_menu_entry_gc
= XCreateGC(dpy
, scr
->w_win
, gcm
, &gcv
);
296 wGetColor(scr
, DEF_FRAME_COLOR
, &color
);
297 gcv
.function
= GXxor
;
298 /* this will raise the probability of the XORed color being different
299 * of the original color in PseudoColor when not all color cells are
301 if (DefaultVisual(dpy
, scr
->screen
)->class==PseudoColor
)
302 gcv
.plane_mask
= (1<<(scr
->depth
-1))|1;
304 gcv
.plane_mask
= AllPlanes
;
305 gcv
.foreground
= color
.pixel
;
306 if (gcv
.foreground
== 0)
308 gcv
.line_width
= DEF_FRAME_THICKNESS
;
309 gcv
.subwindow_mode
= IncludeInferiors
;
310 gcv
.graphics_exposures
= False
;
311 scr
->frame_gc
= XCreateGC(dpy
, scr
->root_win
, GCForeground
|GCGraphicsExposures
312 |GCFunction
|GCSubwindowMode
|GCLineWidth
316 gcv
.foreground
= color
.pixel
;
318 if (gcv
.foreground
== 0)
319 /* XOR:ing with a zero is not going to be of much use, so
320 in that case, we somewhat arbitrarily xor with 17 instead. */
323 gcv
.function
= GXxor
;
324 gcv
.subwindow_mode
= IncludeInferiors
;
326 gcv
.cap_style
= CapRound
;
327 gcv
.graphics_exposures
= False
;
328 gcm
= GCForeground
|GCFunction
|GCSubwindowMode
|GCLineWidth
|GCCapStyle
329 |GCGraphicsExposures
;
330 scr
->line_gc
= XCreateGC(dpy
, scr
->root_win
, gcm
, &gcv
);
332 scr
->line_pixel
= gcv
.foreground
;
335 gcv
.foreground
= scr
->white_pixel
;
336 gcv
.background
= scr
->black_pixel
;
337 gcv
.graphics_exposures
= False
;
338 scr
->copy_gc
= XCreateGC(dpy
, scr
->w_win
, GCForeground
|GCBackground
339 |GCGraphicsExposures
, &gcv
);
341 /* window title text GC */
342 gcv
.graphics_exposures
= False
;
343 scr
->window_title_gc
= XCreateGC(dpy
, scr
->w_win
,GCGraphicsExposures
,&gcv
);
346 scr
->icon_title_gc
= XCreateGC(dpy
, scr
->w_win
, GCGraphicsExposures
, &gcv
);
349 scr
->clip_title_gc
= XCreateGC(dpy
, scr
->w_win
, GCGraphicsExposures
, &gcv
);
351 /* move/size display GC */
352 gcv
.graphics_exposures
= False
;
353 gcm
= GCGraphicsExposures
;
354 scr
->info_text_gc
= XCreateGC(dpy
, scr
->w_win
, gcm
, &gcv
);
356 /* misc drawing GC */
357 gcv
.graphics_exposures
= False
;
358 gcm
= GCGraphicsExposures
;
359 scr
->draw_gc
= XCreateGC(dpy
, scr
->w_win
, gcm
, &gcv
);
365 createPixmaps(WScreen
*scr
)
373 pix
= wPixmapCreateFromXBMData(scr
, (char*)MENU_RADIO_INDICATOR_XBM_DATA
,
374 (char*)MENU_RADIO_INDICATOR_XBM_DATA
,
375 MENU_RADIO_INDICATOR_XBM_SIZE
,
376 MENU_RADIO_INDICATOR_XBM_SIZE
,
377 scr
->black_pixel
, scr
->white_pixel
);
380 scr
->menu_radio_indicator
= pix
;
383 pix
= wPixmapCreateFromXBMData(scr
, (char*)MENU_CHECK_INDICATOR_XBM_DATA
,
384 (char*)MENU_CHECK_INDICATOR_XBM_DATA
,
385 MENU_CHECK_INDICATOR_XBM_SIZE
,
386 MENU_CHECK_INDICATOR_XBM_SIZE
,
387 scr
->black_pixel
, scr
->white_pixel
);
390 scr
->menu_check_indicator
= pix
;
392 pix
= wPixmapCreateFromXBMData(scr
, (char*)MENU_MINI_INDICATOR_XBM_DATA
,
393 (char*)MENU_MINI_INDICATOR_XBM_DATA
,
394 MENU_MINI_INDICATOR_XBM_SIZE
,
395 MENU_MINI_INDICATOR_XBM_SIZE
,
396 scr
->black_pixel
, scr
->white_pixel
);
399 scr
->menu_mini_indicator
= pix
;
401 pix
= wPixmapCreateFromXBMData(scr
, (char*)MENU_HIDE_INDICATOR_XBM_DATA
,
402 (char*)MENU_HIDE_INDICATOR_XBM_DATA
,
403 MENU_HIDE_INDICATOR_XBM_SIZE
,
404 MENU_HIDE_INDICATOR_XBM_SIZE
,
405 scr
->black_pixel
, scr
->white_pixel
);
408 scr
->menu_hide_indicator
= pix
;
410 pix
= wPixmapCreateFromXBMData(scr
, (char*)MENU_SHADE_INDICATOR_XBM_DATA
,
411 (char*)MENU_SHADE_INDICATOR_XBM_DATA
,
412 MENU_SHADE_INDICATOR_XBM_SIZE
,
413 MENU_SHADE_INDICATOR_XBM_SIZE
,
414 scr
->black_pixel
, scr
->white_pixel
);
417 scr
->menu_shade_indicator
= pix
;
420 image
= wDefaultGetImage(scr
, "Logo", "WMPanel");
423 wwarning(_("could not load logo image for panels"));
425 if (!RConvertImageMask(scr
->rcontext
, image
, &p
, &m
, 128)) {
426 wwarning(_("error making logo image for panel:%s"), RMessageForError(RErrorCode
));
428 wmpix
= WMCreatePixmapFromXPixmaps(scr
->wmscreen
, p
, m
,
429 image
->width
, image
->height
,
431 WMSetApplicationIconImage(scr
->wmscreen
, wmpix
);
432 WMReleasePixmap(wmpix
);
434 RDestroyImage(image
);
437 if (!wPreferences
.flags
.nodock
|| !wPreferences
.flags
.noclip
) {
438 scr
->dock_dots
= make3Dots(scr
);
441 /* titlebar button pixmaps */
442 allocButtonPixmaps(scr
);
447 *----------------------------------------------------------------------
448 * createInternalWindows--
449 * Creates some windows used internally by the program. One to
450 * receive input focus when no other window can get it and another
451 * to display window geometry information during window resize/move.
457 * Windows are created and some colors are allocated for the
459 *----------------------------------------------------------------------
462 createInternalWindows(WScreen
*scr
)
465 XSetWindowAttributes attribs
;
467 /* window for displaying geometry information during resizes and moves */
468 vmask
= CWBorderPixel
|CWBackPixmap
|CWBackPixel
|CWCursor
|CWSaveUnder
|CWOverrideRedirect
;
469 attribs
.border_pixel
= 0;
470 attribs
.save_under
= True
;
471 attribs
.override_redirect
= True
;
472 attribs
.cursor
= wCursor
[WCUR_DEFAULT
];
473 attribs
.background_pixmap
= None
;
474 if (scr
->resizebar_texture
[0])
475 attribs
.background_pixel
= scr
->resizebar_texture
[0]->normal
.pixel
;
477 attribs
.background_pixel
= scr
->light_pixel
;
479 attribs
.colormap
= scr
->w_colormap
;
481 wGetGeometryWindowSize(scr
, &scr
->geometry_display_width
,
482 &scr
->geometry_display_height
);
483 scr
->geometry_display
=
484 XCreateWindow(dpy
, scr
->root_win
, 1, 1,
485 scr
->geometry_display_width
,
486 scr
->geometry_display_height
,
487 1, scr
->w_depth
, CopyFromParent
, scr
->w_visual
,
490 /* InputOnly window to get the focus when no other window can get it */
491 vmask
= CWEventMask
|CWOverrideRedirect
;
492 attribs
.event_mask
= KeyPressMask
|FocusChangeMask
;
493 attribs
.override_redirect
= True
;
494 scr
->no_focus_win
=XCreateWindow(dpy
,scr
->root_win
,-10, -10, 4, 4, 0, 0,
495 InputOnly
,CopyFromParent
, vmask
, &attribs
);
496 XSelectInput(dpy
, scr
->no_focus_win
, KeyPressMask
|KeyReleaseMask
);
497 XMapWindow(dpy
, scr
->no_focus_win
);
499 XSetInputFocus (dpy
, scr
->no_focus_win
, RevertToParent
, CurrentTime
);
501 /* shadow window for dock buttons */
502 vmask
= CWBorderPixel
|CWBackPixmap
|CWBackPixel
|CWCursor
|CWSaveUnder
|CWOverrideRedirect
;
503 attribs
.border_pixel
= 0;
504 attribs
.save_under
= True
;
505 attribs
.override_redirect
= True
;
506 attribs
.background_pixmap
= None
;
507 attribs
.background_pixel
= scr
->white_pixel
;
509 attribs
.colormap
= scr
->w_colormap
;
511 XCreateWindow(dpy
, scr
->root_win
, 0, 0, wPreferences
.icon_size
,
512 wPreferences
.icon_size
, 0, scr
->w_depth
, CopyFromParent
,
513 scr
->w_visual
, vmask
, &attribs
);
515 /* workspace name balloon for clip */
516 vmask
= CWBackPixel
|CWSaveUnder
|CWOverrideRedirect
|CWColormap
;
517 attribs
.save_under
= True
;
518 attribs
.override_redirect
= True
;
519 attribs
.colormap
= scr
->w_colormap
;
520 attribs
.background_pixel
= scr
->icon_back_texture
->normal
.pixel
;
522 XCreateWindow(dpy
, scr
->root_win
, 0, 0, 10, 10, 0, scr
->w_depth
,
523 CopyFromParent
, scr
->w_visual
, vmask
, &attribs
);
525 * If the window is clicked without having ButtonPress selected, the
526 * resulting event will have event.xbutton.window == root.
528 XSelectInput(dpy
, scr
->clip_balloon
, ButtonPressMask
);
533 *----------------------------------------------------------------------
535 * Initializes the window manager for the given screen and
536 * allocates a WScreen descriptor for it. Many resources are allocated
537 * for the screen and the root window is setup appropriately.
540 * The WScreen descriptor for the screen.
543 * Many resources are allocated and the IconSize property is
544 * set on the root window.
545 * The program can be aborted if some fatal error occurs.
547 * TODO: User specifiable visual.
548 *----------------------------------------------------------------------
551 wScreenInit(int screen_number
)
554 XIconSize icon_size
[1];
555 RContextAttributes rattr
;
556 extern int wVisualID
;
559 XErrorHandler oldHandler
;
561 scr
= wmalloc(sizeof(WScreen
));
562 memset(scr
, 0, sizeof(WScreen
));
564 /* initialize globals */
565 scr
->screen
= screen_number
;
566 scr
->root_win
= RootWindow(dpy
, screen_number
);
567 scr
->depth
= DefaultDepth(dpy
, screen_number
);
568 scr
->colormap
= DefaultColormap(dpy
, screen_number
);
570 scr
->scr_width
= WidthOfScreen(ScreenOfDisplay(dpy
, screen_number
));
571 scr
->scr_height
= HeightOfScreen(ScreenOfDisplay(dpy
, screen_number
));
573 scr
->usableArea
.x2
= scr
->scr_width
;
574 scr
->usableArea
.y2
= scr
->scr_height
;
575 scr
->totalUsableArea
.x2
= scr
->scr_width
;
576 scr
->totalUsableArea
.y2
= scr
->scr_height
;
578 CantManageScreen
= 0;
579 oldHandler
= XSetErrorHandler((XErrorHandler
)alreadyRunningError
);
581 event_mask
= EVENT_MASK
;
583 if (wPreferences
.disable_root_mouse
) {
584 event_mask
&= ~(ButtonPressMask
|ButtonReleaseMask
);
587 XSelectInput(dpy
, scr
->root_win
, event_mask
);
590 XSetErrorHandler(oldHandler
);
592 if (CantManageScreen
) {
597 XDefineCursor(dpy
, scr
->root_win
, wCursor
[WCUR_DEFAULT
]);
599 /* screen descriptor for raster graphic library */
600 rattr
.flags
= RC_RenderMode
| RC_ColorsPerChannel
;
601 rattr
.render_mode
= wPreferences
.no_dithering
?RM_MATCH
:RM_DITHER
;
602 rattr
.colors_per_channel
= wPreferences
.cmap_size
;
603 if (rattr
.colors_per_channel
<2)
604 rattr
.colors_per_channel
= 2;
607 rattr
.flags
|= RC_VisualID
;
608 rattr
.visualid
= wVisualID
;
610 scr
->rcontext
= RCreateContext(dpy
, screen_number
, &rattr
);
611 if (!scr
->rcontext
) {
612 wwarning(_("could not initialize graphics library context: %s"),
613 RMessageForError(RErrorCode
));
619 formats
= RSupportedFileFormats();
621 for (i
=0; formats
[i
]!=NULL
; i
++) {
622 if (strcmp(formats
[i
], "TIFF")==0) {
623 scr
->flags
.supports_tiff
= 1;
627 RFreeStringList(formats
);
631 scr
->w_win
= scr
->rcontext
->drawable
;
632 scr
->w_visual
= scr
->rcontext
->visual
;
633 scr
->w_depth
= scr
->rcontext
->depth
;
634 scr
->w_colormap
= scr
->rcontext
->cmap
;
636 scr
->black_pixel
= scr
->rcontext
->black
;
637 scr
->white_pixel
= scr
->rcontext
->white
;
639 /* create screen descriptor for WINGs */
640 scr
->wmscreen
= WMCreateScreenWithRContext(dpy
, screen_number
,
643 if (!scr
->wmscreen
) {
644 wfatal(_("could not do initialization of WINGs widget set"));
649 color
= WMGrayColor(scr
->wmscreen
);
650 scr
->light_pixel
= WMColorPixel(color
);
651 WMReleaseColor(color
);
653 color
= WMDarkGrayColor(scr
->wmscreen
);
654 scr
->dark_pixel
= WMColorPixel(color
);
655 WMReleaseColor(color
);
659 /* frame boder color */
660 wGetColor(scr
, FRAME_BORDER_COLOR
, &xcol
);
661 scr
->frame_border_pixel
= xcol
.pixel
;
664 /* create GCs with default values */
667 /* read defaults for this screen */
668 wReadDefaults(scr
, WDWindowMaker
->dictionary
);
670 createInternalWindows(scr
);
677 wGNOMEInitStuff(scr
);
680 /* create initial workspace */
683 /* create shared pixmaps */
686 /* set icon sizes we can accept from clients */
687 icon_size
[0].min_width
= 8;
688 icon_size
[0].min_height
= 8;
689 icon_size
[0].max_width
= wPreferences
.icon_size
-4;
690 icon_size
[0].max_height
= wPreferences
.icon_size
-4;
691 icon_size
[0].width_inc
= 1;
692 icon_size
[0].height_inc
= 1;
693 XSetIconSizes(dpy
, scr
->root_win
, icon_size
, 1);
695 /* setup WindowMaker protocols property in the root window*/
696 PropSetWMakerProtocols(scr
->root_win
);
699 /* initialize balloon text stuff */
700 wBalloonInitialize(scr
);
703 wScreenUpdateUsableArea(scr
);
706 /* kluge to load menu configurations at startup */
707 OpenRootMenu(scr
, -10000, -10000, False
);
708 wMenuUnmap(scr
->root_menu
);
716 wScreenUpdateUsableArea(WScreen
*scr
)
722 scr
->totalUsableArea
= scr
->usableArea
;
725 if (scr
->dock
&& (!scr
->dock
->lowered
726 || wPreferences
.no_window_over_dock
)) {
728 int offset
= wPreferences
.icon_size
+ DOCK_EXTRA_SPACE
;
730 if (scr
->dock
->on_right_side
) {
731 scr
->totalUsableArea
.x2
= WMIN(scr
->totalUsableArea
.x2
,
732 scr
->scr_width
- offset
);
734 scr
->totalUsableArea
.x1
= WMAX(scr
->totalUsableArea
.x1
, offset
);
738 if (wPreferences
.no_window_over_icons
) {
739 if (wPreferences
.icon_yard
& IY_VERT
) {
741 if (!(wPreferences
.icon_yard
& IY_RIGHT
)) {
742 scr
->totalUsableArea
.x1
+= wPreferences
.icon_size
;
744 scr
->totalUsableArea
.x2
-= wPreferences
.icon_size
;
748 if (wPreferences
.icon_yard
& IY_TOP
) {
749 scr
->totalUsableArea
.y1
+= wPreferences
.icon_size
;
751 scr
->totalUsableArea
.y2
-= wPreferences
.icon_size
;
760 if (wKWMGetUsableArea(scr
, &area
)) {
761 scr
->totalUsableArea
.x1
= WMAX(scr
->totalUsableArea
.x1
, area
.x1
);
762 scr
->totalUsableArea
.y1
= WMAX(scr
->totalUsableArea
.y1
, area
.y1
);
763 scr
->totalUsableArea
.x2
= WMIN(scr
->totalUsableArea
.x2
, area
.x2
);
764 scr
->totalUsableArea
.y2
= WMIN(scr
->totalUsableArea
.y2
, area
.y2
);
770 area
= scr
->reservedAreas
;
777 w
= area
->area
.x2
- area
->area
.x1
;
778 h
= area
->area
.y2
- area
->area
.y1
;
781 bh
= scr
->scr_height
- area
->area
.y2
;
783 rw
= scr
->scr_width
- area
->area
.x2
;
785 if (WMIN(th
, bh
) < WMIN(lw
, rw
)) {
789 if (scr
->totalUsableArea
.y1
< area
->area
.y2
)
790 scr
->totalUsableArea
.y1
= area
->area
.y2
;
793 if (scr
->totalUsableArea
.y2
> area
->area
.y1
)
794 scr
->totalUsableArea
.y2
= area
->area
.y1
;
800 if (scr
->totalUsableArea
.x1
< area
->area
.x2
)
801 scr
->totalUsableArea
.x1
= area
->area
.x2
;
804 if (scr
->totalUsableArea
.x2
> area
->area
.x1
)
805 scr
->totalUsableArea
.x2
= area
->area
.x1
;
811 #endif /* GNOME_STUFF */
813 if (scr
->totalUsableArea
.x2
- scr
->totalUsableArea
.x1
< scr
->scr_width
/2) {
814 scr
->totalUsableArea
.x2
= scr
->usableArea
.x2
;
815 scr
->totalUsableArea
.x1
= scr
->usableArea
.x1
;
817 if (scr
->totalUsableArea
.y2
- scr
->totalUsableArea
.y1
< scr
->scr_height
/2) {
818 scr
->totalUsableArea
.y2
= scr
->usableArea
.y2
;
819 scr
->totalUsableArea
.y1
= scr
->usableArea
.y1
;
826 for (i
= 0; i
< scr
->workspace_count
; i
++) {
827 wKWMSetUsableAreaHint(scr
, i
);
835 wScreenRestoreState(WScreen
*scr
)
842 if (wScreenCount
== 1)
843 path
= wdefaultspathfordomain("WMState");
846 sprintf(buf
, "WMState.%i", scr
->screen
);
847 path
= wdefaultspathfordomain(buf
);
849 scr
->session_state
= PLGetProplistWithPath(path
);
851 if (!scr
->session_state
&& wScreenCount
>1) {
853 sprintf(buf
, "WMState.%i", scr
->screen
);
854 path
= wdefaultspathfordomain(buf
);
855 scr
->session_state
= PLGetProplistWithPath(path
);
859 if (!wPreferences
.flags
.noclip
) {
860 state
= PLGetDictionaryEntry(scr
->session_state
, dClip
);
861 scr
->clip_icon
= wClipRestoreState(scr
, state
);
864 wWorkspaceRestoreState(scr
);
866 if (!wPreferences
.flags
.nodock
) {
867 state
= PLGetDictionaryEntry(scr
->session_state
, dDock
);
868 scr
->dock
= wDockRestoreState(scr
, state
, WM_DOCK
);
871 wScreenUpdateUsableArea(scr
);
876 wScreenSaveState(WScreen
*scr
)
878 WWorkspaceState wstate
;
881 proplist_t path
, old_state
, foo
;
888 * Save current workspace, so can go back to it upon restart.
890 wstate
.workspace
= scr
->current_workspace
;
892 data
[0] = wstate
.flags
;
893 data
[1] = wstate
.workspace
;
895 XChangeProperty(dpy
, scr
->root_win
, _XA_WINDOWMAKER_STATE
,
896 _XA_WINDOWMAKER_STATE
, 32, PropModeReplace
,
897 (unsigned char *) data
, 2);
899 /* save state of windows */
900 wwin
= scr
->focused_window
;
902 wWindowSaveState(wwin
);
907 if (wPreferences
.flags
.noupdates
)
911 old_state
= scr
->session_state
;
912 scr
->session_state
= PLMakeDictionaryFromEntries(NULL
, NULL
, NULL
);
914 PLSetStringCmpHook(NULL
);
916 /* save dock state to file */
917 if (!wPreferences
.flags
.nodock
) {
920 if ((foo
= PLGetDictionaryEntry(old_state
, dDock
))!=NULL
) {
921 PLInsertDictionaryEntry(scr
->session_state
, dDock
, foo
);
924 if (!wPreferences
.flags
.noclip
) {
927 if ((foo
= PLGetDictionaryEntry(old_state
, dClip
))!=NULL
) {
928 PLInsertDictionaryEntry(scr
->session_state
, dClip
, foo
);
932 wWorkspaceSaveState(scr
, old_state
);
934 if (wPreferences
.save_session_on_exit
) {
935 wSessionSaveState(scr
);
937 if ((foo
= PLGetDictionaryEntry(old_state
, dApplications
))!=NULL
) {
938 PLInsertDictionaryEntry(scr
->session_state
, dApplications
, foo
);
940 if ((foo
= PLGetDictionaryEntry(old_state
, dWorkspace
))!=NULL
) {
941 PLInsertDictionaryEntry(scr
->session_state
, dWorkspace
, foo
);
946 PLSetStringCmpHook(StringCompareHook
);
950 if (wScreenCount
== 1)
951 str
= wdefaultspathfordomain("WMState");
954 sprintf(buf
, "WMState.%i", scr
->screen
);
955 str
= wdefaultspathfordomain(buf
);
957 path
= PLMakeString(str
);
959 PLSetFilename(scr
->session_state
, path
);
960 if (!PLSave(scr
->session_state
, YES
)) {
961 wwarning(_("could not save session state in %s"), PLGetString(path
));
964 PLRelease(old_state
);
970 wScreenBringInside(WScreen
*scr
, int *x
, int *y
, int width
, int height
)
986 *x
= -tol_w
, moved
= 1;
987 else if (*x
>= scr
->scr_width
- 10)
988 *x
= scr
->scr_width
- tol_w
- 1, moved
= 1;
990 if (*y
< -height
+ 10)
991 *y
= -tol_h
, moved
= 1;
992 else if (*y
>= scr
->scr_height
- 10)
993 *y
= scr
->scr_height
- tol_h
- 1, moved
= 1;