1 // Screen.cc for Openbox
2 // Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
3 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
5 // Permission is hereby granted, free of charge, to any person obtaining a
6 // copy of this software and associated documentation files (the "Software"),
7 // to deal in the Software without restriction, including without limitation
8 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the
10 // Software is furnished to do so, subject to the following conditions:
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 // DEALINGS IN THE SOFTWARE.
23 // stupid macros needed to access some functions in version 2 of the GNU C
30 # include "../config.h"
31 #endif // HAVE_CONFIG_H
33 #include <X11/Xatom.h>
34 #include <X11/keysym.h>
38 #include "Clientmenu.h"
50 #include "Workspace.h"
51 #include "Workspacemenu.h"
56 #endif // HAVE_STDLIB_H
60 #endif // HAVE_STRING_H
62 #ifdef HAVE_SYS_TYPES_H
63 # include <sys/types.h>
64 #endif // HAVE_SYS_TYPES_H
68 #endif // HAVE_CTYPE_H
72 #endif // HAVE_DIRENT_H
76 #endif // HAVE_LOCALE_H
79 # include <sys/types.h>
81 #endif // HAVE_UNISTD_H
83 #ifdef HAVE_SYS_STAT_H
84 # include <sys/stat.h>
85 #endif // HAVE_SYS_STAT_H
89 #endif // HAVE_STDARG_H
92 # include "bsd-snprintf.h"
93 #endif // !HAVE_SNPRINTF
96 #define MAXPATHLEN 255
99 #ifndef FONT_ELEMENT_SIZE
100 #define FONT_ELEMENT_SIZE 50
101 #endif // FONT_ELEMENT_SIZE
105 #endif // HAVE_SSTREAM
109 static Bool running
= True
;
111 static int anotherWMRunning(Display
*display
, XErrorEvent
*) {
112 fprintf(stderr
, i18n
->getMessage(ScreenSet
, ScreenAnotherWMRunning
,
113 "BScreen::BScreen: an error occured while querying the X server.\n"
114 " another window manager already running on display %s.\n"),
115 DisplayString(display
));
123 bool operator()(const char *one
, const char *two
) const {
124 return (strcmp(one
, two
) < 0) ? True
: False
;
128 #ifndef HAVE_STRCASESTR
129 static const char * strcasestr(const char *str
, const char *ptn
) {
131 for( ; *str
; str
++) {
132 for(s2
=str
,p2
=ptn
; ; s2
++,p2
++) {
133 if (!*p2
) return str
;
134 if (toupper(*s2
) != toupper(*p2
)) break;
139 #endif // HAVE_STRCASESTR
141 static const char *getFontElement(const char *pattern
, char *buf
, int bufsiz
, ...) {
146 va_start(va
, bufsiz
);
149 while((v
= va_arg(va
, char *)) != NULL
) {
150 p
= strcasestr(pattern
, v
);
152 strncpy(buf
, p
+1, bufsiz
-2);
153 p2
= strchr(buf
, '-');
160 strncpy(buf
, "*", bufsiz
);
164 static const char *getFontSize(const char *pattern
, int *size
) {
169 for (p
=pattern
; 1; p
++) {
171 if (p2
!=NULL
&& n
>1 && n
<72) {
172 *size
= n
; return p2
+1;
174 *size
= 16; return NULL
;
176 } else if (*p
=='-') {
177 if (n
>1 && n
<72 && p2
!=NULL
) {
182 } else if (*p
>='0' && *p
<='9' && p2
!=NULL
) {
192 BScreen::BScreen(Openbox
&ob
, int scrn
, Resource
&conf
) : ScreenInfo(ob
, scrn
),
193 openbox(ob
), config(conf
)
195 event_mask
= ColormapChangeMask
| EnterWindowMask
| PropertyChangeMask
|
196 SubstructureRedirectMask
| KeyPressMask
| KeyReleaseMask
|
197 ButtonPressMask
| ButtonReleaseMask
;
199 XErrorHandler old
= XSetErrorHandler((XErrorHandler
) anotherWMRunning
);
200 XSelectInput(getBaseDisplay().getXDisplay(), getRootWindow(), event_mask
);
201 XSync(getBaseDisplay().getXDisplay(), False
);
202 XSetErrorHandler((XErrorHandler
) old
);
205 if (! managed
) return;
207 fprintf(stderr
, i18n
->getMessage(ScreenSet
, ScreenManagingScreen
,
208 "BScreen::BScreen: managing screen %d "
209 "using visual 0x%lx, depth %d\n"),
210 getScreenNumber(), XVisualIDFromVisual(getVisual()),
215 resource
.mstyle
.t_fontset
= resource
.mstyle
.f_fontset
=
216 resource
.tstyle
.fontset
= resource
.wstyle
.fontset
= NULL
;
217 resource
.mstyle
.t_font
= resource
.mstyle
.f_font
= resource
.tstyle
.font
=
218 resource
.wstyle
.font
= NULL
;
219 resource
.root_command
= NULL
;
227 pid_t bpid
= getpid();
229 XChangeProperty(getBaseDisplay().getXDisplay(), getRootWindow(),
230 openbox
.getOpenboxPidAtom(), XA_CARDINAL
,
231 sizeof(pid_t
) * 8, PropModeReplace
,
232 (unsigned char *) &bpid
, 1);
233 #endif // HAVE_GETPID
235 XDefineCursor(getBaseDisplay().getXDisplay(), getRootWindow(),
236 openbox
.getSessionCursor());
238 workspaceNames
= new LinkedList
<char>;
239 workspacesList
= new LinkedList
<Workspace
>;
240 rootmenuList
= new LinkedList
<Rootmenu
>;
241 netizenList
= new LinkedList
<Netizen
>;
242 iconList
= new LinkedList
<OpenboxWindow
>;
245 new BImageControl(openbox
, *this, True
, openbox
.getColorsPerChannel(),
246 openbox
.getCacheLife(), openbox
.getCacheMax());
247 image_control
->installRootColormap();
248 root_colormap_installed
= True
;
250 load(); // load config options from Resources
254 unsigned long gc_value_mask
= GCForeground
;
255 if (! i18n
->multibyte()) gc_value_mask
|= GCFont
;
257 gcv
.foreground
= WhitePixel(getBaseDisplay().getXDisplay(),
259 ^ BlackPixel(getBaseDisplay().getXDisplay(),
261 gcv
.function
= GXxor
;
262 gcv
.subwindow_mode
= IncludeInferiors
;
263 opGC
= XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
264 GCForeground
| GCFunction
| GCSubwindowMode
, &gcv
);
266 gcv
.foreground
= resource
.wstyle
.l_text_focus
.getPixel();
267 if (resource
.wstyle
.font
)
268 gcv
.font
= resource
.wstyle
.font
->fid
;
269 resource
.wstyle
.l_text_focus_gc
=
270 XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
271 gc_value_mask
, &gcv
);
273 gcv
.foreground
= resource
.wstyle
.l_text_unfocus
.getPixel();
274 if (resource
.wstyle
.font
)
275 gcv
.font
= resource
.wstyle
.font
->fid
;
276 resource
.wstyle
.l_text_unfocus_gc
=
277 XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
278 gc_value_mask
, &gcv
);
280 gcv
.foreground
= resource
.wstyle
.b_pic_focus
.getPixel();
281 resource
.wstyle
.b_pic_focus_gc
=
282 XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
285 gcv
.foreground
= resource
.wstyle
.b_pic_unfocus
.getPixel();
286 resource
.wstyle
.b_pic_unfocus_gc
=
287 XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
290 gcv
.foreground
= resource
.mstyle
.t_text
.getPixel();
291 if (resource
.mstyle
.t_font
)
292 gcv
.font
= resource
.mstyle
.t_font
->fid
;
293 resource
.mstyle
.t_text_gc
=
294 XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
295 gc_value_mask
, &gcv
);
297 gcv
.foreground
= resource
.mstyle
.f_text
.getPixel();
298 if (resource
.mstyle
.f_font
)
299 gcv
.font
= resource
.mstyle
.f_font
->fid
;
300 resource
.mstyle
.f_text_gc
=
301 XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
302 gc_value_mask
, &gcv
);
304 gcv
.foreground
= resource
.mstyle
.h_text
.getPixel();
305 resource
.mstyle
.h_text_gc
=
306 XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
307 gc_value_mask
, &gcv
);
309 gcv
.foreground
= resource
.mstyle
.d_text
.getPixel();
310 resource
.mstyle
.d_text_gc
=
311 XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
312 gc_value_mask
, &gcv
);
314 gcv
.foreground
= resource
.mstyle
.hilite
.getColor()->getPixel();
315 resource
.mstyle
.hilite_gc
=
316 XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
317 gc_value_mask
, &gcv
);
319 gcv
.foreground
= resource
.tstyle
.l_text
.getPixel();
320 if (resource
.tstyle
.font
)
321 gcv
.font
= resource
.tstyle
.font
->fid
;
322 resource
.tstyle
.l_text_gc
=
323 XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
324 gc_value_mask
, &gcv
);
326 gcv
.foreground
= resource
.tstyle
.w_text
.getPixel();
327 resource
.tstyle
.w_text_gc
=
328 XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
329 gc_value_mask
, &gcv
);
331 gcv
.foreground
= resource
.tstyle
.c_text
.getPixel();
332 resource
.tstyle
.c_text_gc
=
333 XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
334 gc_value_mask
, &gcv
);
336 gcv
.foreground
= resource
.tstyle
.b_pic
.getPixel();
337 resource
.tstyle
.b_pic_gc
=
338 XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
339 gc_value_mask
, &gcv
);
341 const char *s
= i18n
->getMessage(ScreenSet
, ScreenPositionLength
,
342 "0: 0000 x 0: 0000");
345 if (i18n
->multibyte()) {
346 XRectangle ink
, logical
;
347 XmbTextExtents(resource
.wstyle
.fontset
, s
, l
, &ink
, &logical
);
348 geom_w
= logical
.width
;
350 geom_h
= resource
.wstyle
.fontset_extents
->max_ink_extent
.height
;
352 geom_h
= resource
.wstyle
.font
->ascent
+
353 resource
.wstyle
.font
->descent
;
355 geom_w
= XTextWidth(resource
.wstyle
.font
, s
, l
);
358 geom_w
+= (resource
.bevel_width
* 2);
359 geom_h
+= (resource
.bevel_width
* 2);
361 XSetWindowAttributes attrib
;
362 unsigned long mask
= CWBorderPixel
| CWColormap
| CWSaveUnder
;
363 attrib
.border_pixel
= getBorderColor()->getPixel();
364 attrib
.colormap
= getColormap();
365 attrib
.save_under
= True
;
368 XCreateWindow(getBaseDisplay().getXDisplay(), getRootWindow(),
369 0, 0, geom_w
, geom_h
, resource
.border_width
, getDepth(),
370 InputOutput
, getVisual(), mask
, &attrib
);
371 geom_visible
= False
;
373 if (resource
.wstyle
.l_focus
.getTexture() & BImage_ParentRelative
) {
374 if (resource
.wstyle
.t_focus
.getTexture() ==
375 (BImage_Flat
| BImage_Solid
)) {
377 XSetWindowBackground(getBaseDisplay().getXDisplay(), geom_window
,
378 resource
.wstyle
.t_focus
.getColor()->getPixel());
380 geom_pixmap
= image_control
->renderImage(geom_w
, geom_h
,
381 &resource
.wstyle
.t_focus
);
382 XSetWindowBackgroundPixmap(getBaseDisplay().getXDisplay(),
383 geom_window
, geom_pixmap
);
386 if (resource
.wstyle
.l_focus
.getTexture() ==
387 (BImage_Flat
| BImage_Solid
)) {
389 XSetWindowBackground(getBaseDisplay().getXDisplay(), geom_window
,
390 resource
.wstyle
.l_focus
.getColor()->getPixel());
392 geom_pixmap
= image_control
->renderImage(geom_w
, geom_h
,
393 &resource
.wstyle
.l_focus
);
394 XSetWindowBackgroundPixmap(getBaseDisplay().getXDisplay(),
395 geom_window
, geom_pixmap
);
399 workspacemenu
= new Workspacemenu(*this);
400 iconmenu
= new Iconmenu(*this);
401 configmenu
= new Configmenu(*this);
403 Workspace
*wkspc
= NULL
;
404 if (resource
.workspaces
!= 0) {
405 for (int i
= 0; i
< resource
.workspaces
; ++i
) {
406 wkspc
= new Workspace(*this, workspacesList
->count());
407 workspacesList
->insert(wkspc
);
408 saveWorkspaceNames();
409 workspacemenu
->insert(wkspc
->getName(), wkspc
->getMenu());
412 wkspc
= new Workspace(*this, workspacesList
->count());
413 workspacesList
->insert(wkspc
);
414 saveWorkspaceNames();
415 workspacemenu
->insert(wkspc
->getName(), wkspc
->getMenu());
418 workspacemenu
->insert(i18n
->getMessage(IconSet
, IconIcons
, "Icons"),
420 workspacemenu
->update();
422 current_workspace
= workspacesList
->first();
423 workspacemenu
->setItemSelected(2, True
);
425 toolbar
= new Toolbar(*this, config
);
428 slit
= new Slit(*this, config
);
436 changeWorkspaceID(0);
440 Window r
, p
, *children
;
441 XQueryTree(getBaseDisplay().getXDisplay(), getRootWindow(), &r
, &p
,
444 // preen the window list of all icon windows... for better dockapp support
445 for (i
= 0; i
< (int) nchild
; i
++) {
446 if (children
[i
] == None
) continue;
448 XWMHints
*wmhints
= XGetWMHints(getBaseDisplay().getXDisplay(),
452 if ((wmhints
->flags
& IconWindowHint
) &&
453 (wmhints
->icon_window
!= children
[i
]))
454 for (int j
= 0; j
< (int) nchild
; j
++)
455 if (children
[j
] == wmhints
->icon_window
) {
465 // manage shown windows
466 for (i
= 0; i
< (int) nchild
; ++i
) {
467 if (children
[i
] == None
|| (! openbox
.validateWindow(children
[i
])))
470 XWindowAttributes attrib
;
471 if (XGetWindowAttributes(getBaseDisplay().getXDisplay(), children
[i
],
473 if (attrib
.override_redirect
) continue;
475 if (attrib
.map_state
!= IsUnmapped
) {
476 new OpenboxWindow(openbox
, children
[i
], this);
478 OpenboxWindow
*win
= openbox
.searchWindow(children
[i
]);
480 XMapRequestEvent mre
;
481 mre
.window
= children
[i
];
482 win
->restoreAttributes();
483 win
->mapRequestEvent(&mre
);
489 if (! resource
.sloppy_focus
)
490 XSetInputFocus(getBaseDisplay().getXDisplay(), toolbar
->getWindowID(),
491 RevertToParent
, CurrentTime
);
494 XFlush(getBaseDisplay().getXDisplay());
498 BScreen::~BScreen(void) {
499 if (! managed
) return;
501 if (geom_pixmap
!= None
)
502 image_control
->removeImage(geom_pixmap
);
504 if (geom_window
!= None
)
505 XDestroyWindow(getBaseDisplay().getXDisplay(), geom_window
);
507 removeWorkspaceNames();
509 while (workspacesList
->count())
510 delete workspacesList
->remove(0);
512 while (rootmenuList
->count())
513 rootmenuList
->remove(0);
515 while (iconList
->count())
516 delete iconList
->remove(0);
518 while (netizenList
->count())
519 delete netizenList
->remove(0);
522 if (resource
.strftime_format
)
523 delete [] resource
.strftime_format
;
524 #endif // HAVE_STRFTIME
527 delete workspacemenu
;
536 delete image_control
;
538 delete workspacesList
;
539 delete workspaceNames
;
544 if (resource
.wstyle
.fontset
)
545 XFreeFontSet(getBaseDisplay().getXDisplay(), resource
.wstyle
.fontset
);
546 if (resource
.mstyle
.t_fontset
)
547 XFreeFontSet(getBaseDisplay().getXDisplay(), resource
.mstyle
.t_fontset
);
548 if (resource
.mstyle
.f_fontset
)
549 XFreeFontSet(getBaseDisplay().getXDisplay(), resource
.mstyle
.f_fontset
);
550 if (resource
.tstyle
.fontset
)
551 XFreeFontSet(getBaseDisplay().getXDisplay(), resource
.tstyle
.fontset
);
553 if (resource
.wstyle
.font
)
554 XFreeFont(getBaseDisplay().getXDisplay(), resource
.wstyle
.font
);
555 if (resource
.mstyle
.t_font
)
556 XFreeFont(getBaseDisplay().getXDisplay(), resource
.mstyle
.t_font
);
557 if (resource
.mstyle
.f_font
)
558 XFreeFont(getBaseDisplay().getXDisplay(), resource
.mstyle
.f_font
);
559 if (resource
.tstyle
.font
)
560 XFreeFont(getBaseDisplay().getXDisplay(), resource
.tstyle
.font
);
561 if (resource
.root_command
!= NULL
)
562 delete [] resource
.root_command
;
564 XFreeGC(getBaseDisplay().getXDisplay(), opGC
);
566 XFreeGC(getBaseDisplay().getXDisplay(),
567 resource
.wstyle
.l_text_focus_gc
);
568 XFreeGC(getBaseDisplay().getXDisplay(),
569 resource
.wstyle
.l_text_unfocus_gc
);
570 XFreeGC(getBaseDisplay().getXDisplay(),
571 resource
.wstyle
.b_pic_focus_gc
);
572 XFreeGC(getBaseDisplay().getXDisplay(),
573 resource
.wstyle
.b_pic_unfocus_gc
);
575 XFreeGC(getBaseDisplay().getXDisplay(),
576 resource
.mstyle
.t_text_gc
);
577 XFreeGC(getBaseDisplay().getXDisplay(),
578 resource
.mstyle
.f_text_gc
);
579 XFreeGC(getBaseDisplay().getXDisplay(),
580 resource
.mstyle
.h_text_gc
);
581 XFreeGC(getBaseDisplay().getXDisplay(),
582 resource
.mstyle
.d_text_gc
);
583 XFreeGC(getBaseDisplay().getXDisplay(),
584 resource
.mstyle
.hilite_gc
);
586 XFreeGC(getBaseDisplay().getXDisplay(),
587 resource
.tstyle
.l_text_gc
);
588 XFreeGC(getBaseDisplay().getXDisplay(),
589 resource
.tstyle
.w_text_gc
);
590 XFreeGC(getBaseDisplay().getXDisplay(),
591 resource
.tstyle
.c_text_gc
);
592 XFreeGC(getBaseDisplay().getXDisplay(),
593 resource
.tstyle
.b_pic_gc
);
597 Rect
BScreen::availableArea() const {
598 // the following code is temporary and will be taken care of by Screen in the
599 // future (with the NETWM 'strut')
600 Rect
space(0, 0, size().w(), size().h());
601 if (!resource
.full_max
) {
603 int slit_x
= slit
->autoHide() ? slit
->hiddenOrigin().x() : slit
->area().x(),
604 slit_y
= slit
->autoHide() ? slit
->hiddenOrigin().y() : slit
->area().y();
605 int tbarh
= resource
.hide_toolbar
? 0 :
606 toolbar
->getExposedHeight() + resource
.border_width
* 2;
608 switch (toolbar
->placement()) {
609 case Toolbar::TopLeft
:
610 case Toolbar::TopCenter
:
611 case Toolbar::TopRight
:
614 case Toolbar::BottomLeft
:
615 case Toolbar::BottomCenter
:
616 case Toolbar::BottomRight
:
620 ASSERT(false); // unhandled placement
622 if ((slit
->direction() == Slit::Horizontal
&&
623 (slit
->placement() == Slit::TopLeft
||
624 slit
->placement() == Slit::TopRight
)) ||
625 slit
->placement() == Slit::TopCenter
) {
627 if (tbartop
&& slit_y
+ slit
->area().h() < tbarh
) {
628 space
.setY(space
.y() + tbarh
);
629 space
.setH(space
.h() - tbarh
);
631 space
.setY(space
.y() + (slit_y
+ slit
->area().h() +
632 resource
.border_width
* 2));
633 space
.setH(space
.h() - (slit_y
+ slit
->area().h() +
634 resource
.border_width
* 2));
636 space
.setH(space
.h() - tbarh
);
638 } else if ((slit
->direction() == Slit::Vertical
&&
639 (slit
->placement() == Slit::TopRight
||
640 slit
->placement() == Slit::BottomRight
)) ||
641 slit
->placement() == Slit::CenterRight
) {
643 space
.setW(space
.w() - (size().w() - slit_x
));
645 space
.setY(space
.y() + tbarh
);
646 space
.setH(space
.h() - tbarh
);
647 } else if ((slit
->direction() == Slit::Horizontal
&&
648 (slit
->placement() == Slit::BottomLeft
||
649 slit
->placement() == Slit::BottomRight
)) ||
650 slit
->placement() == Slit::BottomCenter
) {
652 if (!tbartop
&& (size().h() - slit_y
) < tbarh
) {
653 space
.setH(space
.h() - tbarh
);
655 space
.setH(space
.h() - (size().h() - slit_y
));
657 space
.setY(space
.y() + tbarh
);
658 space
.setH(space
.h() - tbarh
);
661 } else {// if ((slit->direction() == Slit::Vertical &&
662 // (slit->placement() == Slit::TopLeft ||
663 // slit->placement() == Slit::BottomLeft)) ||
664 // slit->placement() == Slit::CenterLeft)
666 space
.setX(slit_x
+ slit
->area().w() +
667 resource
.border_width
* 2);
668 space
.setW(space
.w() - (slit_x
+ slit
->area().w() +
669 resource
.border_width
* 2));
671 space
.setY(space
.y() + tbarh
);
672 space
.setH(space
.h() - tbarh
);
675 int tbarh
= resource
.hide_toolbar() ? 0 :
676 toolbar
->getExposedHeight() + resource
.border_width
* 2;
677 switch (toolbar
->placement()) {
678 case Toolbar::TopLeft
:
679 case Toolbar::TopCenter
:
680 case Toolbar::TopRight
:
681 space
.setY(toolbar
->getExposedHeight());
682 space
.setH(space
.h() - toolbar
->getExposedHeight());
684 case Toolbar::BottomLeft
:
685 case Toolbar::BottomCenter
:
686 case Toolbar::BottomRight
:
687 space
.setH(space
.h() - tbarh
);
690 ASSERT(false); // unhandled placement
698 void BScreen::readDatabaseTexture(const char *rname
, const char *rclass
,
700 unsigned long default_pixel
)
704 if (resource
.styleconfig
.getValue(rname
, rclass
, s
))
705 image_control
->parseTexture(texture
, s
.c_str());
707 texture
->setTexture(BImage_Solid
| BImage_Flat
);
709 if (texture
->getTexture() & BImage_Solid
) {
710 int clen
= strlen(rclass
) + 32, nlen
= strlen(rname
) + 32;
712 char *colorclass
= new char[clen
], *colorname
= new char[nlen
];
714 sprintf(colorclass
, "%s.Color", rclass
);
715 sprintf(colorname
, "%s.color", rname
);
717 readDatabaseColor(colorname
, colorclass
, texture
->getColor(),
721 sprintf(colorclass
, "%s.ColorTo", rclass
);
722 sprintf(colorname
, "%s.colorTo", rname
);
724 readDatabaseColor(colorname
, colorclass
, texture
->getColorTo(),
728 delete [] colorclass
;
731 if ((! texture
->getColor()->isAllocated()) ||
732 (texture
->getTexture() & BImage_Flat
))
737 xcol
.red
= (unsigned int) (texture
->getColor()->getRed() +
738 (texture
->getColor()->getRed() >> 1));
739 if (xcol
.red
>= 0xff) xcol
.red
= 0xffff;
740 else xcol
.red
*= 0xff;
741 xcol
.green
= (unsigned int) (texture
->getColor()->getGreen() +
742 (texture
->getColor()->getGreen() >> 1));
743 if (xcol
.green
>= 0xff) xcol
.green
= 0xffff;
744 else xcol
.green
*= 0xff;
745 xcol
.blue
= (unsigned int) (texture
->getColor()->getBlue() +
746 (texture
->getColor()->getBlue() >> 1));
747 if (xcol
.blue
>= 0xff) xcol
.blue
= 0xffff;
748 else xcol
.blue
*= 0xff;
750 if (! XAllocColor(getBaseDisplay().getXDisplay(),
751 getColormap(), &xcol
))
754 texture
->getHiColor()->setPixel(xcol
.pixel
);
757 (unsigned int) ((texture
->getColor()->getRed() >> 2) +
758 (texture
->getColor()->getRed() >> 1)) * 0xff;
760 (unsigned int) ((texture
->getColor()->getGreen() >> 2) +
761 (texture
->getColor()->getGreen() >> 1)) * 0xff;
763 (unsigned int) ((texture
->getColor()->getBlue() >> 2) +
764 (texture
->getColor()->getBlue() >> 1)) * 0xff;
766 if (! XAllocColor(getBaseDisplay().getXDisplay(),
767 getColormap(), &xcol
))
770 texture
->getLoColor()->setPixel(xcol
.pixel
);
771 } else if (texture
->getTexture() & BImage_Gradient
) {
772 int clen
= strlen(rclass
) + 10, nlen
= strlen(rname
) + 10;
774 char *colorclass
= new char[clen
], *colorname
= new char[nlen
],
775 *colortoclass
= new char[clen
], *colortoname
= new char[nlen
];
777 sprintf(colorclass
, "%s.Color", rclass
);
778 sprintf(colorname
, "%s.color", rname
);
780 sprintf(colortoclass
, "%s.ColorTo", rclass
);
781 sprintf(colortoname
, "%s.colorTo", rname
);
783 readDatabaseColor(colorname
, colorclass
, texture
->getColor(),
785 readDatabaseColor(colortoname
, colortoclass
, texture
->getColorTo(),
788 delete [] colorclass
;
790 delete [] colortoclass
;
791 delete [] colortoname
;
796 void BScreen::readDatabaseColor(const char *rname
, const char *rclass
,
797 BColor
*color
, unsigned long default_pixel
)
801 if (resource
.styleconfig
.getValue(rname
, rclass
, s
))
802 image_control
->parseColor(color
, s
.c_str());
804 // parsing with no color string just deallocates the color, if it has
805 // been previously allocated
806 image_control
->parseColor(color
);
807 color
->setPixel(default_pixel
);
812 void BScreen::readDatabaseFontSet(const char *rname
, const char *rclass
,
814 if (! fontset
) return;
816 static char *defaultFont
= "fixed";
817 bool load_default
= false;
821 XFreeFontSet(getBaseDisplay().getXDisplay(), *fontset
);
823 if (resource
.styleconfig
.getValue(rname
, rclass
, s
)) {
824 if (! (*fontset
= createFontSet(s
.c_str())))
830 *fontset
= createFontSet(defaultFont
);
833 fprintf(stderr
, i18n
->getMessage(ScreenSet
, ScreenDefaultFontLoadFail
,
834 "BScreen::LoadStyle(): couldn't load default font.\n"));
841 void BScreen::readDatabaseFont(const char *rname
, const char *rclass
,
842 XFontStruct
**font
) {
845 static char *defaultFont
= "fixed";
846 bool load_default
= false;
850 XFreeFont(getBaseDisplay().getXDisplay(), *font
);
852 if (resource
.styleconfig
.getValue(rname
, rclass
, s
)) {
853 if ((*font
= XLoadQueryFont(getBaseDisplay().getXDisplay(),
854 s
.c_str())) == NULL
) {
855 fprintf(stderr
, i18n
->getMessage(ScreenSet
, ScreenFontLoadFail
,
856 "BScreen::LoadStyle(): couldn't load font '%s'\n"),
864 if ((*font
= XLoadQueryFont(getBaseDisplay().getXDisplay(),
865 defaultFont
)) == NULL
) {
866 fprintf(stderr
, i18n
->getMessage(ScreenSet
, ScreenDefaultFontLoadFail
,
867 "BScreen::LoadStyle(): couldn't load default font.\n"));
874 XFontSet
BScreen::createFontSet(const char *fontname
) {
876 char **missing
, *def
= "-";
877 int nmissing
, pixel_size
= 0, buf_size
= 0;
878 char weight
[FONT_ELEMENT_SIZE
], slant
[FONT_ELEMENT_SIZE
];
880 fs
= XCreateFontSet(getBaseDisplay().getXDisplay(),
881 fontname
, &missing
, &nmissing
, &def
);
882 if (fs
&& (! nmissing
)) return fs
;
884 #ifdef HAVE_SETLOCALE
886 if (nmissing
) XFreeStringList(missing
);
888 setlocale(LC_CTYPE
, "C");
889 fs
= XCreateFontSet(getBaseDisplay().getXDisplay(), fontname
,
890 &missing
, &nmissing
, &def
);
891 setlocale(LC_CTYPE
, "");
893 #endif // HAVE_SETLOCALE
896 XFontStruct
**fontstructs
;
898 XFontsOfFontSet(fs
, &fontstructs
, &fontnames
);
899 fontname
= fontnames
[0];
902 getFontElement(fontname
, weight
, FONT_ELEMENT_SIZE
,
903 "-medium-", "-bold-", "-demibold-", "-regular-", NULL
);
904 getFontElement(fontname
, slant
, FONT_ELEMENT_SIZE
,
905 "-r-", "-i-", "-o-", "-ri-", "-ro-", NULL
);
906 getFontSize(fontname
, &pixel_size
);
908 if (! strcmp(weight
, "*")) strncpy(weight
, "medium", FONT_ELEMENT_SIZE
);
909 if (! strcmp(slant
, "*")) strncpy(slant
, "r", FONT_ELEMENT_SIZE
);
910 if (pixel_size
< 3) pixel_size
= 3;
911 else if (pixel_size
> 97) pixel_size
= 97;
913 buf_size
= strlen(fontname
) + (FONT_ELEMENT_SIZE
* 2) + 64;
914 char *pattern2
= new char[buf_size
];
915 snprintf(pattern2
, buf_size
- 1,
917 "-*-*-%s-%s-*-*-%d-*-*-*-*-*-*-*,"
918 "-*-*-*-*-*-*-%d-*-*-*-*-*-*-*,*",
919 fontname
, weight
, slant
, pixel_size
, pixel_size
);
922 if (nmissing
) XFreeStringList(missing
);
923 if (fs
) XFreeFontSet(getBaseDisplay().getXDisplay(), fs
);
925 fs
= XCreateFontSet(getBaseDisplay().getXDisplay(), fontname
,
926 &missing
, &nmissing
, &def
);
933 void BScreen::setSloppyFocus(bool b
) {
934 resource
.sloppy_focus
= b
;
935 std::ostringstream s
;
936 s
<< "session.screen" << getScreenNumber() << ".focusModel";
937 config
.setValue(s
.str(),
938 (resource
.sloppy_focus
?
939 (resource
.auto_raise
? "AutoRaiseSloppyFocus" : "SloppyFocus")
944 void BScreen::setAutoRaise(bool a
) {
945 resource
.auto_raise
= a
;
946 std::ostringstream s
;
947 s
<< "session.screen" << getScreenNumber() << ".focusModel";
948 config
.setValue(s
.str(),
949 (resource
.sloppy_focus
?
950 (resource
.auto_raise
? "AutoRaiseSloppyFocus" : "SloppyFocus")
955 void BScreen::setImageDither(bool d
, bool reconfig
) {
956 resource
.image_dither
= d
;
957 image_control
->setDither(d
);
958 std::ostringstream s
;
959 s
<< "session.screen" << getScreenNumber() << ".imageDither";
960 config
.setValue(s
.str(), resource
.image_dither
);
966 void BScreen::setOpaqueMove(bool o
) {
967 resource
.opaque_move
= o
;
968 std::ostringstream s
;
969 s
<< "session.screen" << getScreenNumber() << ".opaqueMove";
970 config
.setValue(s
.str(), resource
.opaque_move
);
974 void BScreen::setFullMax(bool f
) {
975 resource
.full_max
= f
;
976 std::ostringstream s
;
977 s
<< "session.screen" << getScreenNumber() << ".fullMaximization";
978 config
.setValue(s
.str(), resource
.full_max
);
980 s
.rdbuf()->freeze(0);
981 #endif // HAVE_SSTREAM
985 void BScreen::setFocusNew(bool f
) {
986 resource
.focus_new
= f
;
987 std::ostringstream s
;
988 s
<< "session.screen" << getScreenNumber() << ".focusNewWindows";
989 config
.setValue(s
.str(), resource
.focus_new
);
993 void BScreen::setFocusLast(bool f
) {
994 resource
.focus_last
= f
;
995 std::ostringstream s
;
996 s
<< "session.screen" << getScreenNumber() << ".focusLastWindow";
997 config
.setValue(s
.str(), resource
.focus_last
);
1001 void BScreen::setWindowZones(int z
) {
1003 std::ostringstream s
;
1004 s
<< "session.screen" << getScreenNumber() << ".windowZones";
1005 config
.setValue(s
.str(), resource
.zones
);
1009 void BScreen::setWorkspaceCount(int w
) {
1010 resource
.workspaces
= w
;
1011 std::ostringstream s
;
1012 s
<< "session.screen" << getScreenNumber() << ".workspaces";
1013 config
.setValue(s
.str(), resource
.workspaces
);
1017 void BScreen::setPlacementPolicy(int p
) {
1018 resource
.placement_policy
= p
;
1019 std::ostringstream s
;
1020 s
<< "session.screen" << getScreenNumber() << ".windowPlacement";
1021 const char *placement
;
1022 switch (resource
.placement_policy
) {
1023 case CascadePlacement
: placement
= "CascadePlacement"; break;
1024 case BestFitPlacement
: placement
= "BestFitPlacement"; break;
1025 case ColSmartPlacement
: placement
= "ColSmartPlacement"; break;
1026 case UnderMousePlacement
: placement
= "UnderMousePlacement"; break;
1027 case ClickMousePlacement
: placement
= "ClickMousePlacement"; break;
1029 case RowSmartPlacement
: placement
= "RowSmartPlacement"; break;
1031 config
.setValue(s
.str(), placement
);
1035 void BScreen::setEdgeSnapThreshold(int t
) {
1036 resource
.edge_snap_threshold
= t
;
1037 std::ostringstream s
;
1038 s
<< "session.screen" << getScreenNumber() << ".edgeSnapThreshold";
1039 config
.setValue(s
.str(), resource
.edge_snap_threshold
);
1043 void BScreen::setRowPlacementDirection(int d
) {
1044 resource
.row_direction
= d
;
1045 std::ostringstream s
;
1046 s
<< "session.screen" << getScreenNumber() << ".rowPlacementDirection";
1047 config
.setValue(s
.str(),
1048 resource
.row_direction
== LeftRight
?
1049 "LeftToRight" : "RightToLeft");
1053 void BScreen::setColPlacementDirection(int d
) {
1054 resource
.col_direction
= d
;
1055 std::ostringstream s
;
1056 s
<< "session.screen" << getScreenNumber() << ".colPlacementDirection";
1057 config
.setValue(s
.str(),
1058 resource
.col_direction
== TopBottom
?
1059 "TopToBottom" : "BottomToTop");
1063 void BScreen::setRootCommand(const char *cmd
) {
1064 if (resource
.root_command
!= NULL
)
1065 delete [] resource
.root_command
;
1067 resource
.root_command
= bstrdup(cmd
);
1069 resource
.root_command
= NULL
;
1070 // this doesn't save to the Resources config because it can't be changed
1071 // inside Openbox, and this way we dont add an empty command which would over-
1072 // ride the styles command when none has been specified
1076 #ifdef HAVE_STRFTIME
1077 void BScreen::setStrftimeFormat(const char *f
) {
1078 if (resource
.strftime_format
!= NULL
)
1079 delete [] resource
.strftime_format
;
1081 resource
.strftime_format
= bstrdup(f
);
1082 std::ostringstream s
;
1083 s
<< "session.screen" << getScreenNumber() << ".strftimeFormat";
1084 config
.setValue(s
.str(), resource
.strftime_format
);
1087 #else // !HAVE_STRFTIME
1088 void BScreen::setDateFormat(int f
) {
1089 resource
.date_format
= f
;
1090 std::ostringstream s
;
1091 s
<< "session.screen" << getScreenNumber() << ".dateFormat";
1092 config
.setValue(s
.str(), resource
.date_format
== B_EuropeanDate
?
1093 "European" : "American");
1096 void BScreen::setClock24Hour(Bool c
) {
1097 resource
.clock24hour
= c
;
1098 std::ostringstream s
;
1099 s
<< "session.screen" << getScreenNumber() << ".clockFormat";
1100 config
.setValue(s
.str(), resource
.clock24hour
? 24 : 12);
1102 #endif // HAVE_STRFTIME
1104 void BScreen::setHideToolbar(bool b
) {
1105 resource
.hide_toolbar
= b
;
1106 if (resource
.hide_toolbar
)
1107 getToolbar()->unMapToolbar();
1109 getToolbar()->mapToolbar();
1110 std::ostringstream s
;
1111 s
<< "session.screen" << getScreenNumber() << ".hideToolbar";
1112 config
.setValue(s
.str(), resource
.hide_toolbar
? "True" : "False");
1115 void BScreen::saveWorkspaceNames() {
1116 std::ostringstream rc
, names
;
1118 for (int i
= 0; i
< resource
.workspaces
; i
++) {
1119 Workspace
*w
= getWorkspace(i
);
1121 names
<< w
->getName();
1122 if (i
< resource
.workspaces
-1)
1128 rc
<< "session.screen" << getScreenNumber() << ".workspaceNames";
1129 config
.setValue(rc
.str(), names
.str());
1132 void BScreen::save() {
1133 setSloppyFocus(resource
.sloppy_focus
);
1134 setAutoRaise(resource
.auto_raise
);
1135 setImageDither(resource
.image_dither
, false);
1136 setOpaqueMove(resource
.opaque_move
);
1137 setFullMax(resource
.full_max
);
1138 setFocusNew(resource
.focus_new
);
1139 setFocusLast(resource
.focus_last
);
1140 setWindowZones(resource
.zones
);
1141 setWorkspaceCount(resource
.workspaces
);
1142 setPlacementPolicy(resource
.placement_policy
);
1143 setEdgeSnapThreshold(resource
.edge_snap_threshold
);
1144 setRowPlacementDirection(resource
.row_direction
);
1145 setColPlacementDirection(resource
.col_direction
);
1146 setRootCommand(resource
.root_command
);
1147 #ifdef HAVE_STRFTIME
1148 // it deletes the current value before setting the new one, so we have to
1149 // duplicate the current value.
1150 std::string s
= resource
.strftime_format
;
1151 setStrftimeFormat(s
.c_str());
1152 #else // !HAVE_STRFTIME
1153 setDateFormat(resource
.date_format
);
1154 setClock24Hour(resource
.clock24hour
);
1155 #endif // HAVE_STRFTIME
1156 setHideToolbar(resource
.hide_toolbar
);
1159 void BScreen::load() {
1160 std::ostringstream rscreen
, rname
, rclass
;
1164 rscreen
<< "session.screen" << getScreenNumber() << '.';
1166 rname
<< rscreen
.str() << "hideToolbar";
1167 rclass
<< rscreen
.str() << "HideToolbar";
1168 if (config
.getValue(rname
.str(), rclass
.str(), b
))
1169 resource
.hide_toolbar
= b
;
1171 resource
.hide_toolbar
= false;
1172 Toolbar
*t
= getToolbar();
1174 if (resource
.hide_toolbar
)
1180 rname
.seekp(0); rclass
.seekp(0);
1181 rname
<< rscreen
.str() << "fullMaximization";
1182 rclass
<< rscreen
.str() << "FullMaximization";
1183 if (config
.getValue(rname
.str(), rclass
.str(), b
))
1184 resource
.full_max
= b
;
1186 resource
.full_max
= false;
1188 rname
.seekp(0); rclass
.seekp(0);
1189 rname
<< rscreen
.str() << "focusNewWindows";
1190 rclass
<< rscreen
.str() << "FocusNewWindows";
1191 if (config
.getValue(rname
.str(), rclass
.str(), b
))
1192 resource
.focus_new
= b
;
1194 resource
.focus_new
= false;
1196 rname
.seekp(0); rclass
.seekp(0);
1197 rname
<< rscreen
.str() << "focusLastWindow";
1198 rclass
<< rscreen
.str() << "FocusLastWindow";
1199 if (config
.getValue(rname
.str(), rclass
.str(), b
))
1200 resource
.focus_last
= b
;
1202 resource
.focus_last
= false;
1204 rname
.seekp(0); rclass
.seekp(0);
1205 rname
<< rscreen
.str() << "rowPlacementDirection";
1206 rclass
<< rscreen
.str() << "RowPlacementDirection";
1207 if (config
.getValue(rname
.str(), rclass
.str(), s
)) {
1208 if (0 == strncasecmp(s
.c_str(), "RightToLeft", s
.length()))
1209 resource
.row_direction
= RightLeft
;
1210 else //if (0 == strncasecmp(s.c_str(), "LeftToRight", s.length()))
1211 resource
.row_direction
= LeftRight
;
1213 resource
.row_direction
= LeftRight
;
1215 rname
.seekp(0); rclass
.seekp(0);
1216 rname
<< rscreen
.str() << "colPlacementDirection";
1217 rclass
<< rscreen
.str() << "ColPlacementDirection";
1218 if (config
.getValue(rname
.str(), rclass
.str(), s
)) {
1219 if (0 == strncasecmp(s
.c_str(), "BottomToTop", s
.length()))
1220 resource
.col_direction
= BottomTop
;
1221 else //if (0 == strncasecmp(s.c_str(), "TopToBottom", s.length()))
1222 resource
.col_direction
= TopBottom
;
1224 resource
.col_direction
= TopBottom
;
1226 rname
.seekp(0); rclass
.seekp(0);
1227 rname
<< rscreen
.str() << "workspaces";
1228 rclass
<< rscreen
.str() << "Workspaces";
1229 if (config
.getValue(rname
.str(), rclass
.str(), l
))
1230 resource
.workspaces
= l
;
1232 resource
.workspaces
= 1;
1234 removeWorkspaceNames();
1235 rname
.seekp(0); rclass
.seekp(0);
1236 rname
<< rscreen
.str() << "workspaceNames";
1237 rclass
<< rscreen
.str() << "WorkspaceNames";
1238 if (config
.getValue(rname
.str(), rclass
.str(), s
)) {
1239 std::string::const_iterator it
= s
.begin(), end
= s
.end();
1241 std::string::const_iterator tmp
= it
;// current string.begin()
1242 it
= std::find(tmp
, end
, ','); // look for comma between tmp and end
1243 std::string
name(tmp
, it
); // name = s[tmp:it]
1244 addWorkspaceName(name
.c_str());
1251 rname
.seekp(0); rclass
.seekp(0);
1252 rname
<< rscreen
.str() << "focusModel";
1253 rclass
<< rscreen
.str() << "FocusModel";
1254 if (config
.getValue(rname
.str(), rclass
.str(), s
)) {
1255 if (0 == strncasecmp(s
.c_str(), "ClickToFocus", s
.length())) {
1256 resource
.auto_raise
= false;
1257 resource
.sloppy_focus
= false;
1258 } else if (0 == strncasecmp(s
.c_str(), "AutoRaiseSloppyFocus",
1260 resource
.sloppy_focus
= true;
1261 resource
.auto_raise
= true;
1262 } else { //if (0 == strncasecmp(s.c_str(), "SloppyFocus", s.length())) {
1263 resource
.sloppy_focus
= true;
1264 resource
.auto_raise
= false;
1267 resource
.sloppy_focus
= true;
1268 resource
.auto_raise
= false;
1271 rname
.seekp(0); rclass
.seekp(0);
1272 rname
<< rscreen
.str() << "windowZones";
1273 rclass
<< rscreen
.str() << "WindowZones";
1274 if (config
.getValue(rname
.str(), rclass
.str(), l
))
1275 resource
.zones
= (l
== 1 || l
== 2 || l
== 4) ? l
: 1;
1279 rname
.seekp(0); rclass
.seekp(0);
1280 rname
<< rscreen
.str() << "windowPlacement";
1281 rclass
<< rscreen
.str() << "WindowPlacement";
1282 if (config
.getValue(rname
.str(), rclass
.str(), s
)) {
1283 if (0 == strncasecmp(s
.c_str(), "RowSmartPlacement", s
.length()))
1284 resource
.placement_policy
= RowSmartPlacement
;
1285 else if (0 == strncasecmp(s
.c_str(), "ColSmartPlacement", s
.length()))
1286 resource
.placement_policy
= ColSmartPlacement
;
1287 else if (0 == strncasecmp(s
.c_str(), "BestFitPlacement", s
.length()))
1288 resource
.placement_policy
= BestFitPlacement
;
1289 else if (0 == strncasecmp(s
.c_str(), "UnderMousePlacement", s
.length()))
1290 resource
.placement_policy
= UnderMousePlacement
;
1291 else if (0 == strncasecmp(s
.c_str(), "ClickMousePlacement", s
.length()))
1292 resource
.placement_policy
= ClickMousePlacement
;
1293 else //if (0 == strncasecmp(s.c_str(), "CascadePlacement", s.length()))
1294 resource
.placement_policy
= CascadePlacement
;
1296 resource
.placement_policy
= CascadePlacement
;
1298 #ifdef HAVE_STRFTIME
1299 rname
.seekp(0); rclass
.seekp(0);
1300 rname
<< rscreen
.str() << "strftimeFormat";
1301 rclass
<< rscreen
.str() << "StrftimeFormat";
1303 if (resource
.strftime_format
!= NULL
)
1304 delete [] resource
.strftime_format
;
1306 if (config
.getValue(rname
.str(), rclass
.str(), s
))
1307 resource
.strftime_format
= bstrdup(s
.c_str());
1309 resource
.strftime_format
= bstrdup("%I:%M %p");
1310 #else // !HAVE_STRFTIME
1311 rname
.seekp(0); rclass
.seekp(0);
1312 rname
<< rscreen
.str() << "dateFormat";
1313 rclass
<< rscreen
.str() << "DateFormat";
1314 if (config
.getValue(rname
.str(), rclass
.str(), s
)) {
1315 if (strncasecmp(s
.c_str(), "European", s
.length()))
1316 resource
.date_format
= B_EuropeanDate
;
1317 else //if (strncasecmp(s.c_str(), "American", s.length()))
1318 resource
.date_format
= B_AmericanDate
;
1320 resource
.date_format
= B_AmericanDate
;
1322 rname
.seekp(0); rclass
.seekp(0);
1323 rname
<< rscreen
.str() << "clockFormat";
1324 rclass
<< rscreen
.str() << "ClockFormat";
1325 if (config
.getValue(rname
.str(), rclass
.str(), l
)) {
1327 resource
.clock24hour
= true;
1328 else if (clock
== 12)
1329 resource
.clock24hour
= false;
1331 resource
.clock24hour
= false;
1332 #endif // HAVE_STRFTIME
1334 rname
.seekp(0); rclass
.seekp(0);
1335 rname
<< rscreen
.str() << "edgeSnapThreshold";
1336 rclass
<< rscreen
.str() << "EdgeSnapThreshold";
1337 if (config
.getValue(rname
.str(), rclass
.str(), l
))
1338 resource
.edge_snap_threshold
= l
;
1340 resource
.edge_snap_threshold
= 4;
1342 rname
.seekp(0); rclass
.seekp(0);
1343 rname
<< rscreen
.str() << "imageDither";
1344 rclass
<< rscreen
.str() << "ImageDither";
1345 if (config
.getValue(rname
.str(), rclass
.str(), b
))
1346 resource
.image_dither
= b
;
1348 resource
.image_dither
= true;
1350 rname
.seekp(0); rclass
.seekp(0);
1351 rname
<< rscreen
.str() << "rootCommand";
1352 rclass
<< rscreen
.str() << "RootCommand";
1354 if (resource
.root_command
!= NULL
)
1355 delete [] resource
.root_command
;
1357 if (config
.getValue(rname
.str(), rclass
.str(), s
))
1358 resource
.root_command
= bstrdup(s
.c_str());
1360 resource
.root_command
= NULL
;
1362 rname
.seekp(0); rclass
.seekp(0);
1363 rname
<< rscreen
.str() << "opaqueMove";
1364 rclass
<< rscreen
.str() << "OpaqueMove";
1365 if (config
.getValue(rname
.str(), rclass
.str(), b
))
1366 resource
.opaque_move
= b
;
1368 resource
.opaque_move
= false;
1371 void BScreen::reconfigure(void) {
1380 unsigned long gc_value_mask
= GCForeground
;
1381 if (! i18n
->multibyte()) gc_value_mask
|= GCFont
;
1383 gcv
.foreground
= WhitePixel(getBaseDisplay().getXDisplay(),
1385 gcv
.function
= GXinvert
;
1386 gcv
.subwindow_mode
= IncludeInferiors
;
1387 XChangeGC(getBaseDisplay().getXDisplay(), opGC
,
1388 GCForeground
| GCFunction
| GCSubwindowMode
, &gcv
);
1390 gcv
.foreground
= resource
.wstyle
.l_text_focus
.getPixel();
1391 if (resource
.wstyle
.font
)
1392 gcv
.font
= resource
.wstyle
.font
->fid
;
1393 XChangeGC(getBaseDisplay().getXDisplay(), resource
.wstyle
.l_text_focus_gc
,
1394 gc_value_mask
, &gcv
);
1396 gcv
.foreground
= resource
.wstyle
.l_text_unfocus
.getPixel();
1397 XChangeGC(getBaseDisplay().getXDisplay(), resource
.wstyle
.l_text_unfocus_gc
,
1398 gc_value_mask
, &gcv
);
1400 gcv
.foreground
= resource
.wstyle
.b_pic_focus
.getPixel();
1401 XChangeGC(getBaseDisplay().getXDisplay(), resource
.wstyle
.b_pic_focus_gc
,
1402 GCForeground
, &gcv
);
1404 gcv
.foreground
= resource
.wstyle
.b_pic_unfocus
.getPixel();
1405 XChangeGC(getBaseDisplay().getXDisplay(), resource
.wstyle
.b_pic_unfocus_gc
,
1406 GCForeground
, &gcv
);
1408 gcv
.foreground
= resource
.mstyle
.t_text
.getPixel();
1409 if (resource
.mstyle
.t_font
)
1410 gcv
.font
= resource
.mstyle
.t_font
->fid
;
1411 XChangeGC(getBaseDisplay().getXDisplay(), resource
.mstyle
.t_text_gc
,
1412 gc_value_mask
, &gcv
);
1414 gcv
.foreground
= resource
.mstyle
.f_text
.getPixel();
1415 if (resource
.mstyle
.f_font
)
1416 gcv
.font
= resource
.mstyle
.f_font
->fid
;
1417 XChangeGC(getBaseDisplay().getXDisplay(), resource
.mstyle
.f_text_gc
,
1418 gc_value_mask
, &gcv
);
1420 gcv
.foreground
= resource
.mstyle
.h_text
.getPixel();
1421 XChangeGC(getBaseDisplay().getXDisplay(), resource
.mstyle
.h_text_gc
,
1422 gc_value_mask
, &gcv
);
1424 gcv
.foreground
= resource
.mstyle
.d_text
.getPixel();
1425 XChangeGC(getBaseDisplay().getXDisplay(), resource
.mstyle
.d_text_gc
,
1426 gc_value_mask
, &gcv
);
1428 gcv
.foreground
= resource
.mstyle
.hilite
.getColor()->getPixel();
1429 XChangeGC(getBaseDisplay().getXDisplay(), resource
.mstyle
.hilite_gc
,
1430 gc_value_mask
, &gcv
);
1432 gcv
.foreground
= resource
.tstyle
.l_text
.getPixel();
1433 if (resource
.tstyle
.font
)
1434 gcv
.font
= resource
.tstyle
.font
->fid
;
1435 XChangeGC(getBaseDisplay().getXDisplay(), resource
.tstyle
.l_text_gc
,
1436 gc_value_mask
, &gcv
);
1438 gcv
.foreground
= resource
.tstyle
.w_text
.getPixel();
1439 XChangeGC(getBaseDisplay().getXDisplay(), resource
.tstyle
.w_text_gc
,
1440 gc_value_mask
, &gcv
);
1442 gcv
.foreground
= resource
.tstyle
.c_text
.getPixel();
1443 XChangeGC(getBaseDisplay().getXDisplay(), resource
.tstyle
.c_text_gc
,
1444 gc_value_mask
, &gcv
);
1446 gcv
.foreground
= resource
.tstyle
.b_pic
.getPixel();
1447 XChangeGC(getBaseDisplay().getXDisplay(), resource
.tstyle
.b_pic_gc
,
1448 gc_value_mask
, &gcv
);
1450 const char *s
= i18n
->getMessage(ScreenSet
, ScreenPositionLength
,
1451 "0: 0000 x 0: 0000");
1454 if (i18n
->multibyte()) {
1455 XRectangle ink
, logical
;
1456 XmbTextExtents(resource
.wstyle
.fontset
, s
, l
, &ink
, &logical
);
1457 geom_w
= logical
.width
;
1459 geom_h
= resource
.wstyle
.fontset_extents
->max_ink_extent
.height
;
1461 geom_w
= XTextWidth(resource
.wstyle
.font
, s
, l
);
1463 geom_h
= resource
.wstyle
.font
->ascent
+
1464 resource
.wstyle
.font
->descent
;
1467 geom_w
+= (resource
.bevel_width
* 2);
1468 geom_h
+= (resource
.bevel_width
* 2);
1470 Pixmap tmp
= geom_pixmap
;
1471 if (resource
.wstyle
.l_focus
.getTexture() & BImage_ParentRelative
) {
1472 if (resource
.wstyle
.t_focus
.getTexture() ==
1473 (BImage_Flat
| BImage_Solid
)) {
1475 XSetWindowBackground(getBaseDisplay().getXDisplay(), geom_window
,
1476 resource
.wstyle
.t_focus
.getColor()->getPixel());
1478 geom_pixmap
= image_control
->renderImage(geom_w
, geom_h
,
1479 &resource
.wstyle
.t_focus
);
1480 XSetWindowBackgroundPixmap(getBaseDisplay().getXDisplay(),
1481 geom_window
, geom_pixmap
);
1484 if (resource
.wstyle
.l_focus
.getTexture() ==
1485 (BImage_Flat
| BImage_Solid
)) {
1487 XSetWindowBackground(getBaseDisplay().getXDisplay(), geom_window
,
1488 resource
.wstyle
.l_focus
.getColor()->getPixel());
1490 geom_pixmap
= image_control
->renderImage(geom_w
, geom_h
,
1491 &resource
.wstyle
.l_focus
);
1492 XSetWindowBackgroundPixmap(getBaseDisplay().getXDisplay(),
1493 geom_window
, geom_pixmap
);
1496 if (tmp
) image_control
->removeImage(tmp
);
1498 XSetWindowBorderWidth(getBaseDisplay().getXDisplay(), geom_window
,
1499 resource
.border_width
);
1500 XSetWindowBorder(getBaseDisplay().getXDisplay(), geom_window
,
1501 resource
.border_color
.getPixel());
1503 workspacemenu
->reconfigure();
1504 iconmenu
->reconfigure();
1507 int remember_sub
= rootmenu
->getCurrentSubmenu();
1510 rootmenu
->reconfigure();
1511 rootmenu
->drawSubmenu(remember_sub
);
1514 configmenu
->reconfigure();
1516 toolbar
->reconfigure();
1519 slit
->reconfigure();
1522 LinkedListIterator
<Workspace
> wit(workspacesList
);
1523 for (Workspace
*w
= wit
.current(); w
; wit
++, w
= wit
.current())
1526 LinkedListIterator
<OpenboxWindow
> iit(iconList
);
1527 for (OpenboxWindow
*bw
= iit
.current(); bw
; iit
++, bw
= iit
.current())
1528 if (bw
->validateClient())
1531 image_control
->timeout();
1535 void BScreen::rereadMenu(void) {
1539 rootmenu
->reconfigure();
1543 void BScreen::removeWorkspaceNames(void) {
1544 while (workspaceNames
->count())
1545 delete [] workspaceNames
->remove(0);
1549 void BScreen::LoadStyle(void) {
1550 Resource
&conf
= resource
.styleconfig
;
1552 const char *sfile
= openbox
.getStyleFilename();
1553 bool loaded
= false;
1554 if (sfile
!= NULL
) {
1555 conf
.setFile(sfile
);
1556 loaded
= conf
.load();
1559 conf
.setFile(DEFAULTSTYLE
);
1561 fprintf(stderr
, i18n
->getMessage(ScreenSet
, ScreenDefaultStyleLoadFail
,
1562 "BScreen::LoadStyle(): couldn't load "
1563 "default style.\n"));
1571 // load fonts/fontsets
1573 if (i18n
->multibyte()) {
1574 readDatabaseFontSet("window.font", "Window.Font",
1575 &resource
.wstyle
.fontset
);
1576 readDatabaseFontSet("toolbar.font", "Toolbar.Font",
1577 &resource
.tstyle
.fontset
);
1578 readDatabaseFontSet("menu.title.font", "Menu.Title.Font",
1579 &resource
.mstyle
.t_fontset
);
1580 readDatabaseFontSet("menu.frame.font", "Menu.Frame.Font",
1581 &resource
.mstyle
.f_fontset
);
1583 resource
.mstyle
.t_fontset_extents
=
1584 XExtentsOfFontSet(resource
.mstyle
.t_fontset
);
1585 resource
.mstyle
.f_fontset_extents
=
1586 XExtentsOfFontSet(resource
.mstyle
.f_fontset
);
1587 resource
.tstyle
.fontset_extents
=
1588 XExtentsOfFontSet(resource
.tstyle
.fontset
);
1589 resource
.wstyle
.fontset_extents
=
1590 XExtentsOfFontSet(resource
.wstyle
.fontset
);
1592 readDatabaseFont("window.font", "Window.Font",
1593 &resource
.wstyle
.font
);
1594 readDatabaseFont("menu.title.font", "Menu.Title.Font",
1595 &resource
.mstyle
.t_font
);
1596 readDatabaseFont("menu.frame.font", "Menu.Frame.Font",
1597 &resource
.mstyle
.f_font
);
1598 readDatabaseFont("toolbar.font", "Toolbar.Font",
1599 &resource
.tstyle
.font
);
1602 // load window config
1603 readDatabaseTexture("window.title.focus", "Window.Title.Focus",
1604 &resource
.wstyle
.t_focus
,
1605 WhitePixel(getBaseDisplay().getXDisplay(),
1606 getScreenNumber()));
1607 readDatabaseTexture("window.title.unfocus", "Window.Title.Unfocus",
1608 &resource
.wstyle
.t_unfocus
,
1609 BlackPixel(getBaseDisplay().getXDisplay(),
1610 getScreenNumber()));
1611 readDatabaseTexture("window.label.focus", "Window.Label.Focus",
1612 &resource
.wstyle
.l_focus
,
1613 WhitePixel(getBaseDisplay().getXDisplay(),
1614 getScreenNumber()));
1615 readDatabaseTexture("window.label.unfocus", "Window.Label.Unfocus",
1616 &resource
.wstyle
.l_unfocus
,
1617 BlackPixel(getBaseDisplay().getXDisplay(),
1618 getScreenNumber()));
1619 readDatabaseTexture("window.handle.focus", "Window.Handle.Focus",
1620 &resource
.wstyle
.h_focus
,
1621 WhitePixel(getBaseDisplay().getXDisplay(),
1622 getScreenNumber()));
1623 readDatabaseTexture("window.handle.unfocus", "Window.Handle.Unfocus",
1624 &resource
.wstyle
.h_unfocus
,
1625 BlackPixel(getBaseDisplay().getXDisplay(),
1626 getScreenNumber()));
1627 readDatabaseTexture("window.grip.focus", "Window.Grip.Focus",
1628 &resource
.wstyle
.g_focus
,
1629 WhitePixel(getBaseDisplay().getXDisplay(),
1630 getScreenNumber()));
1631 readDatabaseTexture("window.grip.unfocus", "Window.Grip.Unfocus",
1632 &resource
.wstyle
.g_unfocus
,
1633 BlackPixel(getBaseDisplay().getXDisplay(),
1634 getScreenNumber()));
1635 readDatabaseTexture("window.button.focus", "Window.Button.Focus",
1636 &resource
.wstyle
.b_focus
,
1637 WhitePixel(getBaseDisplay().getXDisplay(),
1638 getScreenNumber()));
1639 readDatabaseTexture("window.button.unfocus", "Window.Button.Unfocus",
1640 &resource
.wstyle
.b_unfocus
,
1641 BlackPixel(getBaseDisplay().getXDisplay(),
1642 getScreenNumber()));
1643 readDatabaseTexture("window.button.pressed", "Window.Button.Pressed",
1644 &resource
.wstyle
.b_pressed
,
1645 BlackPixel(getBaseDisplay().getXDisplay(),
1646 getScreenNumber()));
1647 readDatabaseColor("window.frame.focusColor",
1648 "Window.Frame.FocusColor",
1649 &resource
.wstyle
.f_focus
,
1650 WhitePixel(getBaseDisplay().getXDisplay(),
1651 getScreenNumber()));
1652 readDatabaseColor("window.frame.unfocusColor",
1653 "Window.Frame.UnfocusColor",
1654 &resource
.wstyle
.f_unfocus
,
1655 BlackPixel(getBaseDisplay().getXDisplay(),
1656 getScreenNumber()));
1657 readDatabaseColor("window.label.focus.textColor",
1658 "Window.Label.Focus.TextColor",
1659 &resource
.wstyle
.l_text_focus
,
1660 BlackPixel(getBaseDisplay().getXDisplay(),
1661 getScreenNumber()));
1662 readDatabaseColor("window.label.unfocus.textColor",
1663 "Window.Label.Unfocus.TextColor",
1664 &resource
.wstyle
.l_text_unfocus
,
1665 WhitePixel(getBaseDisplay().getXDisplay(),
1666 getScreenNumber()));
1667 readDatabaseColor("window.button.focus.picColor",
1668 "Window.Button.Focus.PicColor",
1669 &resource
.wstyle
.b_pic_focus
,
1670 BlackPixel(getBaseDisplay().getXDisplay(),
1671 getScreenNumber()));
1672 readDatabaseColor("window.button.unfocus.picColor",
1673 "Window.Button.Unfocus.PicColor",
1674 &resource
.wstyle
.b_pic_unfocus
,
1675 WhitePixel(getBaseDisplay().getXDisplay(),
1676 getScreenNumber()));
1678 if (conf
.getValue("window.justify", "Window.Justify", s
)) {
1679 if (0 == strncasecmp(s
.c_str(), "right", s
.length()))
1680 resource
.wstyle
.justify
= BScreen::RightJustify
;
1681 else if (0 == strncasecmp(s
.c_str(), "center", s
.length()))
1682 resource
.wstyle
.justify
= BScreen::CenterJustify
;
1684 resource
.wstyle
.justify
= BScreen::LeftJustify
;
1686 resource
.wstyle
.justify
= BScreen::LeftJustify
;
1688 // load toolbar config
1689 readDatabaseTexture("toolbar", "Toolbar",
1690 &resource
.tstyle
.toolbar
,
1691 BlackPixel(getBaseDisplay().getXDisplay(),
1692 getScreenNumber()));
1693 readDatabaseTexture("toolbar.label", "Toolbar.Label",
1694 &resource
.tstyle
.label
,
1695 BlackPixel(getBaseDisplay().getXDisplay(),
1696 getScreenNumber()));
1697 readDatabaseTexture("toolbar.windowLabel", "Toolbar.WindowLabel",
1698 &resource
.tstyle
.window
,
1699 BlackPixel(getBaseDisplay().getXDisplay(),
1700 getScreenNumber()));
1701 readDatabaseTexture("toolbar.button", "Toolbar.Button",
1702 &resource
.tstyle
.button
,
1703 WhitePixel(getBaseDisplay().getXDisplay(),
1704 getScreenNumber()));
1705 readDatabaseTexture("toolbar.button.pressed", "Toolbar.Button.Pressed",
1706 &resource
.tstyle
.pressed
,
1707 BlackPixel(getBaseDisplay().getXDisplay(),
1708 getScreenNumber()));
1709 readDatabaseTexture("toolbar.clock", "Toolbar.Clock",
1710 &resource
.tstyle
.clock
,
1711 BlackPixel(getBaseDisplay().getXDisplay(),
1712 getScreenNumber()));
1713 readDatabaseColor("toolbar.label.textColor", "Toolbar.Label.TextColor",
1714 &resource
.tstyle
.l_text
,
1715 WhitePixel(getBaseDisplay().getXDisplay(),
1716 getScreenNumber()));
1717 readDatabaseColor("toolbar.windowLabel.textColor",
1718 "Toolbar.WindowLabel.TextColor",
1719 &resource
.tstyle
.w_text
,
1720 WhitePixel(getBaseDisplay().getXDisplay(),
1721 getScreenNumber()));
1722 readDatabaseColor("toolbar.clock.textColor", "Toolbar.Clock.TextColor",
1723 &resource
.tstyle
.c_text
,
1724 WhitePixel(getBaseDisplay().getXDisplay(),
1725 getScreenNumber()));
1726 readDatabaseColor("toolbar.button.picColor", "Toolbar.Button.PicColor",
1727 &resource
.tstyle
.b_pic
,
1728 BlackPixel(getBaseDisplay().getXDisplay(),
1729 getScreenNumber()));
1731 if (conf
.getValue("toolbar.justify", "Toolbar.Justify", s
)) {
1732 if (0 == strncasecmp(s
.c_str(), "right", s
.length()))
1733 resource
.tstyle
.justify
= BScreen::RightJustify
;
1734 else if (0 == strncasecmp(s
.c_str(), "center", s
.length()))
1735 resource
.tstyle
.justify
= BScreen::CenterJustify
;
1737 resource
.tstyle
.justify
= BScreen::LeftJustify
;
1739 resource
.tstyle
.justify
= BScreen::LeftJustify
;
1742 readDatabaseTexture("menu.title", "Menu.Title",
1743 &resource
.mstyle
.title
,
1744 WhitePixel(getBaseDisplay().getXDisplay(),
1745 getScreenNumber()));
1746 readDatabaseTexture("menu.frame", "Menu.Frame",
1747 &resource
.mstyle
.frame
,
1748 BlackPixel(getBaseDisplay().getXDisplay(),
1749 getScreenNumber()));
1750 readDatabaseTexture("menu.hilite", "Menu.Hilite",
1751 &resource
.mstyle
.hilite
,
1752 WhitePixel(getBaseDisplay().getXDisplay(),
1753 getScreenNumber()));
1754 readDatabaseColor("menu.title.textColor", "Menu.Title.TextColor",
1755 &resource
.mstyle
.t_text
,
1756 BlackPixel(getBaseDisplay().getXDisplay(),
1757 getScreenNumber()));
1758 readDatabaseColor("menu.frame.textColor", "Menu.Frame.TextColor",
1759 &resource
.mstyle
.f_text
,
1760 WhitePixel(getBaseDisplay().getXDisplay(),
1761 getScreenNumber()));
1762 readDatabaseColor("menu.frame.disableColor", "Menu.Frame.DisableColor",
1763 &resource
.mstyle
.d_text
,
1764 BlackPixel(getBaseDisplay().getXDisplay(),
1765 getScreenNumber()));
1766 readDatabaseColor("menu.hilite.textColor", "Menu.Hilite.TextColor",
1767 &resource
.mstyle
.h_text
,
1768 BlackPixel(getBaseDisplay().getXDisplay(),
1769 getScreenNumber()));
1771 if (conf
.getValue("menu.title.justify", "Menu.Title.Justify", s
)) {
1772 if (0 == strncasecmp(s
.c_str(), "right", s
.length()))
1773 resource
.mstyle
.t_justify
= BScreen::RightJustify
;
1774 else if (0 == strncasecmp(s
.c_str(), "center", s
.length()))
1775 resource
.mstyle
.t_justify
= BScreen::CenterJustify
;
1777 resource
.mstyle
.t_justify
= BScreen::LeftJustify
;
1779 resource
.mstyle
.t_justify
= BScreen::LeftJustify
;
1781 if (conf
.getValue("menu.frame.justify", "Menu.Frame.Justify", s
)) {
1782 if (0 == strncasecmp(s
.c_str(), "right", s
.length()))
1783 resource
.mstyle
.f_justify
= BScreen::RightJustify
;
1784 else if (0 == strncasecmp(s
.c_str(), "center", s
.length()))
1785 resource
.mstyle
.f_justify
= BScreen::CenterJustify
;
1787 resource
.mstyle
.f_justify
= BScreen::LeftJustify
;
1789 resource
.mstyle
.f_justify
= BScreen::LeftJustify
;
1791 if (conf
.getValue("menu.bullet", "Menu.Bullet", s
)) {
1792 if (0 == strncasecmp(s
.c_str(), "empty", s
.length()))
1793 resource
.mstyle
.bullet
= Basemenu::Empty
;
1794 else if (0 == strncasecmp(s
.c_str(), "square", s
.length()))
1795 resource
.mstyle
.bullet
= Basemenu::Square
;
1796 else if (0 == strncasecmp(s
.c_str(), "diamond", s
.length()))
1797 resource
.mstyle
.bullet
= Basemenu::Diamond
;
1799 resource
.mstyle
.bullet
= Basemenu::Triangle
;
1801 resource
.mstyle
.bullet
= Basemenu::Triangle
;
1803 if (conf
.getValue("menu.bullet.position", "Menu.Bullet.Position", s
)) {
1804 if (0 == strncasecmp(s
.c_str(), "right", s
.length()))
1805 resource
.mstyle
.bullet_pos
= Basemenu::Right
;
1807 resource
.mstyle
.bullet_pos
= Basemenu::Left
;
1809 resource
.mstyle
.bullet_pos
= Basemenu::Left
;
1811 readDatabaseColor("borderColor", "BorderColor", &resource
.border_color
,
1812 BlackPixel(getBaseDisplay().getXDisplay(),
1813 getScreenNumber()));
1815 // load bevel, border and handle widths
1816 if (conf
.getValue("handleWidth", "HandleWidth", l
)) {
1817 if (l
<= size().w() / 2 && l
!= 0)
1818 resource
.handle_width
= l
;
1820 resource
.handle_width
= 6;
1822 resource
.handle_width
= 6;
1824 if (conf
.getValue("borderWidth", "BorderWidth", l
))
1825 resource
.border_width
= l
;
1827 resource
.border_width
= 1;
1829 if (conf
.getValue("bevelWidth", "BevelWidth", l
)) {
1830 if (l
<= size().w() / 2 && l
!= 0)
1831 resource
.bevel_width
= l
;
1833 resource
.bevel_width
= 3;
1835 resource
.bevel_width
= 3;
1837 if (conf
.getValue("frameWidth", "FrameWidth", l
)) {
1838 if (l
<= size().w() / 2)
1839 resource
.frame_width
= l
;
1841 resource
.frame_width
= resource
.bevel_width
;
1843 resource
.frame_width
= resource
.bevel_width
;
1845 const char *cmd
= resource
.root_command
;
1846 if (cmd
!= NULL
|| conf
.getValue("rootCommand", "RootCommand", s
)) {
1848 cmd
= s
.c_str(); // not specified by the screen, so use the one from the
1851 char displaystring
[MAXPATHLEN
];
1852 sprintf(displaystring
, "DISPLAY=%s",
1853 DisplayString(getBaseDisplay().getXDisplay()));
1854 sprintf(displaystring
+ strlen(displaystring
) - 1, "%d",
1857 bexec(cmd
, displaystring
);
1859 spawnlp(P_NOWAIT
, "cmd.exe", "cmd.exe", "/c", cmd
, NULL
);
1865 void BScreen::addIcon(OpenboxWindow
*w
) {
1868 w
->setWorkspace(-1);
1869 w
->setWindowNumber(iconList
->count());
1871 iconList
->insert(w
);
1873 iconmenu
->insert((const char **) w
->getIconTitle());
1878 void BScreen::removeIcon(OpenboxWindow
*w
) {
1881 iconList
->remove(w
->getWindowNumber());
1883 iconmenu
->remove(w
->getWindowNumber());
1886 LinkedListIterator
<OpenboxWindow
> it(iconList
);
1887 OpenboxWindow
*bw
= it
.current();
1888 for (int i
= 0; bw
; it
++, bw
= it
.current())
1889 bw
->setWindowNumber(i
++);
1893 OpenboxWindow
*BScreen::getIcon(int index
) {
1894 if (index
>= 0 && index
< iconList
->count())
1895 return iconList
->find(index
);
1901 int BScreen::addWorkspace(void) {
1902 Workspace
*wkspc
= new Workspace(*this, workspacesList
->count());
1903 workspacesList
->insert(wkspc
);
1904 saveWorkspaceNames();
1906 workspacemenu
->insert(wkspc
->getName(), wkspc
->getMenu(),
1907 wkspc
->getWorkspaceID() + 2);
1908 workspacemenu
->update();
1910 toolbar
->reconfigure();
1912 updateNetizenWorkspaceCount();
1914 return workspacesList
->count();
1918 int BScreen::removeLastWorkspace(void) {
1919 if (workspacesList
->count() == 1)
1922 Workspace
*wkspc
= workspacesList
->last();
1924 if (current_workspace
->getWorkspaceID() == wkspc
->getWorkspaceID())
1925 changeWorkspaceID(current_workspace
->getWorkspaceID() - 1);
1929 workspacemenu
->remove(wkspc
->getWorkspaceID() + 2);
1930 workspacemenu
->update();
1932 workspacesList
->remove(wkspc
);
1935 toolbar
->reconfigure();
1937 updateNetizenWorkspaceCount();
1939 return workspacesList
->count();
1943 void BScreen::changeWorkspaceID(int id
) {
1944 if (! current_workspace
) return;
1946 if (id
!= current_workspace
->getWorkspaceID()) {
1947 current_workspace
->hideAll();
1949 workspacemenu
->setItemSelected(current_workspace
->getWorkspaceID() + 2,
1952 if (openbox
.getFocusedWindow() &&
1953 openbox
.getFocusedWindow()->getScreen() == this &&
1954 (! openbox
.getFocusedWindow()->isStuck())) {
1955 current_workspace
->setLastFocusedWindow(openbox
.getFocusedWindow());
1956 openbox
.setFocusedWindow(NULL
);
1959 current_workspace
= getWorkspace(id
);
1961 workspacemenu
->setItemSelected(current_workspace
->getWorkspaceID() + 2,
1963 toolbar
->redrawWorkspaceLabel(True
);
1965 current_workspace
->showAll();
1967 if (resource
.focus_last
&& current_workspace
->getLastFocusedWindow()) {
1968 XSync(openbox
.getXDisplay(), False
);
1969 current_workspace
->getLastFocusedWindow()->setInputFocus();
1973 updateNetizenCurrentWorkspace();
1977 void BScreen::addNetizen(Netizen
*n
) {
1978 netizenList
->insert(n
);
1980 n
->sendWorkspaceCount();
1981 n
->sendCurrentWorkspace();
1983 LinkedListIterator
<Workspace
> it(workspacesList
);
1984 for (Workspace
*w
= it
.current(); w
; it
++, w
= it
.current()) {
1985 for (int i
= 0; i
< w
->getCount(); i
++)
1986 n
->sendWindowAdd(w
->getWindow(i
)->getClientWindow(),
1987 w
->getWorkspaceID());
1990 Window f
= ((openbox
.getFocusedWindow()) ?
1991 openbox
.getFocusedWindow()->getClientWindow() : None
);
1992 n
->sendWindowFocus(f
);
1996 void BScreen::removeNetizen(Window w
) {
1997 LinkedListIterator
<Netizen
> it(netizenList
);
2000 for (Netizen
*n
= it
.current(); n
; it
++, i
++, n
= it
.current())
2001 if (n
->getWindowID() == w
) {
2002 Netizen
*tmp
= netizenList
->remove(i
);
2010 void BScreen::updateNetizenCurrentWorkspace(void) {
2011 LinkedListIterator
<Netizen
> it(netizenList
);
2012 for (Netizen
*n
= it
.current(); n
; it
++, n
= it
.current())
2013 n
->sendCurrentWorkspace();
2017 void BScreen::updateNetizenWorkspaceCount(void) {
2018 LinkedListIterator
<Netizen
> it(netizenList
);
2019 for (Netizen
*n
= it
.current(); n
; it
++, n
= it
.current())
2020 n
->sendWorkspaceCount();
2024 void BScreen::updateNetizenWindowFocus(void) {
2025 Window f
= ((openbox
.getFocusedWindow()) ?
2026 openbox
.getFocusedWindow()->getClientWindow() : None
);
2027 LinkedListIterator
<Netizen
> it(netizenList
);
2028 for (Netizen
*n
= it
.current(); n
; it
++, n
= it
.current())
2029 n
->sendWindowFocus(f
);
2033 void BScreen::updateNetizenWindowAdd(Window w
, unsigned long p
) {
2034 LinkedListIterator
<Netizen
> it(netizenList
);
2035 for (Netizen
*n
= it
.current(); n
; it
++, n
= it
.current())
2036 n
->sendWindowAdd(w
, p
);
2040 void BScreen::updateNetizenWindowDel(Window w
) {
2041 LinkedListIterator
<Netizen
> it(netizenList
);
2042 for (Netizen
*n
= it
.current(); n
; it
++, n
= it
.current())
2043 n
->sendWindowDel(w
);
2047 void BScreen::updateNetizenWindowRaise(Window w
) {
2048 LinkedListIterator
<Netizen
> it(netizenList
);
2049 for (Netizen
*n
= it
.current(); n
; it
++, n
= it
.current())
2050 n
->sendWindowRaise(w
);
2054 void BScreen::updateNetizenWindowLower(Window w
) {
2055 LinkedListIterator
<Netizen
> it(netizenList
);
2056 for (Netizen
*n
= it
.current(); n
; it
++, n
= it
.current())
2057 n
->sendWindowLower(w
);
2061 void BScreen::updateNetizenConfigNotify(XEvent
*e
) {
2062 LinkedListIterator
<Netizen
> it(netizenList
);
2063 for (Netizen
*n
= it
.current(); n
; it
++, n
= it
.current())
2064 n
->sendConfigNotify(e
);
2068 void BScreen::raiseWindows(Window
*workspace_stack
, int num
) {
2069 Window
*session_stack
= new
2070 Window
[(num
+ workspacesList
->count() + rootmenuList
->count() + 13)];
2073 XRaiseWindow(getBaseDisplay().getXDisplay(), iconmenu
->getWindowID());
2074 *(session_stack
+ i
++) = iconmenu
->getWindowID();
2076 LinkedListIterator
<Workspace
> wit(workspacesList
);
2077 for (Workspace
*tmp
= wit
.current(); tmp
; wit
++, tmp
= wit
.current())
2078 *(session_stack
+ i
++) = tmp
->getMenu()->getWindowID();
2080 *(session_stack
+ i
++) = workspacemenu
->getWindowID();
2082 *(session_stack
+ i
++) = configmenu
->getFocusmenu()->getWindowID();
2083 *(session_stack
+ i
++) = configmenu
->getPlacementmenu()->getWindowID();
2084 *(session_stack
+ i
++) = configmenu
->getWindowID();
2087 *(session_stack
+ i
++) = slit
->getMenu()->getDirectionmenu()->getWindowID();
2088 *(session_stack
+ i
++) = slit
->getMenu()->getPlacementmenu()->getWindowID();
2089 *(session_stack
+ i
++) = slit
->getMenu()->getWindowID();
2092 *(session_stack
+ i
++) =
2093 toolbar
->getMenu()->getPlacementmenu()->getWindowID();
2094 *(session_stack
+ i
++) = toolbar
->getMenu()->getWindowID();
2096 LinkedListIterator
<Rootmenu
> rit(rootmenuList
);
2097 for (Rootmenu
*tmp
= rit
.current(); tmp
; rit
++, tmp
= rit
.current())
2098 *(session_stack
+ i
++) = tmp
->getWindowID();
2099 *(session_stack
+ i
++) = rootmenu
->getWindowID();
2101 if (toolbar
->onTop())
2102 *(session_stack
+ i
++) = toolbar
->getWindowID();
2106 *(session_stack
+ i
++) = slit
->getWindowID();
2110 *(session_stack
+ i
++) = *(workspace_stack
+ k
);
2112 XRestackWindows(getBaseDisplay().getXDisplay(), session_stack
, i
);
2114 delete [] session_stack
;
2118 void BScreen::addWorkspaceName(const char *name
) {
2119 workspaceNames
->insert(bstrdup(name
));
2122 char* BScreen::getNameOfWorkspace(int id
) {
2125 if (id
>= 0 && id
< workspaceNames
->count()) {
2126 char *wkspc_name
= workspaceNames
->find(id
);
2135 void BScreen::reassociateWindow(OpenboxWindow
*w
, int wkspc_id
, Bool ignore_sticky
) {
2139 wkspc_id
= current_workspace
->getWorkspaceID();
2141 if (w
->getWorkspaceNumber() == wkspc_id
)
2144 if (w
->isIconic()) {
2146 getWorkspace(wkspc_id
)->addWindow(w
);
2147 } else if (ignore_sticky
|| ! w
->isStuck()) {
2148 getWorkspace(w
->getWorkspaceNumber())->removeWindow(w
);
2149 getWorkspace(wkspc_id
)->addWindow(w
);
2154 void BScreen::nextFocus(void) {
2155 Bool have_focused
= False
;
2156 int focused_window_number
= -1;
2157 OpenboxWindow
*next
;
2159 if (openbox
.getFocusedWindow()) {
2160 if (openbox
.getFocusedWindow()->getScreen()->getScreenNumber() ==
2161 getScreenNumber()) {
2162 have_focused
= True
;
2163 focused_window_number
= openbox
.getFocusedWindow()->getWindowNumber();
2167 if ((getCurrentWorkspace()->getCount() > 1) && have_focused
) {
2168 int next_window_number
= focused_window_number
;
2170 if ((++next_window_number
) >= getCurrentWorkspace()->getCount())
2171 next_window_number
= 0;
2173 next
= getCurrentWorkspace()->getWindow(next_window_number
);
2174 } while ((! next
->setInputFocus()) && (next_window_number
!=
2175 focused_window_number
));
2177 if (next_window_number
!= focused_window_number
)
2178 getCurrentWorkspace()->raiseWindow(next
);
2179 } else if (getCurrentWorkspace()->getCount() >= 1) {
2180 next
= current_workspace
->getWindow(0);
2182 current_workspace
->raiseWindow(next
);
2183 next
->setInputFocus();
2188 void BScreen::prevFocus(void) {
2189 Bool have_focused
= False
;
2190 int focused_window_number
= -1;
2191 OpenboxWindow
*prev
;
2193 if (openbox
.getFocusedWindow()) {
2194 if (openbox
.getFocusedWindow()->getScreen()->getScreenNumber() ==
2195 getScreenNumber()) {
2196 have_focused
= True
;
2197 focused_window_number
= openbox
.getFocusedWindow()->getWindowNumber();
2201 if ((getCurrentWorkspace()->getCount() > 1) && have_focused
) {
2202 int prev_window_number
= focused_window_number
;
2204 if ((--prev_window_number
) < 0)
2205 prev_window_number
= getCurrentWorkspace()->getCount() - 1;
2207 prev
= getCurrentWorkspace()->getWindow(prev_window_number
);
2208 } while ((! prev
->setInputFocus()) && (prev_window_number
!=
2209 focused_window_number
));
2211 if (prev_window_number
!= focused_window_number
)
2212 getCurrentWorkspace()->raiseWindow(prev
);
2213 } else if (getCurrentWorkspace()->getCount() >= 1) {
2214 prev
= current_workspace
->getWindow(0);
2216 current_workspace
->raiseWindow(prev
);
2217 prev
->setInputFocus();
2222 void BScreen::raiseFocus(void) {
2223 Bool have_focused
= False
;
2224 int focused_window_number
= -1;
2226 if (openbox
.getFocusedWindow()) {
2227 if (openbox
.getFocusedWindow()->getScreen()->getScreenNumber() ==
2228 getScreenNumber()) {
2229 have_focused
= True
;
2230 focused_window_number
= openbox
.getFocusedWindow()->getWindowNumber();
2234 if ((getCurrentWorkspace()->getCount() > 1) && have_focused
)
2235 getWorkspace(openbox
.getFocusedWindow()->getWorkspaceNumber())->
2236 raiseWindow(openbox
.getFocusedWindow());
2240 void BScreen::InitMenu(void) {
2242 while (rootmenuList
->count())
2243 rootmenuList
->remove(0);
2245 while (rootmenu
->getCount())
2246 rootmenu
->remove(0);
2248 rootmenu
= new Rootmenu(*this);
2250 Bool defaultMenu
= True
;
2252 if (openbox
.getMenuFilename()) {
2253 FILE *menu_file
= fopen(openbox
.getMenuFilename(), "r");
2256 perror(openbox
.getMenuFilename());
2258 if (feof(menu_file
)) {
2259 fprintf(stderr
, i18n
->getMessage(ScreenSet
, ScreenEmptyMenuFile
,
2260 "%s: Empty menu file"),
2261 openbox
.getMenuFilename());
2263 char line
[1024], label
[1024];
2264 memset(line
, 0, 1024);
2265 memset(label
, 0, 1024);
2267 while (fgets(line
, 1024, menu_file
) && ! feof(menu_file
)) {
2268 if (line
[0] != '#') {
2269 int i
, key
= 0, index
= -1, len
= strlen(line
);
2272 for (i
= 0; i
< len
; i
++) {
2273 if (line
[i
] == '[') index
= 0;
2274 else if (line
[i
] == ']') break;
2275 else if (line
[i
] != ' ')
2277 key
+= tolower(line
[i
]);
2282 for (i
= index
; i
< len
; i
++) {
2283 if (line
[i
] == '(') index
= 0;
2284 else if (line
[i
] == ')') break;
2285 else if (index
++ >= 0) {
2286 if (line
[i
] == '\\' && i
< len
- 1) i
++;
2287 label
[index
- 1] = line
[i
];
2291 if (index
== -1) index
= 0;
2292 label
[index
] = '\0';
2294 rootmenu
->setLabel(label
);
2295 defaultMenu
= parseMenuFile(menu_file
, rootmenu
);
2306 rootmenu
->setInternalMenu();
2307 rootmenu
->insert(i18n
->getMessage(ScreenSet
, Screenxterm
, "xterm"),
2309 i18n
->getMessage(ScreenSet
, Screenxterm
, "xterm"));
2310 rootmenu
->insert(i18n
->getMessage(ScreenSet
, ScreenRestart
, "Restart"),
2312 rootmenu
->insert(i18n
->getMessage(ScreenSet
, ScreenExit
, "Exit"),
2315 openbox
.setMenuFilename(openbox
.getMenuFilename());
2320 Bool
BScreen::parseMenuFile(FILE *file
, Rootmenu
*menu
) {
2321 char line
[1024], label
[1024], command
[1024];
2323 while (! feof(file
)) {
2324 memset(line
, 0, 1024);
2325 memset(label
, 0, 1024);
2326 memset(command
, 0, 1024);
2328 if (fgets(line
, 1024, file
)) {
2329 if (line
[0] != '#') {
2330 register int i
, key
= 0, parse
= 0, index
= -1,
2331 line_length
= strlen(line
),
2332 label_length
= 0, command_length
= 0;
2334 // determine the keyword
2336 for (i
= 0; i
< line_length
; i
++) {
2337 if (line
[i
] == '[') parse
= 1;
2338 else if (line
[i
] == ']') break;
2339 else if (line
[i
] != ' ')
2341 key
+= tolower(line
[i
]);
2344 // get the label enclosed in ()'s
2347 for (i
= 0; i
< line_length
; i
++) {
2348 if (line
[i
] == '(') {
2351 } else if (line
[i
] == ')') break;
2352 else if (index
++ >= 0) {
2353 if (line
[i
] == '\\' && i
< line_length
- 1) i
++;
2354 label
[index
- 1] = line
[i
];
2359 label
[index
] = '\0';
2360 label_length
= index
;
2366 // get the command enclosed in {}'s
2369 for (i
= 0; i
< line_length
; i
++) {
2370 if (line
[i
] == '{') {
2373 } else if (line
[i
] == '}') break;
2374 else if (index
++ >= 0) {
2375 if (line
[i
] == '\\' && i
< line_length
- 1) i
++;
2376 command
[index
- 1] = line
[i
];
2381 command
[index
] = '\0';
2382 command_length
= index
;
2390 return ((menu
->getCount() == 0) ? True
: False
);
2395 menu
->insert(label
);
2400 if ((! *label
) && (! *command
)) {
2401 fprintf(stderr
, i18n
->getMessage(ScreenSet
, ScreenEXECError
,
2402 "BScreen::parseMenuFile: [exec] error, "
2403 "no menu label and/or command defined\n"));
2407 menu
->insert(label
, BScreen::Execute
, command
);
2413 fprintf(stderr
, i18n
->getMessage(ScreenSet
, ScreenEXITError
,
2414 "BScreen::parseMenuFile: [exit] error, "
2415 "no menu label defined\n"));
2419 menu
->insert(label
, BScreen::Exit
);
2425 if ((! *label
) || (! *command
)) {
2426 fprintf(stderr
, i18n
->getMessage(ScreenSet
, ScreenSTYLEError
,
2427 "BScreen::parseMenuFile: [style] error, "
2428 "no menu label and/or filename defined\n"));
2432 char style
[MAXPATHLEN
];
2434 // perform shell style ~ home directory expansion
2436 int homedir_len
= 0;
2437 if (*command
== '~' && *(command
+ 1) == '/') {
2438 homedir
= getenv("HOME");
2439 homedir_len
= strlen(homedir
);
2442 if (homedir
&& homedir_len
!= 0) {
2443 strncpy(style
, homedir
, homedir_len
);
2445 strncpy(style
+ homedir_len
, command
+ 1,
2446 command_length
- 1);
2447 *(style
+ command_length
+ homedir_len
- 1) = '\0';
2449 strncpy(style
, command
, command_length
);
2450 *(style
+ command_length
) = '\0';
2453 menu
->insert(label
, BScreen::SetStyle
, style
);
2460 fprintf(stderr
, i18n
->getMessage(ScreenSet
, ScreenCONFIGError
,
2461 "BScreen::parseMenufile: [config] error, "
2462 "no label defined"));
2466 menu
->insert(label
, configmenu
);
2470 case 740: // include
2473 fprintf(stderr
, i18n
->getMessage(ScreenSet
, ScreenINCLUDEError
,
2474 "BScreen::parseMenuFile: [include] error, "
2475 "no filename defined\n"));
2479 char newfile
[MAXPATHLEN
];
2481 // perform shell style ~ home directory expansion
2483 int homedir_len
= 0;
2484 if (*label
== '~' && *(label
+ 1) == '/') {
2485 homedir
= getenv("HOME");
2486 homedir_len
= strlen(homedir
);
2489 if (homedir
&& homedir_len
!= 0) {
2490 strncpy(newfile
, homedir
, homedir_len
);
2492 strncpy(newfile
+ homedir_len
, label
+ 1,
2494 *(newfile
+ label_length
+ homedir_len
- 1) = '\0';
2496 strncpy(newfile
, label
, label_length
);
2497 *(newfile
+ label_length
) = '\0';
2501 FILE *submenufile
= fopen(newfile
, "r");
2505 if (fstat(fileno(submenufile
), &buf
) ||
2506 (! S_ISREG(buf
.st_mode
))) {
2508 i18n
->getMessage(ScreenSet
, ScreenINCLUDEErrorReg
,
2509 "BScreen::parseMenuFile: [include] error: "
2510 "'%s' is not a regular file\n"), newfile
);
2514 if (! feof(submenufile
)) {
2515 if (! parseMenuFile(submenufile
, menu
))
2516 openbox
.setMenuFilename(newfile
);
2518 fclose(submenufile
);
2527 case 767: // submenu
2530 fprintf(stderr
, i18n
->getMessage(ScreenSet
, ScreenSUBMENUError
,
2531 "BScreen::parseMenuFile: [submenu] error, "
2532 "no menu label defined\n"));
2536 Rootmenu
*submenu
= new Rootmenu(*this);
2539 submenu
->setLabel(command
);
2541 submenu
->setLabel(label
);
2543 parseMenuFile(file
, submenu
);
2545 menu
->insert(label
, submenu
);
2546 rootmenuList
->insert(submenu
);
2551 case 773: // restart
2554 fprintf(stderr
, i18n
->getMessage(ScreenSet
, ScreenRESTARTError
,
2555 "BScreen::parseMenuFile: [restart] error, "
2556 "no menu label defined\n"));
2561 menu
->insert(label
, BScreen::RestartOther
, command
);
2563 menu
->insert(label
, BScreen::Restart
);
2568 case 845: // reconfig
2571 fprintf(stderr
, i18n
->getMessage(ScreenSet
, ScreenRECONFIGError
,
2572 "BScreen::parseMenuFile: [reconfig] error, "
2573 "no menu label defined\n"));
2577 menu
->insert(label
, BScreen::Reconfigure
);
2582 case 995: // stylesdir
2583 case 1113: // stylesmenu
2585 Bool newmenu
= ((key
== 1113) ? True
: False
);
2587 if ((! *label
) || ((! *command
) && newmenu
)) {
2589 i18n
->getMessage(ScreenSet
, ScreenSTYLESDIRError
,
2590 "BScreen::parseMenuFile: [stylesdir/stylesmenu]"
2591 " error, no directory defined\n"));
2595 char stylesdir
[MAXPATHLEN
];
2597 char *directory
= ((newmenu
) ? command
: label
);
2598 int directory_length
= ((newmenu
) ? command_length
: label_length
);
2600 // perform shell style ~ home directory expansion
2602 int homedir_len
= 0;
2604 if (*directory
== '~' && *(directory
+ 1) == '/') {
2605 homedir
= getenv("HOME");
2606 homedir_len
= strlen(homedir
);
2609 if (homedir
&& homedir_len
!= 0) {
2610 strncpy(stylesdir
, homedir
, homedir_len
);
2612 strncpy(stylesdir
+ homedir_len
, directory
+ 1,
2613 directory_length
- 1);
2614 *(stylesdir
+ directory_length
+ homedir_len
- 1) = '\0';
2616 strncpy(stylesdir
, directory
, directory_length
);
2617 *(stylesdir
+ directory_length
) = '\0';
2620 struct stat statbuf
;
2622 if (! stat(stylesdir
, &statbuf
)) {
2623 if (S_ISDIR(statbuf
.st_mode
)) {
2624 Rootmenu
*stylesmenu
;
2627 stylesmenu
= new Rootmenu(*this);
2631 DIR *d
= opendir(stylesdir
);
2635 // get the total number of directory entries
2636 while ((p
= readdir(d
))) entries
++;
2639 char **ls
= new char* [entries
];
2641 while ((p
= readdir(d
)))
2642 ls
[index
++] = bstrdup(p
->d_name
);
2646 std::sort(ls
, ls
+ entries
, dcmp());
2648 int n
, slen
= strlen(stylesdir
);
2649 for (n
= 0; n
< entries
; n
++) {
2650 if (ls
[n
][strlen(ls
[n
])-1] != '~') {
2651 int nlen
= strlen(ls
[n
]);
2652 char style
[MAXPATHLEN
+ 1];
2654 strncpy(style
, stylesdir
, slen
);
2655 *(style
+ slen
) = '/';
2656 strncpy(style
+ slen
+ 1, ls
[n
], nlen
+ 1);
2658 if ((! stat(style
, &statbuf
)) && S_ISREG(statbuf
.st_mode
))
2659 stylesmenu
->insert(ls
[n
], BScreen::SetStyle
, style
);
2667 stylesmenu
->update();
2670 stylesmenu
->setLabel(label
);
2671 menu
->insert(label
, stylesmenu
);
2672 rootmenuList
->insert(stylesmenu
);
2675 openbox
.setMenuFilename(stylesdir
);
2677 fprintf(stderr
, i18n
->getMessage(ScreenSet
,
2678 ScreenSTYLESDIRErrorNotDir
,
2679 "BScreen::parseMenuFile:"
2680 " [stylesdir/stylesmenu] error, %s is not a"
2681 " directory\n"), stylesdir
);
2685 i18n
->getMessage(ScreenSet
, ScreenSTYLESDIRErrorNoExist
,
2686 "BScreen::parseMenuFile: [stylesdir/stylesmenu]"
2687 " error, %s does not exist\n"), stylesdir
);
2693 case 1090: // workspaces
2697 i18n
->getMessage(ScreenSet
, ScreenWORKSPACESError
,
2698 "BScreen:parseMenuFile: [workspaces] error, "
2699 "no menu label defined\n"));
2703 menu
->insert(label
, workspacemenu
);
2712 return ((menu
->getCount() == 0) ? True
: False
);
2716 void BScreen::shutdown(void) {
2719 XSelectInput(getBaseDisplay().getXDisplay(), getRootWindow(), NoEventMask
);
2720 XSync(getBaseDisplay().getXDisplay(), False
);
2722 LinkedListIterator
<Workspace
> it(workspacesList
);
2723 for (Workspace
*w
= it
.current(); w
; it
++, w
= it
.current())
2726 while (iconList
->count()) {
2727 iconList
->first()->restore();
2728 delete iconList
->first();
2739 void BScreen::showPosition(int x
, int y
) {
2740 if (! geom_visible
) {
2741 XMoveResizeWindow(getBaseDisplay().getXDisplay(), geom_window
,
2742 (size().w() - geom_w
) / 2,
2743 (size().h() - geom_h
) / 2, geom_w
, geom_h
);
2744 XMapWindow(getBaseDisplay().getXDisplay(), geom_window
);
2745 XRaiseWindow(getBaseDisplay().getXDisplay(), geom_window
);
2747 geom_visible
= True
;
2752 sprintf(label
, i18n
->getMessage(ScreenSet
, ScreenPositionFormat
,
2753 "X: %4d x Y: %4d"), x
, y
);
2755 XClearWindow(getBaseDisplay().getXDisplay(), geom_window
);
2757 if (i18n
->multibyte()) {
2758 XmbDrawString(getBaseDisplay().getXDisplay(), geom_window
,
2759 resource
.wstyle
.fontset
, resource
.wstyle
.l_text_focus_gc
,
2760 resource
.bevel_width
, resource
.bevel_width
-
2761 resource
.wstyle
.fontset_extents
->max_ink_extent
.y
,
2762 label
, strlen(label
));
2764 XDrawString(getBaseDisplay().getXDisplay(), geom_window
,
2765 resource
.wstyle
.l_text_focus_gc
,
2766 resource
.bevel_width
,
2767 resource
.wstyle
.font
->ascent
+
2768 resource
.bevel_width
, label
, strlen(label
));
2773 void BScreen::showGeometry(unsigned int gx
, unsigned int gy
) {
2774 if (! geom_visible
) {
2775 XMoveResizeWindow(getBaseDisplay().getXDisplay(), geom_window
,
2776 (size().w() - geom_w
) / 2,
2777 (size().h() - geom_h
) / 2, geom_w
, geom_h
);
2778 XMapWindow(getBaseDisplay().getXDisplay(), geom_window
);
2779 XRaiseWindow(getBaseDisplay().getXDisplay(), geom_window
);
2781 geom_visible
= True
;
2786 sprintf(label
, i18n
->getMessage(ScreenSet
, ScreenGeometryFormat
,
2787 "W: %4d x H: %4d"), gx
, gy
);
2789 XClearWindow(getBaseDisplay().getXDisplay(), geom_window
);
2791 if (i18n
->multibyte()) {
2792 XmbDrawString(getBaseDisplay().getXDisplay(), geom_window
,
2793 resource
.wstyle
.fontset
, resource
.wstyle
.l_text_focus_gc
,
2794 resource
.bevel_width
, resource
.bevel_width
-
2795 resource
.wstyle
.fontset_extents
->max_ink_extent
.y
,
2796 label
, strlen(label
));
2798 XDrawString(getBaseDisplay().getXDisplay(), geom_window
,
2799 resource
.wstyle
.l_text_focus_gc
,
2800 resource
.bevel_width
,
2801 resource
.wstyle
.font
->ascent
+
2802 resource
.bevel_width
, label
, strlen(label
));
2806 void BScreen::hideGeometry(void) {
2808 XUnmapWindow(getBaseDisplay().getXDisplay(), geom_window
);
2809 geom_visible
= False
;