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>
31 #include <X11/Xatom.h>
33 #include <X11/extensions/shape.h>
38 #include "WindowMaker.h"
39 #include "def_pixmaps.h"
46 #include "properties.h"
48 #include "resources.h"
49 #include "workspace.h"
59 # include "openlook.h"
68 #define EVENT_MASK (LeaveWindowMask|EnterWindowMask|PropertyChangeMask\
69 |SubstructureNotifyMask|PointerMotionMask \
70 |SubstructureRedirectMask|KeyPressMask|KeyReleaseMask)
72 #define EVENT_MASK (LeaveWindowMask|EnterWindowMask|PropertyChangeMask\
73 |SubstructureNotifyMask|PointerMotionMask \
74 |SubstructureRedirectMask|ButtonPressMask|ButtonReleaseMask\
75 |KeyPressMask|KeyReleaseMask)
78 /**** Global variables ****/
80 extern Cursor wCursor
[WCUR_LAST
];
81 extern WPreferences wPreferences
;
82 extern Atom _XA_WINDOWMAKER_STATE
;
83 extern Atom _XA_WINDOWMAKER_NOTICEBOARD
;
86 extern int wScreenCount
;
88 extern WDDomain
*WDWindowMaker
;
93 #define STIPPLE_WIDTH 2
94 #define STIPPLE_HEIGHT 2
95 static char STIPPLE_DATA
[] = {0x02, 0x01};
97 static int CantManageScreen
= 0;
99 static proplist_t dApplications
= NULL
;
100 static proplist_t dWorkspace
;
101 static proplist_t dDock
;
102 static proplist_t dClip
;
108 if (dApplications
!=NULL
)
111 dApplications
= PLMakeString("Applications");
112 dWorkspace
= PLMakeString("Workspace");
113 dDock
= PLMakeString("Dock");
114 dClip
= PLMakeString("Clip");
119 *----------------------------------------------------------------------
120 * alreadyRunningError--
121 * X error handler used to catch errors when trying to do
122 * XSelectInput() on the root window. These errors probably mean that
123 * there already is some other window manager running.
126 * Nothing, unless something really evil happens...
129 * CantManageScreen is set to 1;
130 *----------------------------------------------------------------------
133 alreadyRunningError(Display
*dpy
, XErrorEvent
*error
)
135 CantManageScreen
= 1;
141 *----------------------------------------------------------------------
142 * allocButtonPixmaps--
143 * Allocate pixmaps used on window operation buttons (those in the
144 * titlebar). The pixmaps are linked to the program. If XPM is supported
145 * XPM pixmaps are used otherwise, equivalent bitmaps are used.
151 * Allocates shared pixmaps for the screen. These pixmaps should
152 * not be freed by anybody.
153 *----------------------------------------------------------------------
156 allocButtonPixmaps(WScreen
*scr
)
160 /* create predefined pixmaps */
161 pix
= wPixmapCreateFromXPMData(scr
, PRED_CLOSE_XPM
);
164 scr
->b_pixmaps
[WBUT_CLOSE
] = pix
;
166 pix
= wPixmapCreateFromXPMData(scr
, PRED_BROKEN_CLOSE_XPM
);
169 scr
->b_pixmaps
[WBUT_BROKENCLOSE
] = pix
;
171 pix
= wPixmapCreateFromXPMData(scr
, PRED_ICONIFY_XPM
);
174 scr
->b_pixmaps
[WBUT_ICONIFY
] = pix
;
176 pix
= wPixmapCreateFromXPMData(scr
, PRED_KILL_XPM
);
179 scr
->b_pixmaps
[WBUT_KILL
] = pix
;
185 draw_dot(WScreen
*scr
, Drawable d
, int x
, int y
, GC gc
)
187 XSetForeground(dpy
, gc
, scr
->black_pixel
);
188 XDrawLine(dpy
, d
, gc
, x
, y
, x
+1, y
);
189 XDrawPoint(dpy
, d
, gc
, x
, y
+1);
190 XSetForeground(dpy
, gc
, scr
->white_pixel
);
191 XDrawLine(dpy
, d
, gc
, x
+2, y
, x
+2, y
+1);
192 XDrawPoint(dpy
, d
, gc
, x
+1, y
+1);
197 make3Dots(WScreen
*scr
)
205 pix
= XCreatePixmap(dpy
, scr
->w_win
, wPreferences
.icon_size
,
206 wPreferences
.icon_size
, scr
->w_depth
);
207 XSetForeground(dpy
, gc
, scr
->black_pixel
);
208 XFillRectangle(dpy
, pix
, gc
, 0, 0, wPreferences
.icon_size
,
209 wPreferences
.icon_size
);
210 XSetForeground(dpy
, gc
, scr
->white_pixel
);
211 draw_dot(scr
, pix
, 4, wPreferences
.icon_size
-6, gc
);
212 draw_dot(scr
, pix
, 9, wPreferences
.icon_size
-6, gc
);
213 draw_dot(scr
, pix
, 14, wPreferences
.icon_size
-6, gc
);
215 mask
= XCreatePixmap(dpy
, scr
->w_win
, wPreferences
.icon_size
,
216 wPreferences
.icon_size
, 1);
218 gcv
.graphics_exposures
= False
;
219 gc2
= XCreateGC(dpy
, mask
, GCForeground
|GCGraphicsExposures
, &gcv
);
220 XFillRectangle(dpy
, mask
, gc2
, 0, 0, wPreferences
.icon_size
,
221 wPreferences
.icon_size
);
222 XSetForeground(dpy
, gc2
, 1);
223 XFillRectangle(dpy
, mask
, gc2
, 4, wPreferences
.icon_size
-6, 3, 2);
224 XFillRectangle(dpy
, mask
, gc2
, 9, wPreferences
.icon_size
-6, 3, 2);
225 XFillRectangle(dpy
, mask
, gc2
, 14, wPreferences
.icon_size
-6, 3, 2);
229 wpix
= wPixmapCreate(scr
, pix
, mask
);
237 allocGCs(WScreen
*scr
)
241 unsigned long mtextcolor
;
244 scr
->stipple_bitmap
=
245 XCreateBitmapFromData(dpy
, scr
->w_win
, STIPPLE_DATA
, STIPPLE_WIDTH
,
248 gcv
.stipple
= scr
->stipple_bitmap
;
249 gcv
.foreground
= scr
->white_pixel
;
250 gcv
.fill_style
= FillStippled
;
251 gcv
.graphics_exposures
= False
;
252 gcm
= GCForeground
|GCStipple
|GCFillStyle
|GCGraphicsExposures
;
253 scr
->stipple_gc
= XCreateGC(dpy
, scr
->w_win
, gcm
, &gcv
);
256 /* selected icon border GCs */
257 gcv
.function
= GXcopy
;
258 gcv
.foreground
= scr
->white_pixel
;
259 gcv
.background
= scr
->black_pixel
;
261 gcv
.line_style
= LineDoubleDash
;
262 gcv
.fill_style
= FillSolid
;
265 gcv
.graphics_exposures
= False
;
267 gcm
= GCFunction
| GCGraphicsExposures
;
268 gcm
|= GCForeground
| GCBackground
;
269 gcm
|= GCLineWidth
| GCLineStyle
;
271 gcm
|= GCDashOffset
| GCDashList
;
273 scr
->icon_select_gc
= XCreateGC(dpy
, scr
->w_win
, gcm
, &gcv
);
275 gcm
= GCForeground
|GCGraphicsExposures
;
277 scr
->menu_title_pixel
[0] = scr
->white_pixel
;
278 gcv
.foreground
= scr
->white_pixel
;
279 gcv
.graphics_exposures
= False
;
280 scr
->menu_title_gc
= XCreateGC(dpy
, scr
->w_win
, gcm
, &gcv
);
282 scr
->mtext_pixel
= scr
->black_pixel
;
283 mtextcolor
= gcv
.foreground
= scr
->black_pixel
;
284 scr
->menu_entry_gc
= XCreateGC(dpy
, scr
->w_win
, gcm
, &gcv
);
286 /* selected menu entry GC */
287 gcm
= GCForeground
|GCBackground
|GCGraphicsExposures
;
288 gcv
.foreground
= scr
->white_pixel
;
289 gcv
.background
= scr
->white_pixel
;
290 gcv
.graphics_exposures
= False
;
291 scr
->select_menu_gc
= XCreateGC(dpy
, scr
->w_win
, gcm
, &gcv
);
293 /* disabled menu entry GC */
294 scr
->dtext_pixel
= scr
->black_pixel
;
295 gcm
= GCForeground
|GCBackground
|GCStipple
|GCGraphicsExposures
;
296 gcv
.stipple
= scr
->stipple_bitmap
;
297 gcv
.graphics_exposures
= False
;
298 scr
->disabled_menu_entry_gc
= XCreateGC(dpy
, scr
->w_win
, gcm
, &gcv
);
301 wGetColor(scr
, DEF_FRAME_COLOR
, &color
);
302 gcv
.function
= GXxor
;
303 /* this will raise the probability of the XORed color being different
304 * of the original color in PseudoColor when not all color cells are
306 if (DefaultVisual(dpy
, scr
->screen
)->class==PseudoColor
)
307 gcv
.plane_mask
= (1<<(scr
->depth
-1))|1;
309 gcv
.plane_mask
= AllPlanes
;
310 gcv
.foreground
= color
.pixel
;
311 if (gcv
.foreground
== 0)
313 gcv
.line_width
= DEF_FRAME_THICKNESS
;
314 gcv
.subwindow_mode
= IncludeInferiors
;
315 gcv
.graphics_exposures
= False
;
316 scr
->frame_gc
= XCreateGC(dpy
, scr
->root_win
, GCForeground
|GCGraphicsExposures
317 |GCFunction
|GCSubwindowMode
|GCLineWidth
321 gcv
.foreground
= color
.pixel
;
323 if (gcv
.foreground
== 0)
324 /* XOR:ing with a zero is not going to be of much use, so
325 in that case, we somewhat arbitrarily xor with 17 instead. */
328 gcv
.function
= GXxor
;
329 gcv
.subwindow_mode
= IncludeInferiors
;
331 gcv
.cap_style
= CapRound
;
332 gcv
.graphics_exposures
= False
;
333 gcm
= GCForeground
|GCFunction
|GCSubwindowMode
|GCLineWidth
|GCCapStyle
334 |GCGraphicsExposures
;
335 scr
->line_gc
= XCreateGC(dpy
, scr
->root_win
, gcm
, &gcv
);
337 scr
->line_pixel
= gcv
.foreground
;
340 gcv
.foreground
= scr
->white_pixel
;
341 gcv
.background
= scr
->black_pixel
;
342 gcv
.graphics_exposures
= False
;
343 scr
->copy_gc
= XCreateGC(dpy
, scr
->w_win
, GCForeground
|GCBackground
344 |GCGraphicsExposures
, &gcv
);
346 /* window title text GC */
347 gcv
.graphics_exposures
= False
;
348 scr
->window_title_gc
= XCreateGC(dpy
, scr
->w_win
,GCGraphicsExposures
,&gcv
);
351 scr
->icon_title_gc
= XCreateGC(dpy
, scr
->w_win
, GCGraphicsExposures
, &gcv
);
354 scr
->clip_title_gc
= XCreateGC(dpy
, scr
->w_win
, GCGraphicsExposures
, &gcv
);
356 /* move/size display GC */
357 gcv
.graphics_exposures
= False
;
358 gcm
= GCGraphicsExposures
;
359 scr
->info_text_gc
= XCreateGC(dpy
, scr
->w_win
, gcm
, &gcv
);
361 /* misc drawing GC */
362 gcv
.graphics_exposures
= False
;
363 gcm
= GCGraphicsExposures
;
364 scr
->draw_gc
= XCreateGC(dpy
, scr
->w_win
, gcm
, &gcv
);
370 createPixmaps(WScreen
*scr
)
378 pix
= wPixmapCreateFromXBMData(scr
, (char*)MENU_RADIO_INDICATOR_XBM_DATA
,
379 (char*)MENU_RADIO_INDICATOR_XBM_DATA
,
380 MENU_RADIO_INDICATOR_XBM_SIZE
,
381 MENU_RADIO_INDICATOR_XBM_SIZE
,
382 scr
->black_pixel
, scr
->white_pixel
);
385 scr
->menu_radio_indicator
= pix
;
388 pix
= wPixmapCreateFromXBMData(scr
, (char*)MENU_CHECK_INDICATOR_XBM_DATA
,
389 (char*)MENU_CHECK_INDICATOR_XBM_DATA
,
390 MENU_CHECK_INDICATOR_XBM_SIZE
,
391 MENU_CHECK_INDICATOR_XBM_SIZE
,
392 scr
->black_pixel
, scr
->white_pixel
);
395 scr
->menu_check_indicator
= pix
;
397 pix
= wPixmapCreateFromXBMData(scr
, (char*)MENU_MINI_INDICATOR_XBM_DATA
,
398 (char*)MENU_MINI_INDICATOR_XBM_DATA
,
399 MENU_MINI_INDICATOR_XBM_SIZE
,
400 MENU_MINI_INDICATOR_XBM_SIZE
,
401 scr
->black_pixel
, scr
->white_pixel
);
404 scr
->menu_mini_indicator
= pix
;
406 pix
= wPixmapCreateFromXBMData(scr
, (char*)MENU_HIDE_INDICATOR_XBM_DATA
,
407 (char*)MENU_HIDE_INDICATOR_XBM_DATA
,
408 MENU_HIDE_INDICATOR_XBM_SIZE
,
409 MENU_HIDE_INDICATOR_XBM_SIZE
,
410 scr
->black_pixel
, scr
->white_pixel
);
413 scr
->menu_hide_indicator
= pix
;
415 pix
= wPixmapCreateFromXBMData(scr
, (char*)MENU_SHADE_INDICATOR_XBM_DATA
,
416 (char*)MENU_SHADE_INDICATOR_XBM_DATA
,
417 MENU_SHADE_INDICATOR_XBM_SIZE
,
418 MENU_SHADE_INDICATOR_XBM_SIZE
,
419 scr
->black_pixel
, scr
->white_pixel
);
422 scr
->menu_shade_indicator
= pix
;
425 image
= wDefaultGetImage(scr
, "Logo", "WMPanel");
428 wwarning(_("could not load logo image for panels"));
430 if (!RConvertImageMask(scr
->rcontext
, image
, &p
, &m
, 128)) {
431 wwarning(_("error making logo image for panel:%s"), RMessageForError(RErrorCode
));
433 wmpix
= WMCreatePixmapFromXPixmaps(scr
->wmscreen
, p
, m
,
434 image
->width
, image
->height
,
436 WMSetApplicationIconImage(scr
->wmscreen
, wmpix
);
437 WMReleasePixmap(wmpix
);
439 RDestroyImage(image
);
442 if (!wPreferences
.flags
.nodock
|| !wPreferences
.flags
.noclip
) {
443 scr
->dock_dots
= make3Dots(scr
);
446 /* titlebar button pixmaps */
447 allocButtonPixmaps(scr
);
452 *----------------------------------------------------------------------
453 * createInternalWindows--
454 * Creates some windows used internally by the program. One to
455 * receive input focus when no other window can get it and another
456 * to display window geometry information during window resize/move.
462 * Windows are created and some colors are allocated for the
464 *----------------------------------------------------------------------
467 createInternalWindows(WScreen
*scr
)
470 XSetWindowAttributes attribs
;
472 /* window for displaying geometry information during resizes and moves */
473 vmask
= CWBorderPixel
|CWBackPixmap
|CWBackPixel
|CWCursor
|CWSaveUnder
|CWOverrideRedirect
;
474 attribs
.border_pixel
= 0;
475 attribs
.save_under
= True
;
476 attribs
.override_redirect
= True
;
477 attribs
.cursor
= wCursor
[WCUR_DEFAULT
];
478 attribs
.background_pixmap
= None
;
479 if (scr
->resizebar_texture
[0])
480 attribs
.background_pixel
= scr
->resizebar_texture
[0]->normal
.pixel
;
482 attribs
.background_pixel
= scr
->light_pixel
;
484 attribs
.colormap
= scr
->w_colormap
;
486 wGetGeometryWindowSize(scr
, &scr
->geometry_display_width
,
487 &scr
->geometry_display_height
);
488 scr
->geometry_display
=
489 XCreateWindow(dpy
, scr
->root_win
, 1, 1,
490 scr
->geometry_display_width
,
491 scr
->geometry_display_height
,
492 1, scr
->w_depth
, CopyFromParent
, scr
->w_visual
,
495 /* InputOnly window to get the focus when no other window can get it */
496 vmask
= CWEventMask
|CWOverrideRedirect
;
497 attribs
.event_mask
= KeyPressMask
|FocusChangeMask
;
498 attribs
.override_redirect
= True
;
499 scr
->no_focus_win
=XCreateWindow(dpy
,scr
->root_win
,-10, -10, 4, 4, 0, 0,
500 InputOnly
,CopyFromParent
, vmask
, &attribs
);
501 XSelectInput(dpy
, scr
->no_focus_win
, KeyPressMask
|KeyReleaseMask
);
502 XMapWindow(dpy
, scr
->no_focus_win
);
504 XSetInputFocus (dpy
, scr
->no_focus_win
, RevertToParent
, CurrentTime
);
506 /* shadow window for dock buttons */
507 vmask
= CWBorderPixel
|CWBackPixmap
|CWBackPixel
|CWCursor
|CWSaveUnder
|CWOverrideRedirect
;
508 attribs
.border_pixel
= 0;
509 attribs
.save_under
= True
;
510 attribs
.override_redirect
= True
;
511 attribs
.background_pixmap
= None
;
512 attribs
.background_pixel
= scr
->white_pixel
;
514 attribs
.colormap
= scr
->w_colormap
;
516 XCreateWindow(dpy
, scr
->root_win
, 0, 0, wPreferences
.icon_size
,
517 wPreferences
.icon_size
, 0, scr
->w_depth
, CopyFromParent
,
518 scr
->w_visual
, vmask
, &attribs
);
520 /* workspace name balloon for clip */
521 vmask
= CWBackPixel
|CWSaveUnder
|CWOverrideRedirect
|CWColormap
523 attribs
.save_under
= True
;
524 attribs
.override_redirect
= True
;
525 attribs
.colormap
= scr
->w_colormap
;
526 attribs
.background_pixel
= scr
->icon_back_texture
->normal
.pixel
;
527 attribs
.border_pixel
= 0; /* do not care */
529 XCreateWindow(dpy
, scr
->root_win
, 0, 0, 10, 10, 0, scr
->w_depth
,
530 CopyFromParent
, scr
->w_visual
, vmask
, &attribs
);
532 /* for our window manager info notice board */
534 XCreateWindow(dpy
, scr
->root_win
, 0, 0, 10, 10, 0, CopyFromParent
,
535 CopyFromParent
, CopyFromParent
, 0, NULL
);
538 * If the window is clicked without having ButtonPress selected, the
539 * resulting event will have event.xbutton.window == root.
541 XSelectInput(dpy
, scr
->clip_balloon
, ButtonPressMask
);
547 aquireManagerSelection(WScreen
*scr
)
553 sprintf(buffer
, "WM_S%i", scr
->screen
);
554 scr
->managerAtom
= XInternAtom(dpy
, buffer
, False
);
556 /* for race-conditions... */
559 /* if there is another manager running, don't try to replace it
560 * (for now, at least) */
561 if (XGetSelectionOwner(dpy
, scr
->managerAtom
) != None
) {
566 /* become the manager for this screen */
568 scr
->managerWindow
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 1, 1,
571 XSelectInput(dpy
, scr
->managerWindow
, PropertyChangeMask
);
572 /* get a timestamp */
573 XChangeProperty(dpy
, scr
->managerWindow
, scr
->managerAtom
,
574 XA_INTEGER
, 32, PropModeAppend
, NULL
, 0);
576 XWindowEvent(dpy
, scr
->managerWindow
, &ev
);
577 if (ev
.type
== PropertyNotify
) {
578 timestamp
= ev
.xproperty
.time
;
582 XSelectInput(dpy
, scr
->managerWindow
, NoEvents
);
583 XDeleteProperty(dpy
, scr
->managerWindow
, scr
->managerAtom
);
585 XSetSelectionOwner(dpy
, scr
->managerAtom
, scr
->managerWindow
, CurrentTime
);
589 /* announce our arrival */
591 ev
.xclient
.type
= ClientMessage
;
592 ev
.xclient
.message_type
= XInternAtom(dpy
, "MANAGER", False
);
593 ev
.xclient
.destination
= scr
->root_win
;
594 ev
.xclient
.format
= 32;
595 ev
.xclient
.data
.l
[0] = timestamp
;
596 ev
.xclient
.data
.l
[1] = scr
->managerAtom
;
597 ev
.xclient
.data
.l
[2] = scr
->managerWindow
;
598 ev
.xclient
.data
.l
[3] = 0;
599 ev
.xclient
.data
.l
[4] = 0;
601 XSendEvent(dpy
, scr
->root_win
, False
, StructureNotify
, &ev
);
609 *----------------------------------------------------------------------
611 * Initializes the window manager for the given screen and
612 * allocates a WScreen descriptor for it. Many resources are allocated
613 * for the screen and the root window is setup appropriately.
616 * The WScreen descriptor for the screen.
619 * Many resources are allocated and the IconSize property is
620 * set on the root window.
621 * The program can be aborted if some fatal error occurs.
623 * TODO: User specifiable visual.
624 *----------------------------------------------------------------------
627 wScreenInit(int screen_number
)
630 XIconSize icon_size
[1];
631 RContextAttributes rattr
;
632 extern int wVisualID
;
635 XErrorHandler oldHandler
;
637 scr
= wmalloc(sizeof(WScreen
));
638 memset(scr
, 0, sizeof(WScreen
));
640 /* initialize globals */
641 scr
->screen
= screen_number
;
642 scr
->root_win
= RootWindow(dpy
, screen_number
);
643 scr
->depth
= DefaultDepth(dpy
, screen_number
);
644 scr
->colormap
= DefaultColormap(dpy
, screen_number
);
646 scr
->scr_width
= WidthOfScreen(ScreenOfDisplay(dpy
, screen_number
));
647 scr
->scr_height
= HeightOfScreen(ScreenOfDisplay(dpy
, screen_number
));
649 scr
->usableArea
.x2
= scr
->scr_width
;
650 scr
->usableArea
.y2
= scr
->scr_height
;
651 scr
->totalUsableArea
.x2
= scr
->scr_width
;
652 scr
->totalUsableArea
.y2
= scr
->scr_height
;
655 if (!aquireManagerSelection(scr
)) {
661 CantManageScreen
= 0;
662 oldHandler
= XSetErrorHandler((XErrorHandler
)alreadyRunningError
);
664 event_mask
= EVENT_MASK
;
666 if (wPreferences
.disable_root_mouse
) {
667 event_mask
&= ~(ButtonPressMask
|ButtonReleaseMask
);
670 XSelectInput(dpy
, scr
->root_win
, event_mask
);
673 XSetErrorHandler(oldHandler
);
675 if (CantManageScreen
) {
680 XDefineCursor(dpy
, scr
->root_win
, wCursor
[WCUR_DEFAULT
]);
682 /* screen descriptor for raster graphic library */
683 rattr
.flags
= RC_RenderMode
| RC_ColorsPerChannel
;
684 rattr
.render_mode
= wPreferences
.no_dithering
?RM_MATCH
:RM_DITHER
;
685 rattr
.colors_per_channel
= wPreferences
.cmap_size
;
686 if (rattr
.colors_per_channel
<2)
687 rattr
.colors_per_channel
= 2;
690 rattr
.flags
|= RC_VisualID
;
691 rattr
.visualid
= wVisualID
;
693 scr
->rcontext
= RCreateContext(dpy
, screen_number
, &rattr
);
694 if (!scr
->rcontext
) {
695 wwarning(_("could not initialize graphics library context: %s"),
696 RMessageForError(RErrorCode
));
702 formats
= RSupportedFileFormats();
704 for (i
=0; formats
[i
]!=NULL
; i
++) {
705 if (strcmp(formats
[i
], "TIFF")==0) {
706 scr
->flags
.supports_tiff
= 1;
710 RFreeStringList(formats
);
714 scr
->w_win
= scr
->rcontext
->drawable
;
715 scr
->w_visual
= scr
->rcontext
->visual
;
716 scr
->w_depth
= scr
->rcontext
->depth
;
717 scr
->w_colormap
= scr
->rcontext
->cmap
;
719 scr
->black_pixel
= scr
->rcontext
->black
;
720 scr
->white_pixel
= scr
->rcontext
->white
;
722 /* create screen descriptor for WINGs */
723 scr
->wmscreen
= WMCreateScreenWithRContext(dpy
, screen_number
,
726 if (!scr
->wmscreen
) {
727 wfatal(_("could not do initialization of WINGs widget set"));
732 color
= WMGrayColor(scr
->wmscreen
);
733 scr
->light_pixel
= WMColorPixel(color
);
734 WMReleaseColor(color
);
736 color
= WMDarkGrayColor(scr
->wmscreen
);
737 scr
->dark_pixel
= WMColorPixel(color
);
738 WMReleaseColor(color
);
742 /* frame boder color */
743 wGetColor(scr
, FRAME_BORDER_COLOR
, &xcol
);
744 scr
->frame_border_pixel
= xcol
.pixel
;
747 /* create GCs with default values */
750 /* read defaults for this screen */
751 wReadDefaults(scr
, WDWindowMaker
->dictionary
);
753 createInternalWindows(scr
);
760 wGNOMEInitStuff(scr
);
767 /* create initial workspace */
770 /* create shared pixmaps */
773 /* set icon sizes we can accept from clients */
774 icon_size
[0].min_width
= 8;
775 icon_size
[0].min_height
= 8;
776 icon_size
[0].max_width
= wPreferences
.icon_size
-4;
777 icon_size
[0].max_height
= wPreferences
.icon_size
-4;
778 icon_size
[0].width_inc
= 1;
779 icon_size
[0].height_inc
= 1;
780 XSetIconSizes(dpy
, scr
->root_win
, icon_size
, 1);
782 /* setup WindowMaker protocols property in the root window*/
783 PropSetWMakerProtocols(scr
->root_win
);
785 /* setup our noticeboard */
786 XChangeProperty(dpy
, scr
->info_window
, _XA_WINDOWMAKER_NOTICEBOARD
,
787 XA_WINDOW
, 32, PropModeReplace
,
788 (unsigned char*)&scr
->info_window
, 1);
789 XChangeProperty(dpy
, scr
->root_win
, _XA_WINDOWMAKER_NOTICEBOARD
,
790 XA_WINDOW
, 32, PropModeReplace
,
791 (unsigned char*)&scr
->info_window
, 1);
795 /* initialize balloon text stuff */
796 wBalloonInitialize(scr
);
799 wScreenUpdateUsableArea(scr
);
802 /* kluge to load menu configurations at startup */
803 OpenRootMenu(scr
, -10000, -10000, False
);
804 wMenuUnmap(scr
->root_menu
);
812 wScreenUpdateUsableArea(WScreen
*scr
)
818 scr
->totalUsableArea
= scr
->usableArea
;
821 if (scr
->dock
&& (!scr
->dock
->lowered
822 || wPreferences
.no_window_over_dock
)) {
824 int offset
= wPreferences
.icon_size
+ DOCK_EXTRA_SPACE
;
826 if (scr
->dock
->on_right_side
) {
827 scr
->totalUsableArea
.x2
= WMIN(scr
->totalUsableArea
.x2
,
828 scr
->scr_width
- offset
);
830 scr
->totalUsableArea
.x1
= WMAX(scr
->totalUsableArea
.x1
, offset
);
834 if (wPreferences
.no_window_over_icons
) {
835 if (wPreferences
.icon_yard
& IY_VERT
) {
837 if (!(wPreferences
.icon_yard
& IY_RIGHT
)) {
838 scr
->totalUsableArea
.x1
+= wPreferences
.icon_size
;
840 scr
->totalUsableArea
.x2
-= wPreferences
.icon_size
;
844 if (wPreferences
.icon_yard
& IY_TOP
) {
845 scr
->totalUsableArea
.y1
+= wPreferences
.icon_size
;
847 scr
->totalUsableArea
.y2
-= wPreferences
.icon_size
;
856 if (wKWMGetUsableArea(scr
, &area
)) {
857 scr
->totalUsableArea
.x1
= WMAX(scr
->totalUsableArea
.x1
, area
.x1
);
858 scr
->totalUsableArea
.y1
= WMAX(scr
->totalUsableArea
.y1
, area
.y1
);
859 scr
->totalUsableArea
.x2
= WMIN(scr
->totalUsableArea
.x2
, area
.x2
);
860 scr
->totalUsableArea
.y2
= WMIN(scr
->totalUsableArea
.y2
, area
.y2
);
866 area
= scr
->reservedAreas
;
873 w
= area
->area
.x2
- area
->area
.x1
;
874 h
= area
->area
.y2
- area
->area
.y1
;
877 bh
= scr
->scr_height
- area
->area
.y2
;
879 rw
= scr
->scr_width
- area
->area
.x2
;
881 if (WMIN(th
, bh
) < WMIN(lw
, rw
)) {
885 if (scr
->totalUsableArea
.y1
< area
->area
.y2
)
886 scr
->totalUsableArea
.y1
= area
->area
.y2
;
889 if (scr
->totalUsableArea
.y2
> area
->area
.y1
)
890 scr
->totalUsableArea
.y2
= area
->area
.y1
;
896 if (scr
->totalUsableArea
.x1
< area
->area
.x2
)
897 scr
->totalUsableArea
.x1
= area
->area
.x2
;
900 if (scr
->totalUsableArea
.x2
> area
->area
.x1
)
901 scr
->totalUsableArea
.x2
= area
->area
.x1
;
907 #endif /* GNOME_STUFF */
909 if (scr
->totalUsableArea
.x2
- scr
->totalUsableArea
.x1
< scr
->scr_width
/2) {
910 scr
->totalUsableArea
.x2
= scr
->usableArea
.x2
;
911 scr
->totalUsableArea
.x1
= scr
->usableArea
.x1
;
913 if (scr
->totalUsableArea
.y2
- scr
->totalUsableArea
.y1
< scr
->scr_height
/2) {
914 scr
->totalUsableArea
.y2
= scr
->usableArea
.y2
;
915 scr
->totalUsableArea
.y1
= scr
->usableArea
.y1
;
923 for (i
= 0; i
< scr
->workspace_count
; i
++) {
924 wKWMSetUsableAreaHint(scr
, i
);
933 wScreenRestoreState(WScreen
*scr
)
940 if (wScreenCount
== 1)
941 path
= wdefaultspathfordomain("WMState");
944 sprintf(buf
, "WMState.%i", scr
->screen
);
945 path
= wdefaultspathfordomain(buf
);
947 scr
->session_state
= PLGetProplistWithPath(path
);
949 if (!scr
->session_state
&& wScreenCount
>1) {
951 sprintf(buf
, "WMState.%i", scr
->screen
);
952 path
= wdefaultspathfordomain(buf
);
953 scr
->session_state
= PLGetProplistWithPath(path
);
957 if (!wPreferences
.flags
.noclip
) {
958 state
= PLGetDictionaryEntry(scr
->session_state
, dClip
);
959 scr
->clip_icon
= wClipRestoreState(scr
, state
);
962 wWorkspaceRestoreState(scr
);
964 if (!wPreferences
.flags
.nodock
) {
965 state
= PLGetDictionaryEntry(scr
->session_state
, dDock
);
966 scr
->dock
= wDockRestoreState(scr
, state
, WM_DOCK
);
969 wScreenUpdateUsableArea(scr
);
974 wScreenSaveState(WScreen
*scr
)
976 WWorkspaceState wstate
;
979 proplist_t path
, old_state
, foo
;
986 * Save current workspace, so can go back to it upon restart.
988 wstate
.workspace
= scr
->current_workspace
;
990 data
[0] = wstate
.flags
;
991 data
[1] = wstate
.workspace
;
993 XChangeProperty(dpy
, scr
->root_win
, _XA_WINDOWMAKER_STATE
,
994 _XA_WINDOWMAKER_STATE
, 32, PropModeReplace
,
995 (unsigned char *) data
, 2);
997 /* save state of windows */
998 wwin
= scr
->focused_window
;
1000 wWindowSaveState(wwin
);
1005 if (wPreferences
.flags
.noupdates
)
1009 old_state
= scr
->session_state
;
1010 scr
->session_state
= PLMakeDictionaryFromEntries(NULL
, NULL
, NULL
);
1012 PLSetStringCmpHook(NULL
);
1014 /* save dock state to file */
1015 if (!wPreferences
.flags
.nodock
) {
1016 wDockSaveState(scr
);
1018 if ((foo
= PLGetDictionaryEntry(old_state
, dDock
))!=NULL
) {
1019 PLInsertDictionaryEntry(scr
->session_state
, dDock
, foo
);
1022 if (!wPreferences
.flags
.noclip
) {
1023 wClipSaveState(scr
);
1025 if ((foo
= PLGetDictionaryEntry(old_state
, dClip
))!=NULL
) {
1026 PLInsertDictionaryEntry(scr
->session_state
, dClip
, foo
);
1030 wWorkspaceSaveState(scr
, old_state
);
1032 if (wPreferences
.save_session_on_exit
) {
1033 wSessionSaveState(scr
);
1035 if ((foo
= PLGetDictionaryEntry(old_state
, dApplications
))!=NULL
) {
1036 PLInsertDictionaryEntry(scr
->session_state
, dApplications
, foo
);
1038 if ((foo
= PLGetDictionaryEntry(old_state
, dWorkspace
))!=NULL
) {
1039 PLInsertDictionaryEntry(scr
->session_state
, dWorkspace
, foo
);
1044 PLSetStringCmpHook(StringCompareHook
);
1046 wMenuSaveState(scr
);
1048 if (wScreenCount
== 1)
1049 str
= wdefaultspathfordomain("WMState");
1052 sprintf(buf
, "WMState.%i", scr
->screen
);
1053 str
= wdefaultspathfordomain(buf
);
1055 path
= PLMakeString(str
);
1057 PLSetFilename(scr
->session_state
, path
);
1058 if (!PLSave(scr
->session_state
, YES
)) {
1059 wwarning(_("could not save session state in %s"), PLGetString(path
));
1062 PLRelease(old_state
);
1068 wScreenBringInside(WScreen
*scr
, int *x
, int *y
, int width
, int height
)
1084 *x
= -tol_w
, moved
= 1;
1085 else if (*x
>= scr
->scr_width
- 10)
1086 *x
= scr
->scr_width
- tol_w
- 1, moved
= 1;
1088 if (*y
< -height
+ 10)
1089 *y
= -tol_h
, moved
= 1;
1090 else if (*y
>= scr
->scr_height
- 10)
1091 *y
= scr
->scr_height
- tol_h
- 1, moved
= 1;