1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 // Screen.cc for Blackbox - an X11 Window manager
3 // Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
4 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
6 // Permission is hereby granted, free of charge, to any person obtaining a
7 // copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following conditions:
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 // DEALINGS IN THE SOFTWARE.
25 #include "../config.h"
26 #endif // HAVE_CONFIG_H
29 #include <X11/Xatom.h>
30 #include <X11/keysym.h>
33 # include <X11/Xlib.h>
34 # include <X11/extensions/Xinerama.h>
39 #endif // HAVE_STDLIB_H
43 #endif // HAVE_STRING_H
47 #endif // HAVE_CTYPE_H
50 # include <sys/types.h>
52 #endif // HAVE_UNISTD_H
56 #endif // HAVE_DIRENT_H
60 #endif // HAVE_LOCALE_H
62 #ifdef HAVE_SYS_STAT_H
63 # include <sys/stat.h>
64 #endif // HAVE_SYS_STAT_H
68 #endif // HAVE_STDARG_H
79 #include "blackbox.hh"
80 #include "Clientmenu.hh"
83 #include "Iconmenu.hh"
87 #include "Rootmenu.hh"
91 #include "Workspace.hh"
92 #include "Workspacemenu.hh"
96 #ifndef FONT_ELEMENT_SIZE
97 #define FONT_ELEMENT_SIZE 50
98 #endif // FONT_ELEMENT_SIZE
101 static bool running
= True
;
103 static int anotherWMRunning(Display
*display
, XErrorEvent
*) {
104 fprintf(stderr
, i18n(ScreenSet
, ScreenAnotherWMRunning
,
105 "BScreen::BScreen: an error occured while querying the X server.\n"
106 " another window manager already running on display %s.\n"),
107 DisplayString(display
));
115 BScreen::BScreen(Blackbox
*bb
, unsigned int scrn
) : ScreenInfo(bb
, scrn
) {
117 screenstr
= "session.screen" + itostring(scrn
) + '.';
118 config
= blackbox
->getConfig();
119 xatom
= blackbox
->getXAtom();
121 event_mask
= ColormapChangeMask
| EnterWindowMask
| PropertyChangeMask
|
122 SubstructureRedirectMask
| ButtonPressMask
| ButtonReleaseMask
;
124 XErrorHandler old
= XSetErrorHandler((XErrorHandler
) anotherWMRunning
);
125 XSelectInput(getBaseDisplay()->getXDisplay(), getRootWindow(), event_mask
);
126 XSync(getBaseDisplay()->getXDisplay(), False
);
127 XSetErrorHandler((XErrorHandler
) old
);
130 if (! managed
) return;
132 fprintf(stderr
, i18n(ScreenSet
, ScreenManagingScreen
,
133 "BScreen::BScreen: managing screen %d "
134 "using visual 0x%lx, depth %d\n"),
135 getScreenNumber(), XVisualIDFromVisual(getVisual()),
140 resource
.mstyle
.t_font
= resource
.mstyle
.f_font
= resource
.tstyle
.font
=
141 resource
.wstyle
.font
= (BFont
*) 0;
145 xatom
->setSupported(this); // set-up netwm support
147 xatom
->setValue(getRootWindow(), XAtom::blackbox_pid
, XAtom::cardinal
,
148 (unsigned long) getpid());
149 #endif // HAVE_GETPID
150 unsigned long geometry
[] = { getWidth(),
152 xatom
->setValue(getRootWindow(), XAtom::net_desktop_geometry
,
153 XAtom::cardinal
, geometry
, 2);
154 unsigned long viewport
[] = {0,0};
155 xatom
->setValue(getRootWindow(), XAtom::net_desktop_viewport
,
156 XAtom::cardinal
, viewport
, 2);
159 XDefineCursor(blackbox
->getXDisplay(), getRootWindow(),
160 blackbox
->getSessionCursor());
162 updateAvailableArea();
165 new BImageControl(blackbox
, this, True
, blackbox
->getColorsPerChannel(),
166 blackbox
->getCacheLife(), blackbox
->getCacheMax());
167 image_control
->installRootColormap();
168 root_colormap_installed
= True
;
174 gcv
.foreground
= WhitePixel(blackbox
->getXDisplay(), getScreenNumber())
175 ^ BlackPixel(blackbox
->getXDisplay(), getScreenNumber());
176 gcv
.function
= GXxor
;
177 gcv
.subwindow_mode
= IncludeInferiors
;
178 opGC
= XCreateGC(blackbox
->getXDisplay(), getRootWindow(),
179 GCForeground
| GCFunction
| GCSubwindowMode
, &gcv
);
181 const char *s
= i18n(ScreenSet
, ScreenPositionLength
,
182 "0: 0000 x 0: 0000");
183 geom_w
= resource
.wstyle
.font
->measureString(s
) + resource
.bevel_width
* 2;
184 geom_h
= resource
.wstyle
.font
->height() + resource
.bevel_width
* 2;
186 XSetWindowAttributes attrib
;
187 unsigned long mask
= CWBorderPixel
| CWColormap
| CWSaveUnder
;
188 attrib
.border_pixel
= getBorderColor()->pixel();
189 attrib
.colormap
= getColormap();
190 attrib
.save_under
= True
;
192 geom_window
= XCreateWindow(blackbox
->getXDisplay(), getRootWindow(),
193 0, 0, geom_w
, geom_h
, resource
.border_width
,
194 getDepth(), InputOutput
, getVisual(),
196 geom_visible
= False
;
198 BTexture
* texture
= &(resource
.wstyle
.l_focus
);
199 geom_pixmap
= texture
->render(geom_w
, geom_h
, geom_pixmap
);
200 if (geom_pixmap
== ParentRelative
) {
201 texture
= &(resource
.wstyle
.t_focus
);
202 geom_pixmap
= texture
->render(geom_w
, geom_h
, geom_pixmap
);
205 XSetWindowBackground(blackbox
->getXDisplay(), geom_window
,
206 texture
->color().pixel());
208 XSetWindowBackgroundPixmap(blackbox
->getXDisplay(),
209 geom_window
, geom_pixmap
);
211 workspacemenu
= new Workspacemenu(this);
212 iconmenu
= new Iconmenu(this);
213 configmenu
= new Configmenu(this);
215 if (resource
.workspaces
!= 0) {
216 for (unsigned int i
= 0; i
< resource
.workspaces
; ++i
) {
217 Workspace
*wkspc
= new Workspace(this, workspacesList
.size());
218 workspacesList
.push_back(wkspc
);
219 workspacemenu
->insertWorkspace(wkspc
);
220 workspacemenu
->update();
224 Workspace
*wkspc
= new Workspace(this, workspacesList
.size());
225 workspacesList
.push_back(wkspc
);
226 workspacemenu
->insertWorkspace(wkspc
);
227 workspacemenu
->update();
229 saveWorkspaceNames();
231 updateNetizenWorkspaceCount();
233 workspacemenu
->insert(i18n(IconSet
, IconIcons
, "Icons"), iconmenu
);
234 workspacemenu
->update();
236 current_workspace
= workspacesList
.front();
238 xatom
->setValue(getRootWindow(), XAtom::net_current_desktop
,
239 XAtom::cardinal
, 0); //first workspace
241 workspacemenu
->setItemSelected(2, True
);
243 toolbar
= new Toolbar(this);
245 slit
= new Slit(this);
249 raiseWindows(0, 0); // this also initializes the empty stacking list
252 updateClientList(); // initialize the client lists, which will be empty
253 updateAvailableArea();
255 changeWorkspaceID(0);
257 unsigned int i
, j
, nchild
;
258 Window r
, p
, *children
;
259 XQueryTree(blackbox
->getXDisplay(), getRootWindow(), &r
, &p
,
262 // preen the window list of all icon windows... for better dockapp support
263 for (i
= 0; i
< nchild
; i
++) {
264 if (children
[i
] == None
) continue;
266 XWMHints
*wmhints
= XGetWMHints(blackbox
->getXDisplay(),
270 if ((wmhints
->flags
& IconWindowHint
) &&
271 (wmhints
->icon_window
!= children
[i
])) {
272 for (j
= 0; j
< nchild
; j
++) {
273 if (children
[j
] == wmhints
->icon_window
) {
284 // manage shown windows
285 for (i
= 0; i
< nchild
; ++i
) {
286 if (children
[i
] == None
|| (! blackbox
->validateWindow(children
[i
])))
289 XWindowAttributes attrib
;
290 if (XGetWindowAttributes(blackbox
->getXDisplay(), children
[i
], &attrib
)) {
291 if (attrib
.override_redirect
) continue;
293 if (attrib
.map_state
!= IsUnmapped
) {
294 manageWindow(children
[i
]);
301 // call this again just in case a window we found updates the Strut list
302 updateAvailableArea();
306 BScreen::~BScreen(void) {
307 if (! managed
) return;
309 if (geom_pixmap
!= None
)
310 image_control
->removeImage(geom_pixmap
);
312 if (geom_window
!= None
)
313 XDestroyWindow(blackbox
->getXDisplay(), geom_window
);
315 std::for_each(workspacesList
.begin(), workspacesList
.end(),
318 std::for_each(iconList
.begin(), iconList
.end(), PointerAssassin());
320 std::for_each(netizenList
.begin(), netizenList
.end(), PointerAssassin());
322 while (! systrayWindowList
.empty())
323 removeSystrayWindow(systrayWindowList
[0]);
326 delete workspacemenu
;
331 delete image_control
;
333 if (resource
.wstyle
.font
)
334 delete resource
.wstyle
.font
;
335 if (resource
.mstyle
.t_font
)
336 delete resource
.mstyle
.t_font
;
337 if (resource
.mstyle
.f_font
)
338 delete resource
.mstyle
.f_font
;
339 if (resource
.tstyle
.font
)
340 delete resource
.tstyle
.font
;
342 XFreeGC(blackbox
->getXDisplay(), opGC
);
346 void BScreen::saveSloppyFocus(bool s
) {
347 resource
.sloppy_focus
= s
;
350 if (resource
.sloppy_focus
) {
351 fmodel
= "SloppyFocus";
352 if (resource
.auto_raise
) fmodel
+= " AutoRaise";
353 if (resource
.click_raise
) fmodel
+= " ClickRaise";
355 fmodel
= "ClickToFocus";
357 config
->setValue(screenstr
+ "focusModel", fmodel
);
361 void BScreen::saveAutoRaise(bool a
) {
362 resource
.auto_raise
= a
;
363 saveSloppyFocus(resource
.sloppy_focus
);
367 void BScreen::saveClickRaise(bool c
) {
368 resource
.click_raise
= c
;
369 saveSloppyFocus(resource
.sloppy_focus
);
373 void BScreen::saveImageDither(bool d
) {
374 image_control
->setDither(d
);
375 config
->setValue(screenstr
+ "imageDither", doImageDither());
379 void BScreen::saveOpaqueMove(bool o
) {
380 resource
.opaque_move
= o
;
381 config
->setValue(screenstr
+ "opaqueMove", resource
.opaque_move
);
385 void BScreen::saveFullMax(bool f
) {
386 resource
.full_max
= f
;
387 config
->setValue(screenstr
+ "fullMaximization", resource
.full_max
);
391 void BScreen::saveFocusNew(bool f
) {
392 resource
.focus_new
= f
;
393 config
->setValue(screenstr
+ "focusNewWindows", resource
.focus_new
);
397 void BScreen::saveFocusLast(bool f
) {
398 resource
.focus_last
= f
;
399 config
->setValue(screenstr
+ "focusLastWindow", resource
.focus_last
);
403 void BScreen::saveAAFonts(bool f
) {
404 resource
.aa_fonts
= f
;
406 config
->setValue(screenstr
+ "antialiasFonts", resource
.aa_fonts
);
410 void BScreen::saveHideToolbar(bool h
) {
411 resource
.hide_toolbar
= h
;
412 if (resource
.hide_toolbar
)
413 toolbar
->unmapToolbar();
415 toolbar
->mapToolbar();
416 config
->setValue(screenstr
+ "hideToolbar", resource
.hide_toolbar
);
420 void BScreen::saveWindowToWindowSnap(bool s
) {
421 resource
.window_to_window_snap
= s
;
422 config
->setValue(screenstr
+ "windowToWindowSnap",
423 resource
.window_to_window_snap
);
427 void BScreen::saveResizeZones(unsigned int z
) {
428 resource
.resize_zones
= z
;
429 config
->setValue(screenstr
+ "resizeZones", resource
.resize_zones
);
433 void BScreen::saveWindowCornerSnap(bool s
) {
434 resource
.window_corner_snap
= s
;
435 config
->setValue(screenstr
+ "windowCornerSnap",
436 resource
.window_corner_snap
);
440 void BScreen::saveWorkspaces(unsigned int w
) {
441 resource
.workspaces
= w
;
442 config
->setValue(screenstr
+ "workspaces", resource
.workspaces
);
446 void BScreen::savePlacementPolicy(int p
) {
447 resource
.placement_policy
= p
;
448 const char *placement
;
449 switch (resource
.placement_policy
) {
450 case CascadePlacement
: placement
= "CascadePlacement"; break;
451 case UnderMousePlacement
: placement
= "UnderMousePlacement"; break;
452 case ClickMousePlacement
: placement
= "ClickMousePlacement"; break;
453 case ColSmartPlacement
: placement
= "ColSmartPlacement"; break;
454 case RowSmartPlacement
: default: placement
= "RowSmartPlacement"; break;
456 config
->setValue(screenstr
+ "windowPlacement", placement
);
460 void BScreen::saveEdgeSnapThreshold(int t
) {
461 resource
.edge_snap_threshold
= t
;
462 config
->setValue(screenstr
+ "edgeSnapThreshold",
463 resource
.edge_snap_threshold
);
467 void BScreen::saveRowPlacementDirection(int d
) {
468 resource
.row_direction
= d
;
469 config
->setValue(screenstr
+ "rowPlacementDirection",
470 resource
.row_direction
== LeftRight
?
471 "LeftToRight" : "RightToLeft");
475 void BScreen::saveColPlacementDirection(int d
) {
476 resource
.col_direction
= d
;
477 config
->setValue(screenstr
+ "colPlacementDirection",
478 resource
.col_direction
== TopBottom
?
479 "TopToBottom" : "BottomToTop");
484 void BScreen::saveStrftimeFormat(const std::string
& format
) {
485 resource
.strftime_format
= format
;
486 config
->setValue(screenstr
+ "strftimeFormat", resource
.strftime_format
);
489 #else // !HAVE_STRFTIME
491 void BScreen::saveDateFormat(int f
) {
492 resource
.date_format
= f
;
493 config
->setValue(screenstr
+ "dateFormat",
494 resource
.date_format
== B_EuropeanDate
?
495 "European" : "American");
499 void BScreen::saveClock24Hour(bool c
) {
500 resource
.clock24hour
= c
;
501 config
->setValue(screenstr
+ "clockFormat", resource
.clock24hour
? 24 : 12);
503 #endif // HAVE_STRFTIME
506 void BScreen::saveWorkspaceNames() {
509 for (unsigned int i
= 0; i
< workspacesList
.size(); ++i
) {
510 names
+= workspacesList
[i
]->getName();
511 if (i
< workspacesList
.size() - 1)
515 config
->setValue(screenstr
+ "workspaceNames", names
);
519 void BScreen::savePlaceIgnoreShaded(bool i
) {
520 resource
.ignore_shaded
= i
;
521 config
->setValue(screenstr
+ "placementIgnoreShaded",
522 resource
.ignore_shaded
);
526 void BScreen::savePlaceIgnoreMaximized(bool i
) {
527 resource
.ignore_maximized
= i
;
528 config
->setValue(screenstr
+ "placementIgnoreMaximized",
529 resource
.ignore_maximized
);
533 void BScreen::saveAllowScrollLock(bool a
) {
534 resource
.allow_scroll_lock
= a
;
535 config
->setValue(screenstr
+ "disableBindingsWithScrollLock",
536 resource
.allow_scroll_lock
);
540 void BScreen::save_rc(void) {
541 saveSloppyFocus(resource
.sloppy_focus
);
542 saveAutoRaise(resource
.auto_raise
);
543 saveImageDither(doImageDither());
544 saveAAFonts(resource
.aa_fonts
);
545 saveResizeZones(resource
.resize_zones
);
546 saveOpaqueMove(resource
.opaque_move
);
547 saveFullMax(resource
.full_max
);
548 saveFocusNew(resource
.focus_new
);
549 saveFocusLast(resource
.focus_last
);
550 saveHideToolbar(resource
.hide_toolbar
);
551 saveWindowToWindowSnap(resource
.window_to_window_snap
);
552 saveWindowCornerSnap(resource
.window_corner_snap
);
553 saveWorkspaces(resource
.workspaces
);
554 savePlacementPolicy(resource
.placement_policy
);
555 saveEdgeSnapThreshold(resource
.edge_snap_threshold
);
556 saveRowPlacementDirection(resource
.row_direction
);
557 saveColPlacementDirection(resource
.col_direction
);
559 saveStrftimeFormat(resource
.strftime_format
);
560 #else // !HAVE_STRFTIME
561 saveDateFormat(resource
.date_format
);
562 savwClock24Hour(resource
.clock24hour
);
563 #endif // HAVE_STRFTIME
564 savePlaceIgnoreShaded(resource
.ignore_shaded
);
565 savePlaceIgnoreMaximized(resource
.ignore_maximized
);
566 saveAllowScrollLock(resource
.allow_scroll_lock
);
573 void BScreen::load_rc(void) {
577 if (! config
->getValue(screenstr
+ "fullMaximization", resource
.full_max
))
578 resource
.full_max
= false;
580 if (! config
->getValue(screenstr
+ "focusNewWindows", resource
.focus_new
))
581 resource
.focus_new
= false;
583 if (! config
->getValue(screenstr
+ "focusLastWindow", resource
.focus_last
))
584 resource
.focus_last
= false;
586 if (! config
->getValue(screenstr
+ "workspaces", resource
.workspaces
))
587 resource
.workspaces
= 1;
589 if (! config
->getValue(screenstr
+ "opaqueMove", resource
.opaque_move
))
590 resource
.opaque_move
= false;
592 if (! config
->getValue(screenstr
+ "antialiasFonts", resource
.aa_fonts
))
593 resource
.aa_fonts
= true;
595 if (! config
->getValue(screenstr
+ "resizeZones", resource
.resize_zones
) ||
596 (resource
.resize_zones
!= 1 && resource
.resize_zones
!= 2 &&
597 resource
.resize_zones
!= 4))
598 resource
.resize_zones
= 4;
600 if (! config
->getValue(screenstr
+ "hideToolbar", resource
.hide_toolbar
))
601 resource
.hide_toolbar
= false;
603 if (! config
->getValue(screenstr
+ "windowToWindowSnap",
604 resource
.window_to_window_snap
))
605 resource
.window_to_window_snap
= true;
607 if (! config
->getValue(screenstr
+ "windowCornerSnap",
608 resource
.window_corner_snap
))
609 resource
.window_corner_snap
= true;
611 if (! config
->getValue(screenstr
+ "imageDither", b
))
613 image_control
->setDither(b
);
615 if (! config
->getValue(screenstr
+ "edgeSnapThreshold",
616 resource
.edge_snap_threshold
))
617 resource
.edge_snap_threshold
= 4;
619 if (config
->getValue(screenstr
+ "rowPlacementDirection", s
) &&
621 resource
.row_direction
= RightLeft
;
623 resource
.row_direction
= LeftRight
;
625 if (config
->getValue(screenstr
+ "colPlacementDirection", s
) &&
627 resource
.col_direction
= BottomTop
;
629 resource
.col_direction
= TopBottom
;
631 if (config
->getValue(screenstr
+ "workspaceNames", s
)) {
632 XAtom::StringVect workspaceNames
;
634 string::const_iterator it
= s
.begin(), end
= s
.end();
636 string::const_iterator tmp
= it
; // current string.begin()
637 it
= std::find(tmp
, end
, ','); // look for comma between tmp and end
638 workspaceNames
.push_back(string(tmp
, it
)); // s[tmp:it]
644 xatom
->setValue(getRootWindow(), XAtom::net_desktop_names
, XAtom::utf8
,
648 resource
.sloppy_focus
= true;
649 resource
.auto_raise
= false;
650 resource
.click_raise
= false;
651 if (config
->getValue(screenstr
+ "focusModel", s
)) {
652 if (s
.find("ClickToFocus") != string::npos
) {
653 resource
.sloppy_focus
= false;
656 if (s
.find("AutoRaise") != string::npos
)
657 resource
.auto_raise
= true;
658 if (s
.find("ClickRaise") != string::npos
)
659 resource
.click_raise
= true;
663 if (config
->getValue(screenstr
+ "windowPlacement", s
)) {
664 if (s
== "CascadePlacement")
665 resource
.placement_policy
= CascadePlacement
;
666 else if (s
== "UnderMousePlacement")
667 resource
.placement_policy
= UnderMousePlacement
;
668 else if (s
== "ClickMousePlacement")
669 resource
.placement_policy
= ClickMousePlacement
;
670 else if (s
== "ColSmartPlacement")
671 resource
.placement_policy
= ColSmartPlacement
;
672 else //if (s == "RowSmartPlacement")
673 resource
.placement_policy
= RowSmartPlacement
;
675 resource
.placement_policy
= RowSmartPlacement
;
678 if (! config
->getValue(screenstr
+ "strftimeFormat",
679 resource
.strftime_format
))
680 resource
.strftime_format
= "%I:%M %p";
681 #else // !HAVE_STRFTIME
684 if (config
->getValue(screenstr
+ "dateFormat", s
) && s
== "European")
685 resource
.date_format
= B_EuropeanDate
;
687 resource
.date_format
= B_AmericanDate
;
689 if (! config
->getValue(screenstr
+ "clockFormat", l
))
691 resource
.clock24hour
= l
== 24;
692 #endif // HAVE_STRFTIME
694 if (! config
->getValue(screenstr
+ "placementIgnoreShaded",
695 resource
.ignore_shaded
))
696 resource
.ignore_shaded
= true;
698 if (! config
->getValue(screenstr
+ "placementIgnoreMaximized",
699 resource
.ignore_maximized
))
700 resource
.ignore_maximized
= true;
702 if (! config
->getValue(screenstr
+ "disableBindingsWithScrollLock",
703 resource
.allow_scroll_lock
))
704 resource
.allow_scroll_lock
= false;
708 void BScreen::changeWorkspaceCount(unsigned int new_count
) {
709 assert(new_count
> 0);
711 if (new_count
< workspacesList
.size()) {
713 for (unsigned int i
= workspacesList
.size(); i
> new_count
; --i
)
714 removeLastWorkspace();
715 // removeLast already sets the current workspace to the
716 // last available one.
717 } else if (new_count
> workspacesList
.size()) {
719 for(unsigned int i
= workspacesList
.size(); i
< new_count
; ++i
)
725 void BScreen::reconfigure(void) {
726 // don't reconfigure while saving the initial rc file, it's a waste and it
727 // breaks somethings (workspace names)
728 if (blackbox
->isStartup()) return;
735 // we need to do this explicitly, because just loading this value from the rc
737 changeWorkspaceCount(resource
.workspaces
);
740 gcv
.foreground
= WhitePixel(blackbox
->getXDisplay(),
742 gcv
.function
= GXinvert
;
743 gcv
.subwindow_mode
= IncludeInferiors
;
744 XChangeGC(blackbox
->getXDisplay(), opGC
,
745 GCForeground
| GCFunction
| GCSubwindowMode
, &gcv
);
747 const char *s
= i18n(ScreenSet
, ScreenPositionLength
,
748 "0: 0000 x 0: 0000");
750 geom_w
= resource
.wstyle
.font
->measureString(s
) + resource
.bevel_width
* 2;
751 geom_h
= resource
.wstyle
.font
->height() + resource
.bevel_width
* 2;
753 BTexture
* texture
= &(resource
.wstyle
.l_focus
);
754 geom_pixmap
= texture
->render(geom_w
, geom_h
, geom_pixmap
);
755 if (geom_pixmap
== ParentRelative
) {
756 texture
= &(resource
.wstyle
.t_focus
);
757 geom_pixmap
= texture
->render(geom_w
, geom_h
, geom_pixmap
);
760 XSetWindowBackground(blackbox
->getXDisplay(), geom_window
,
761 texture
->color().pixel());
763 XSetWindowBackgroundPixmap(blackbox
->getXDisplay(),
764 geom_window
, geom_pixmap
);
766 XSetWindowBorderWidth(blackbox
->getXDisplay(), geom_window
,
767 resource
.border_width
);
768 XSetWindowBorder(blackbox
->getXDisplay(), geom_window
,
769 resource
.border_color
.pixel());
771 workspacemenu
->reconfigure();
772 iconmenu
->reconfigure();
774 typedef std::vector
<int> SubList
;
775 SubList remember_subs
;
777 // save the current open menus
778 Basemenu
*menu
= rootmenu
;
780 while ((submenu
= menu
->getCurrentSubmenu()) >= 0) {
781 remember_subs
.push_back(submenu
);
782 menu
= menu
->find(submenu
)->submenu();
788 rootmenu
->reconfigure();
790 // reopen the saved menus
792 const SubList::iterator subs_end
= remember_subs
.end();
793 for (SubList::iterator it
= remember_subs
.begin(); it
!= subs_end
; ++it
) {
794 menu
->drawSubmenu(*it
);
795 menu
= menu
->find(*it
)->submenu();
800 configmenu
->reconfigure();
802 toolbar
->reconfigure();
806 std::for_each(workspacesList
.begin(), workspacesList
.end(),
807 std::mem_fun(&Workspace::reconfigure
));
809 BlackboxWindowList::iterator iit
= iconList
.begin();
810 for (; iit
!= iconList
.end(); ++iit
) {
811 BlackboxWindow
*bw
= *iit
;
812 if (bw
->validateClient())
816 image_control
->timeout();
820 void BScreen::rereadMenu(void) {
824 rootmenu
->reconfigure();
828 void BScreen::LoadStyle(void) {
829 Configuration
style(False
);
831 const char *sfile
= blackbox
->getStyleFilename();
833 style
.setFile(sfile
);
834 if (! style
.load()) {
835 style
.setFile(DEFAULTSTYLE
);
837 style
.create(); // hardcoded default values will be used.
841 // merge in the rc file
842 style
.merge(config
->file(), True
);
846 // load fonts/fontsets
847 if (resource
.wstyle
.font
)
848 delete resource
.wstyle
.font
;
849 if (resource
.tstyle
.font
)
850 delete resource
.tstyle
.font
;
851 if (resource
.mstyle
.f_font
)
852 delete resource
.mstyle
.f_font
;
853 if (resource
.mstyle
.t_font
)
854 delete resource
.mstyle
.t_font
;
855 resource
.wstyle
.font
= resource
.tstyle
.font
= resource
.mstyle
.f_font
=
856 resource
.mstyle
.t_font
= (BFont
*) 0;
858 resource
.wstyle
.font
= readDatabaseFont("window.", style
);
859 resource
.tstyle
.font
= readDatabaseFont("toolbar.", style
);
860 resource
.mstyle
.t_font
= readDatabaseFont("menu.title.", style
);
861 resource
.mstyle
.f_font
= readDatabaseFont("menu.frame.", style
);
863 // load window config
864 resource
.wstyle
.t_focus
=
865 readDatabaseTexture("window.title.focus", "white", style
);
866 resource
.wstyle
.t_unfocus
=
867 readDatabaseTexture("window.title.unfocus", "black", style
);
868 resource
.wstyle
.l_focus
=
869 readDatabaseTexture("window.label.focus", "white", style
);
870 resource
.wstyle
.l_unfocus
=
871 readDatabaseTexture("window.label.unfocus", "black", style
);
872 resource
.wstyle
.h_focus
=
873 readDatabaseTexture("window.handle.focus", "white", style
);
874 resource
.wstyle
.h_unfocus
=
875 readDatabaseTexture("window.handle.unfocus", "black", style
);
876 resource
.wstyle
.g_focus
=
877 readDatabaseTexture("window.grip.focus", "white", style
);
878 resource
.wstyle
.g_unfocus
=
879 readDatabaseTexture("window.grip.unfocus", "black", style
);
880 resource
.wstyle
.b_focus
=
881 readDatabaseTexture("window.button.focus", "white", style
);
882 resource
.wstyle
.b_unfocus
=
883 readDatabaseTexture("window.button.unfocus", "black", style
);
884 resource
.wstyle
.b_pressed
=
885 readDatabaseTexture("window.button.pressed", "black", style
);
886 resource
.wstyle
.f_focus
=
887 readDatabaseColor("window.frame.focusColor", "white", style
);
888 resource
.wstyle
.f_unfocus
=
889 readDatabaseColor("window.frame.unfocusColor", "black", style
);
890 resource
.wstyle
.l_text_focus
=
891 readDatabaseColor("window.label.focus.textColor", "black", style
);
892 resource
.wstyle
.l_text_unfocus
=
893 readDatabaseColor("window.label.unfocus.textColor", "white", style
);
894 resource
.wstyle
.b_pic_focus
=
895 readDatabaseColor("window.button.focus.picColor", "black", style
);
896 resource
.wstyle
.b_pic_unfocus
=
897 readDatabaseColor("window.button.unfocus.picColor", "white", style
);
899 resource
.wstyle
.justify
= LeftJustify
;
900 if (style
.getValue("window.justify", s
)) {
901 if (s
== "right" || s
== "Right")
902 resource
.wstyle
.justify
= RightJustify
;
903 else if (s
== "center" || s
== "Center")
904 resource
.wstyle
.justify
= CenterJustify
;
907 // load toolbar config
908 resource
.tstyle
.toolbar
=
909 readDatabaseTexture("toolbar", "black", style
);
910 resource
.tstyle
.label
=
911 readDatabaseTexture("toolbar.label", "black", style
);
912 resource
.tstyle
.window
=
913 readDatabaseTexture("toolbar.windowLabel", "black", style
);
914 resource
.tstyle
.button
=
915 readDatabaseTexture("toolbar.button", "white", style
);
916 resource
.tstyle
.pressed
=
917 readDatabaseTexture("toolbar.button.pressed", "black", style
);
918 resource
.tstyle
.clock
=
919 readDatabaseTexture("toolbar.clock", "black", style
);
920 resource
.tstyle
.l_text
=
921 readDatabaseColor("toolbar.label.textColor", "white", style
);
922 resource
.tstyle
.w_text
=
923 readDatabaseColor("toolbar.windowLabel.textColor", "white", style
);
924 resource
.tstyle
.c_text
=
925 readDatabaseColor("toolbar.clock.textColor", "white", style
);
926 resource
.tstyle
.b_pic
=
927 readDatabaseColor("toolbar.button.picColor", "black", style
);
929 resource
.tstyle
.justify
= LeftJustify
;
930 if (style
.getValue("toolbar.justify", s
)) {
931 if (s
== "right" || s
== "Right")
932 resource
.tstyle
.justify
= RightJustify
;
933 else if (s
== "center" || s
== "Center")
934 resource
.tstyle
.justify
= CenterJustify
;
938 resource
.mstyle
.title
=
939 readDatabaseTexture("menu.title", "white", style
);
940 resource
.mstyle
.frame
=
941 readDatabaseTexture("menu.frame", "black", style
);
942 resource
.mstyle
.hilite
=
943 readDatabaseTexture("menu.hilite", "white", style
);
944 resource
.mstyle
.t_text
=
945 readDatabaseColor("menu.title.textColor", "black", style
);
946 resource
.mstyle
.f_text
=
947 readDatabaseColor("menu.frame.textColor", "white", style
);
948 resource
.mstyle
.d_text
=
949 readDatabaseColor("menu.frame.disableColor", "black", style
);
950 resource
.mstyle
.h_text
=
951 readDatabaseColor("menu.hilite.textColor", "black", style
);
953 resource
.mstyle
.t_justify
= LeftJustify
;
954 if (style
.getValue("menu.title.justify", s
)) {
955 if (s
== "right" || s
== "Right")
956 resource
.mstyle
.t_justify
= RightJustify
;
957 else if (s
== "center" || s
== "Center")
958 resource
.mstyle
.t_justify
= CenterJustify
;
961 resource
.mstyle
.f_justify
= LeftJustify
;
962 if (style
.getValue("menu.frame.justify", s
)) {
963 if (s
== "right" || s
== "Right")
964 resource
.mstyle
.f_justify
= RightJustify
;
965 else if (s
== "center" || s
== "Center")
966 resource
.mstyle
.f_justify
= CenterJustify
;
969 resource
.mstyle
.bullet
= Basemenu::Triangle
;
970 if (style
.getValue("menu.bullet", s
)) {
971 if (s
== "empty" || s
== "Empty")
972 resource
.mstyle
.bullet
= Basemenu::Empty
;
973 else if (s
== "square" || s
== "Square")
974 resource
.mstyle
.bullet
= Basemenu::Square
;
975 else if (s
== "diamond" || s
== "Diamond")
976 resource
.mstyle
.bullet
= Basemenu::Diamond
;
979 resource
.mstyle
.bullet_pos
= Basemenu::Left
;
980 if (style
.getValue("menu.bullet.position", s
)) {
981 if (s
== "right" || s
== "Right")
982 resource
.mstyle
.bullet_pos
= Basemenu::Right
;
985 resource
.border_color
=
986 readDatabaseColor("borderColor", "black", style
);
988 // load bevel, border and handle widths
989 if (! style
.getValue("handleWidth", resource
.handle_width
) ||
990 resource
.handle_width
> (getWidth() / 2) || resource
.handle_width
== 0)
991 resource
.handle_width
= 6;
993 if (! style
.getValue("borderWidth", resource
.border_width
))
994 resource
.border_width
= 1;
996 if (! style
.getValue("bevelWidth", resource
.bevel_width
) ||
997 resource
.bevel_width
> (getWidth() / 2) || resource
.bevel_width
== 0)
998 resource
.bevel_width
= 3;
1000 if (! style
.getValue("frameWidth", resource
.frame_width
) ||
1001 resource
.frame_width
> (getWidth() / 2))
1002 resource
.frame_width
= resource
.bevel_width
;
1004 if (style
.getValue("rootCommand", s
))
1005 bexec(s
, displayString());
1009 void BScreen::addIcon(BlackboxWindow
*w
) {
1012 w
->setWorkspace(BSENTINEL
);
1013 w
->setWindowNumber(iconList
.size());
1015 iconList
.push_back(w
);
1017 const char* title
= w
->getIconTitle();
1018 iconmenu
->insert(title
);
1023 void BScreen::removeIcon(BlackboxWindow
*w
) {
1028 iconmenu
->remove(w
->getWindowNumber());
1031 BlackboxWindowList::iterator it
= iconList
.begin(),
1032 end
= iconList
.end();
1033 for (int i
= 0; it
!= end
; ++it
)
1034 (*it
)->setWindowNumber(i
++);
1038 BlackboxWindow
*BScreen::getIcon(unsigned int index
) {
1039 if (index
< iconList
.size()) {
1040 BlackboxWindowList::iterator it
= iconList
.begin();
1041 for (; index
> 0; --index
, ++it
) ; /* increment to index */
1045 return (BlackboxWindow
*) 0;
1049 unsigned int BScreen::addWorkspace(void) {
1050 Workspace
*wkspc
= new Workspace(this, workspacesList
.size());
1051 workspacesList
.push_back(wkspc
);
1052 saveWorkspaces(getWorkspaceCount());
1053 saveWorkspaceNames();
1055 workspacemenu
->insertWorkspace(wkspc
);
1056 workspacemenu
->update();
1058 toolbar
->reconfigure();
1060 updateNetizenWorkspaceCount();
1062 return workspacesList
.size();
1066 unsigned int BScreen::removeLastWorkspace(void) {
1067 if (workspacesList
.size() == 1)
1070 Workspace
*wkspc
= workspacesList
.back();
1072 if (current_workspace
->getID() == wkspc
->getID())
1073 changeWorkspaceID(current_workspace
->getID() - 1);
1077 workspacemenu
->removeWorkspace(wkspc
);
1078 workspacemenu
->update();
1080 workspacesList
.pop_back();
1083 saveWorkspaces(getWorkspaceCount());
1084 saveWorkspaceNames();
1086 toolbar
->reconfigure();
1088 updateNetizenWorkspaceCount();
1090 return workspacesList
.size();
1094 void BScreen::changeWorkspaceID(unsigned int id
) {
1095 if (! current_workspace
|| id
== current_workspace
->getID()) return;
1097 BlackboxWindow
*focused
= blackbox
->getFocusedWindow();
1098 if (focused
&& focused
->getScreen() == this) {
1099 assert(focused
->isStuck() ||
1100 focused
->getWorkspaceNumber() == current_workspace
->getID());
1102 current_workspace
->setLastFocusedWindow(focused
);
1104 // if no window had focus, no need to store a last focus
1105 current_workspace
->setLastFocusedWindow((BlackboxWindow
*) 0);
1108 // when we switch workspaces, unfocus whatever was focused
1109 blackbox
->setFocusedWindow((BlackboxWindow
*) 0);
1111 current_workspace
->hideAll();
1112 workspacemenu
->setItemSelected(current_workspace
->getID() + 2, False
);
1114 current_workspace
= getWorkspace(id
);
1116 xatom
->setValue(getRootWindow(), XAtom::net_current_desktop
,
1117 XAtom::cardinal
, id
);
1119 workspacemenu
->setItemSelected(current_workspace
->getID() + 2, True
);
1120 toolbar
->redrawWorkspaceLabel(True
);
1122 current_workspace
->showAll();
1124 if (resource
.focus_last
&& current_workspace
->getLastFocusedWindow()) {
1125 XSync(blackbox
->getXDisplay(), False
);
1126 current_workspace
->getLastFocusedWindow()->setInputFocus();
1129 updateNetizenCurrentWorkspace();
1134 * Set the _NET_CLIENT_LIST root window property.
1136 void BScreen::updateClientList(void) {
1137 if (windowList
.size() > 0) {
1138 Window
*windows
= new Window
[windowList
.size()];
1139 Window
*win_it
= windows
;
1140 BlackboxWindowList::iterator it
= windowList
.begin();
1141 const BlackboxWindowList::iterator end
= windowList
.end();
1142 for (; it
!= end
; ++it
, ++win_it
)
1143 *win_it
= (*it
)->getClientWindow();
1144 xatom
->setValue(getRootWindow(), XAtom::net_client_list
, XAtom::window
,
1145 windows
, windowList
.size());
1148 xatom
->setValue(getRootWindow(), XAtom::net_client_list
, XAtom::window
,
1151 updateStackingList();
1156 * Set the _NET_CLIENT_LIST_STACKING root window property.
1158 void BScreen::updateStackingList(void) {
1160 BlackboxWindowList stack_order
;
1163 * Get the stacking order from all of the workspaces.
1164 * We start with the current workspace so that the sticky windows will be
1165 * in the right order on the current workspace.
1166 * XXX: Do we need to have sticky windows in the list once for each workspace?
1168 getCurrentWorkspace()->appendStackOrder(stack_order
);
1169 for (unsigned int i
= 0; i
< getWorkspaceCount(); ++i
)
1170 if (i
!= getCurrentWorkspaceID())
1171 getWorkspace(i
)->appendStackOrder(stack_order
);
1173 if (stack_order
.size() > 0) {
1174 // set the client list atoms
1175 Window
*windows
= new Window
[stack_order
.size()];
1176 Window
*win_it
= windows
;
1177 BlackboxWindowList::iterator it
= stack_order
.begin(),
1178 end
= stack_order
.end();
1179 for (; it
!= end
; ++it
, ++win_it
)
1180 *win_it
= (*it
)->getClientWindow();
1181 xatom
->setValue(getRootWindow(), XAtom::net_client_list_stacking
,
1182 XAtom::window
, windows
, stack_order
.size());
1185 xatom
->setValue(getRootWindow(), XAtom::net_client_list_stacking
,
1186 XAtom::window
, 0, 0);
1190 void BScreen::addSystrayWindow(Window window
) {
1191 systrayWindowList
.push_back(window
);
1192 xatom
->setValue(getRootWindow(), XAtom::kde_net_system_tray_windows
,
1194 &systrayWindowList
[0], systrayWindowList
.size());
1195 blackbox
->saveSystrayWindowSearch(window
, this);
1199 void BScreen::removeSystrayWindow(Window window
) {
1200 WindowList::iterator it
= systrayWindowList
.begin();
1201 const WindowList::iterator end
= systrayWindowList
.end();
1202 for (; it
!= end
; ++it
)
1203 if (*it
== window
) {
1204 systrayWindowList
.erase(it
);
1205 xatom
->setValue(getRootWindow(), XAtom::kde_net_system_tray_windows
,
1207 &systrayWindowList
[0], systrayWindowList
.size());
1208 blackbox
->removeSystrayWindowSearch(window
);
1214 void BScreen::manageWindow(Window w
) {
1215 // is the window a KDE systray window?
1217 if (xatom
->getValue(w
, XAtom::kde_net_wm_system_tray_window_for
,
1218 XAtom::window
, systray
) && systray
) {
1219 addSystrayWindow(w
);
1223 new BlackboxWindow(blackbox
, w
, this);
1225 BlackboxWindow
*win
= blackbox
->searchWindow(w
);
1230 if (win
->isNormal()) {
1231 // don't list non-normal windows as managed windows
1232 windowList
.push_back(win
);
1234 } else if (win
->isDesktop()) {
1235 desktopWindowList
.push_back(win
->getFrameWindow());
1238 XMapRequestEvent mre
;
1240 if (blackbox
->isStartup() && win
->isNormal()) win
->restoreAttributes();
1241 win
->mapRequestEvent(&mre
);
1245 void BScreen::unmanageWindow(BlackboxWindow
*w
, bool remap
) {
1248 if (w
->getWorkspaceNumber() != BSENTINEL
&&
1249 w
->getWindowNumber() != BSENTINEL
)
1250 getWorkspace(w
->getWorkspaceNumber())->removeWindow(w
);
1251 else if (w
->isIconic())
1254 if (w
->isNormal()) {
1255 // we don't list non-normal windows as managed windows
1256 windowList
.remove(w
);
1258 } else if (w
->isDesktop()) {
1259 WindowList::iterator it
= desktopWindowList
.begin();
1260 const WindowList::iterator end
= desktopWindowList
.end();
1261 for (; it
!= end
; ++it
)
1262 if (*it
== w
->getFrameWindow()) {
1263 desktopWindowList
.erase(it
);
1266 assert(it
!= end
); // the window wasnt a desktop window?
1269 if (blackbox
->getFocusedWindow() == w
)
1270 blackbox
->setFocusedWindow((BlackboxWindow
*) 0);
1272 removeNetizen(w
->getClientWindow());
1275 some managed windows can also be window group controllers. when
1276 unmanaging such windows, we should also delete the window group.
1278 BWindowGroup
*group
= blackbox
->searchGroup(w
->getClientWindow());
1285 void BScreen::addNetizen(Netizen
*n
) {
1286 netizenList
.push_back(n
);
1288 n
->sendWorkspaceCount();
1289 n
->sendCurrentWorkspace();
1291 WorkspaceList::iterator it
= workspacesList
.begin();
1292 const WorkspaceList::iterator end
= workspacesList
.end();
1293 for (; it
!= end
; ++it
)
1294 (*it
)->sendWindowList(*n
);
1296 Window f
= ((blackbox
->getFocusedWindow()) ?
1297 blackbox
->getFocusedWindow()->getClientWindow() : None
);
1298 n
->sendWindowFocus(f
);
1302 void BScreen::removeNetizen(Window w
) {
1303 NetizenList::iterator it
= netizenList
.begin();
1304 for (; it
!= netizenList
.end(); ++it
) {
1305 if ((*it
)->getWindowID() == w
) {
1307 netizenList
.erase(it
);
1314 void BScreen::updateWorkArea(void) {
1315 if (workspacesList
.size() > 0) {
1316 unsigned long *dims
= new unsigned long[4 * workspacesList
.size()];
1317 for (unsigned int i
= 0, m
= workspacesList
.size(); i
< m
; ++i
) {
1318 // XXX: this could be different for each workspace
1319 const Rect
&area
= availableArea();
1320 dims
[(i
* 4) + 0] = area
.x();
1321 dims
[(i
* 4) + 1] = area
.y();
1322 dims
[(i
* 4) + 2] = area
.width();
1323 dims
[(i
* 4) + 3] = area
.height();
1325 xatom
->setValue(getRootWindow(), XAtom::net_workarea
, XAtom::cardinal
,
1326 dims
, 4 * workspacesList
.size());
1329 xatom
->setValue(getRootWindow(), XAtom::net_workarea
, XAtom::cardinal
,
1334 void BScreen::updateNetizenCurrentWorkspace(void) {
1335 std::for_each(netizenList
.begin(), netizenList
.end(),
1336 std::mem_fun(&Netizen::sendCurrentWorkspace
));
1340 void BScreen::updateNetizenWorkspaceCount(void) {
1341 xatom
->setValue(getRootWindow(), XAtom::net_number_of_desktops
,
1342 XAtom::cardinal
, workspacesList
.size());
1346 std::for_each(netizenList
.begin(), netizenList
.end(),
1347 std::mem_fun(&Netizen::sendWorkspaceCount
));
1351 void BScreen::updateNetizenWindowFocus(void) {
1352 Window f
= ((blackbox
->getFocusedWindow()) ?
1353 blackbox
->getFocusedWindow()->getClientWindow() : None
);
1355 xatom
->setValue(getRootWindow(), XAtom::net_active_window
,
1358 NetizenList::iterator it
= netizenList
.begin();
1359 for (; it
!= netizenList
.end(); ++it
)
1360 (*it
)->sendWindowFocus(f
);
1364 void BScreen::updateNetizenWindowAdd(Window w
, unsigned long p
) {
1365 NetizenList::iterator it
= netizenList
.begin();
1366 for (; it
!= netizenList
.end(); ++it
) {
1367 (*it
)->sendWindowAdd(w
, p
);
1372 void BScreen::updateNetizenWindowDel(Window w
) {
1373 NetizenList::iterator it
= netizenList
.begin();
1374 for (; it
!= netizenList
.end(); ++it
)
1375 (*it
)->sendWindowDel(w
);
1379 void BScreen::updateNetizenWindowRaise(Window w
) {
1380 NetizenList::iterator it
= netizenList
.begin();
1381 for (; it
!= netizenList
.end(); ++it
)
1382 (*it
)->sendWindowRaise(w
);
1386 void BScreen::updateNetizenWindowLower(Window w
) {
1387 NetizenList::iterator it
= netizenList
.begin();
1388 for (; it
!= netizenList
.end(); ++it
)
1389 (*it
)->sendWindowLower(w
);
1393 void BScreen::updateNetizenConfigNotify(XEvent
*e
) {
1394 NetizenList::iterator it
= netizenList
.begin();
1395 for (; it
!= netizenList
.end(); ++it
)
1396 (*it
)->sendConfigNotify(e
);
1400 void BScreen::raiseWindows(Window
*workspace_stack
, unsigned int num
) {
1401 // the 13 represents the number of blackbox windows such as menus
1402 Window
*session_stack
= new
1403 Window
[(num
+ workspacesList
.size() + rootmenuList
.size() + 13)];
1404 unsigned int i
= 0, k
= num
;
1406 XRaiseWindow(blackbox
->getXDisplay(), iconmenu
->getWindowID());
1407 *(session_stack
+ i
++) = iconmenu
->getWindowID();
1409 WorkspaceList::iterator wit
= workspacesList
.begin();
1410 const WorkspaceList::iterator w_end
= workspacesList
.end();
1411 for (; wit
!= w_end
; ++wit
)
1412 *(session_stack
+ i
++) = (*wit
)->getMenu()->getWindowID();
1414 *(session_stack
+ i
++) = workspacemenu
->getWindowID();
1416 *(session_stack
+ i
++) = configmenu
->getFocusmenu()->getWindowID();
1417 *(session_stack
+ i
++) = configmenu
->getPlacementmenu()->getWindowID();
1418 *(session_stack
+ i
++) = configmenu
->getWindowID();
1420 *(session_stack
+ i
++) = slit
->getMenu()->getDirectionmenu()->getWindowID();
1421 *(session_stack
+ i
++) = slit
->getMenu()->getPlacementmenu()->getWindowID();
1422 *(session_stack
+ i
++) = slit
->getMenu()->getWindowID();
1424 *(session_stack
+ i
++) =
1425 toolbar
->getMenu()->getPlacementmenu()->getWindowID();
1426 *(session_stack
+ i
++) = toolbar
->getMenu()->getWindowID();
1428 RootmenuList::iterator rit
= rootmenuList
.begin();
1429 for (; rit
!= rootmenuList
.end(); ++rit
)
1430 *(session_stack
+ i
++) = (*rit
)->getWindowID();
1431 *(session_stack
+ i
++) = rootmenu
->getWindowID();
1433 if (toolbar
->isOnTop())
1434 *(session_stack
+ i
++) = toolbar
->getWindowID();
1436 if (slit
->isOnTop())
1437 *(session_stack
+ i
++) = slit
->getWindowID();
1440 *(session_stack
+ i
++) = *(workspace_stack
+ k
);
1442 XRestackWindows(blackbox
->getXDisplay(), session_stack
, i
);
1444 delete [] session_stack
;
1446 updateStackingList();
1450 void BScreen::lowerWindows(Window
*workspace_stack
, unsigned int num
) {
1451 assert(num
> 0); // this would cause trouble in the XRaiseWindow call
1453 Window
*session_stack
= new Window
[(num
+ desktopWindowList
.size())];
1454 unsigned int i
= 0, k
= num
;
1456 XLowerWindow(blackbox
->getXDisplay(), workspace_stack
[0]);
1459 *(session_stack
+ i
++) = *(workspace_stack
+ k
);
1461 WindowList::iterator dit
= desktopWindowList
.begin();
1462 const WindowList::iterator d_end
= desktopWindowList
.end();
1463 for (; dit
!= d_end
; ++dit
)
1464 *(session_stack
+ i
++) = *dit
;
1466 XRestackWindows(blackbox
->getXDisplay(), session_stack
, i
);
1468 delete [] session_stack
;
1470 updateStackingList();
1474 void BScreen::reassociateWindow(BlackboxWindow
*w
, unsigned int wkspc_id
,
1475 bool ignore_sticky
) {
1478 if (wkspc_id
== BSENTINEL
)
1479 wkspc_id
= current_workspace
->getID();
1481 if (w
->getWorkspaceNumber() == wkspc_id
)
1484 if (w
->isIconic()) {
1486 getWorkspace(wkspc_id
)->addWindow(w
);
1487 } else if (ignore_sticky
|| ! w
->isStuck()) {
1488 getWorkspace(w
->getWorkspaceNumber())->removeWindow(w
);
1489 getWorkspace(wkspc_id
)->addWindow(w
);
1491 updateStackingList();
1495 void BScreen::propagateWindowName(const BlackboxWindow
*bw
) {
1496 if (bw
->isIconic()) {
1497 iconmenu
->changeItemLabel(bw
->getWindowNumber(), bw
->getIconTitle());
1501 Clientmenu
*clientmenu
= getWorkspace(bw
->getWorkspaceNumber())->getMenu();
1502 clientmenu
->changeItemLabel(bw
->getWindowNumber(), bw
->getTitle());
1503 clientmenu
->update();
1505 if (blackbox
->getFocusedWindow() == bw
)
1506 toolbar
->redrawWindowLabel(True
);
1511 void BScreen::nextFocus(void) {
1512 BlackboxWindow
*focused
= blackbox
->getFocusedWindow(),
1516 // if window is not on this screen, ignore it
1517 if (focused
->getScreen()->getScreenNumber() != getScreenNumber())
1518 focused
= (BlackboxWindow
*) 0;
1521 if (focused
&& current_workspace
->getCount() > 1) {
1522 // next is the next window to recieve focus, current is a place holder
1523 BlackboxWindow
*current
;
1526 next
= current_workspace
->getNextWindowInList(current
);
1527 } while(! next
->setInputFocus() && next
!= focused
);
1529 if (next
!= focused
)
1530 current_workspace
->raiseWindow(next
);
1531 } else if (current_workspace
->getCount() >= 1) {
1532 next
= current_workspace
->getTopWindowOnStack();
1534 current_workspace
->raiseWindow(next
);
1535 next
->setInputFocus();
1540 void BScreen::prevFocus(void) {
1541 BlackboxWindow
*focused
= blackbox
->getFocusedWindow(),
1545 // if window is not on this screen, ignore it
1546 if (focused
->getScreen()->getScreenNumber() != getScreenNumber())
1547 focused
= (BlackboxWindow
*) 0;
1550 if (focused
&& current_workspace
->getCount() > 1) {
1551 // next is the next window to recieve focus, current is a place holder
1552 BlackboxWindow
*current
;
1555 next
= current_workspace
->getPrevWindowInList(current
);
1556 } while(! next
->setInputFocus() && next
!= focused
);
1558 if (next
!= focused
)
1559 current_workspace
->raiseWindow(next
);
1560 } else if (current_workspace
->getCount() >= 1) {
1561 next
= current_workspace
->getTopWindowOnStack();
1563 current_workspace
->raiseWindow(next
);
1564 next
->setInputFocus();
1569 void BScreen::raiseFocus(void) {
1570 BlackboxWindow
*focused
= blackbox
->getFocusedWindow();
1574 // if on this Screen, raise it
1575 if (focused
->getScreen()->getScreenNumber() == getScreenNumber()) {
1576 Workspace
*workspace
= getWorkspace(focused
->getWorkspaceNumber());
1577 workspace
->raiseWindow(focused
);
1582 void BScreen::InitMenu(void) {
1584 rootmenuList
.clear();
1586 while (rootmenu
->getCount())
1587 rootmenu
->remove(0);
1589 rootmenu
= new Rootmenu(this);
1591 bool defaultMenu
= True
;
1593 FILE *menu_file
= (FILE *) 0;
1594 const char *menu_filename
= blackbox
->getMenuFilename();
1597 if (! (menu_file
= fopen(menu_filename
, "r")))
1598 perror(menu_filename
);
1599 if (! menu_file
) { // opening the menu file failed, try the default menu
1600 menu_filename
= DEFAULTMENU
;
1601 if (! (menu_file
= fopen(menu_filename
, "r")))
1602 perror(menu_filename
);
1606 if (feof(menu_file
)) {
1607 fprintf(stderr
, i18n(ScreenSet
, ScreenEmptyMenuFile
,
1608 "%s: Empty menu file"),
1611 char line
[1024], label
[1024];
1612 memset(line
, 0, 1024);
1613 memset(label
, 0, 1024);
1615 while (fgets(line
, 1024, menu_file
) && ! feof(menu_file
)) {
1616 if (line
[0] != '#') {
1617 int i
, key
= 0, index
= -1, len
= strlen(line
);
1619 for (i
= 0; i
< len
; i
++) {
1620 if (line
[i
] == '[') index
= 0;
1621 else if (line
[i
] == ']') break;
1622 else if (line
[i
] != ' ')
1624 key
+= tolower(line
[i
]);
1627 if (key
== 517) { // [begin]
1629 for (i
= index
; i
< len
; i
++) {
1630 if (line
[i
] == '(') index
= 0;
1631 else if (line
[i
] == ')') break;
1632 else if (index
++ >= 0) {
1633 if (line
[i
] == '\\' && i
< len
- 1) i
++;
1634 label
[index
- 1] = line
[i
];
1638 if (index
== -1) index
= 0;
1639 label
[index
] = '\0';
1641 rootmenu
->setLabel(label
);
1642 defaultMenu
= parseMenuFile(menu_file
, rootmenu
);
1644 blackbox
->addMenuTimestamp(menu_filename
);
1654 rootmenu
->setInternalMenu();
1655 rootmenu
->insert(i18n(ScreenSet
, Screenxterm
, "xterm"),
1657 i18n(ScreenSet
, Screenxterm
, "xterm"));
1658 rootmenu
->insert(i18n(ScreenSet
, ScreenRestart
, "Restart"),
1660 rootmenu
->insert(i18n(ScreenSet
, ScreenExit
, "Exit"),
1662 rootmenu
->setLabel(i18n(BasemenuSet
, BasemenuBlackboxMenu
,
1668 bool BScreen::parseMenuFile(FILE *file
, Rootmenu
*menu
) {
1669 char line
[1024], label
[1024], command
[1024];
1671 while (! feof(file
)) {
1672 memset(line
, 0, 1024);
1673 memset(label
, 0, 1024);
1674 memset(command
, 0, 1024);
1676 if (fgets(line
, 1024, file
)) {
1677 if (line
[0] != '#') {
1678 int i
, key
= 0, parse
= 0, index
= -1, line_length
= strlen(line
);
1680 // determine the keyword
1681 for (i
= 0; i
< line_length
; i
++) {
1682 if (line
[i
] == '[') parse
= 1;
1683 else if (line
[i
] == ']') break;
1684 else if (line
[i
] != ' ')
1686 key
+= tolower(line
[i
]);
1689 // get the label enclosed in ()'s
1692 for (i
= 0; i
< line_length
; i
++) {
1693 if (line
[i
] == '(') {
1696 } else if (line
[i
] == ')') break;
1697 else if (index
++ >= 0) {
1698 if (line
[i
] == '\\' && i
< line_length
- 1) i
++;
1699 label
[index
- 1] = line
[i
];
1704 label
[index
] = '\0';
1709 // get the command enclosed in {}'s
1712 for (i
= 0; i
< line_length
; i
++) {
1713 if (line
[i
] == '{') {
1716 } else if (line
[i
] == '}') break;
1717 else if (index
++ >= 0) {
1718 if (line
[i
] == '\\' && i
< line_length
- 1) i
++;
1719 command
[index
- 1] = line
[i
];
1724 command
[index
] = '\0';
1731 return ((menu
->getCount() == 0) ? True
: False
);
1738 menu
->insert(label
);
1743 if ((! *label
) && (! *command
)) {
1744 fprintf(stderr
, i18n(ScreenSet
, ScreenEXECError
,
1745 "BScreen::parseMenuFile: [exec] error, "
1746 "no menu label and/or command defined\n"));
1750 menu
->insert(label
, BScreen::Execute
, command
);
1756 fprintf(stderr
, i18n(ScreenSet
, ScreenEXITError
,
1757 "BScreen::parseMenuFile: [exit] error, "
1758 "no menu label defined\n"));
1762 menu
->insert(label
, BScreen::Exit
);
1768 if ((! *label
) || (! *command
)) {
1770 i18n(ScreenSet
, ScreenSTYLEError
,
1771 "BScreen::parseMenuFile: [style] error, "
1772 "no menu label and/or filename defined\n"));
1776 string style
= expandTilde(command
);
1778 menu
->insert(label
, BScreen::SetStyle
, style
.c_str());
1785 fprintf(stderr
, i18n(ScreenSet
, ScreenCONFIGError
,
1786 "BScreen::parseMenufile: [config] error, "
1787 "no label defined"));
1791 menu
->insert(label
, configmenu
);
1795 case 740: // include
1798 fprintf(stderr
, i18n(ScreenSet
, ScreenINCLUDEError
,
1799 "BScreen::parseMenuFile: [include] error, "
1800 "no filename defined\n"));
1804 string newfile
= expandTilde(label
);
1805 FILE *submenufile
= fopen(newfile
.c_str(), "r");
1809 if (fstat(fileno(submenufile
), &buf
) ||
1810 (! S_ISREG(buf
.st_mode
))) {
1812 i18n(ScreenSet
, ScreenINCLUDEErrorReg
,
1813 "BScreen::parseMenuFile: [include] error: "
1814 "'%s' is not a regular file\n"), newfile
.c_str());
1818 if (! feof(submenufile
)) {
1819 if (! parseMenuFile(submenufile
, menu
))
1820 blackbox
->addMenuTimestamp(newfile
);
1822 fclose(submenufile
);
1825 perror(newfile
.c_str());
1831 case 767: // submenu
1834 fprintf(stderr
, i18n(ScreenSet
, ScreenSUBMENUError
,
1835 "BScreen::parseMenuFile: [submenu] error, "
1836 "no menu label defined\n"));
1840 Rootmenu
*submenu
= new Rootmenu(this);
1843 submenu
->setLabel(command
);
1845 submenu
->setLabel(label
);
1847 parseMenuFile(file
, submenu
);
1849 menu
->insert(label
, submenu
);
1850 rootmenuList
.push_back(submenu
);
1855 case 773: // restart
1858 fprintf(stderr
, i18n(ScreenSet
, ScreenRESTARTError
,
1859 "BScreen::parseMenuFile: [restart] error, "
1860 "no menu label defined\n"));
1865 menu
->insert(label
, BScreen::RestartOther
, command
);
1867 menu
->insert(label
, BScreen::Restart
);
1872 case 845: // reconfig
1876 i18n(ScreenSet
, ScreenRECONFIGError
,
1877 "BScreen::parseMenuFile: [reconfig] error, "
1878 "no menu label defined\n"));
1882 menu
->insert(label
, BScreen::Reconfigure
);
1887 case 995: // stylesdir
1888 case 1113: // stylesmenu
1890 bool newmenu
= ((key
== 1113) ? True
: False
);
1892 if ((! *label
) || ((! *command
) && newmenu
)) {
1894 i18n(ScreenSet
, ScreenSTYLESDIRError
,
1895 "BScreen::parseMenuFile: [stylesdir/stylesmenu]"
1896 " error, no directory defined\n"));
1900 char *directory
= ((newmenu
) ? command
: label
);
1902 string stylesdir
= expandTilde(directory
);
1904 struct stat statbuf
;
1906 if (! stat(stylesdir
.c_str(), &statbuf
)) {
1907 if (S_ISDIR(statbuf
.st_mode
)) {
1908 Rootmenu
*stylesmenu
;
1911 stylesmenu
= new Rootmenu(this);
1915 DIR *d
= opendir(stylesdir
.c_str());
1917 std::vector
<string
> ls
;
1919 while((p
= readdir(d
)))
1920 ls
.push_back(p
->d_name
);
1924 std::sort(ls
.begin(), ls
.end());
1926 std::vector
<string
>::iterator it
= ls
.begin(),
1928 for (; it
!= end
; ++it
) {
1929 const string
& fname
= *it
;
1931 if (fname
[fname
.size()-1] == '~')
1934 string style
= stylesdir
;
1938 if ((! stat(style
.c_str(), &statbuf
)) &&
1939 S_ISREG(statbuf
.st_mode
))
1940 stylesmenu
->insert(fname
, BScreen::SetStyle
, style
);
1943 stylesmenu
->update();
1946 stylesmenu
->setLabel(label
);
1947 menu
->insert(label
, stylesmenu
);
1948 rootmenuList
.push_back(stylesmenu
);
1951 blackbox
->addMenuTimestamp(stylesdir
);
1954 i18n(ScreenSet
, ScreenSTYLESDIRErrorNotDir
,
1955 "BScreen::parseMenuFile:"
1956 " [stylesdir/stylesmenu] error, %s is not a"
1957 " directory\n"), stylesdir
.c_str());
1961 i18n(ScreenSet
, ScreenSTYLESDIRErrorNoExist
,
1962 "BScreen::parseMenuFile: [stylesdir/stylesmenu]"
1963 " error, %s does not exist\n"), stylesdir
.c_str());
1968 case 1090: // workspaces
1972 i18n(ScreenSet
, ScreenWORKSPACESError
,
1973 "BScreen:parseMenuFile: [workspaces] error, "
1974 "no menu label defined\n"));
1978 menu
->insert(label
, workspacemenu
);
1987 return ((menu
->getCount() == 0) ? True
: False
);
1991 void BScreen::shutdown(void) {
1992 XSelectInput(blackbox
->getXDisplay(), getRootWindow(), NoEventMask
);
1993 XSync(blackbox
->getXDisplay(), False
);
1995 while(! windowList
.empty())
1996 unmanageWindow(windowList
.front(), True
);
2002 void BScreen::showPosition(int x
, int y
) {
2003 if (! geom_visible
) {
2004 XMoveResizeWindow(blackbox
->getXDisplay(), geom_window
,
2005 (getWidth() - geom_w
) / 2,
2006 (getHeight() - geom_h
) / 2, geom_w
, geom_h
);
2007 XMapWindow(blackbox
->getXDisplay(), geom_window
);
2008 XRaiseWindow(blackbox
->getXDisplay(), geom_window
);
2010 geom_visible
= True
;
2015 sprintf(label
, i18n(ScreenSet
, ScreenPositionFormat
,
2016 "X: %4d x Y: %4d"), x
, y
);
2018 XClearWindow(blackbox
->getXDisplay(), geom_window
);
2020 resource
.wstyle
.font
->drawString(geom_window
,
2021 resource
.bevel_width
, resource
.bevel_width
,
2022 resource
.wstyle
.l_text_focus
,
2027 void BScreen::showGeometry(unsigned int gx
, unsigned int gy
) {
2028 if (! geom_visible
) {
2029 XMoveResizeWindow(blackbox
->getXDisplay(), geom_window
,
2030 (getWidth() - geom_w
) / 2,
2031 (getHeight() - geom_h
) / 2, geom_w
, geom_h
);
2032 XMapWindow(blackbox
->getXDisplay(), geom_window
);
2033 XRaiseWindow(blackbox
->getXDisplay(), geom_window
);
2035 geom_visible
= True
;
2040 sprintf(label
, i18n(ScreenSet
, ScreenGeometryFormat
,
2041 "W: %4d x H: %4d"), gx
, gy
);
2043 XClearWindow(blackbox
->getXDisplay(), geom_window
);
2045 resource
.wstyle
.font
->drawString(geom_window
,
2046 resource
.bevel_width
, resource
.bevel_width
,
2047 resource
.wstyle
.l_text_focus
,
2052 void BScreen::hideGeometry(void) {
2054 XUnmapWindow(blackbox
->getXDisplay(), geom_window
);
2055 geom_visible
= False
;
2060 void BScreen::addStrut(Strut
*strut
) {
2061 strutList
.push_back(strut
);
2065 void BScreen::removeStrut(Strut
*strut
) {
2066 strutList
.remove(strut
);
2070 const Rect
& BScreen::availableArea(void) const {
2072 return getRect(); // return the full screen
2078 RectList
BScreen::allAvailableAreas(void) const {
2079 assert(isXineramaActive());
2080 assert(xineramaUsableArea
.size() > 0);
2081 return xineramaUsableArea
;
2086 void BScreen::updateAvailableArea(void) {
2087 Rect old_area
= usableArea
;
2088 usableArea
= getRect(); // reset to full screen
2091 // reset to the full areas
2092 if (isXineramaActive())
2093 xineramaUsableArea
= getXineramaAreas();
2096 /* these values represent offsets from the screen edge
2097 * we look for the biggest offset on each edge and then apply them
2099 * do not be confused by the similarity to the names of Rect's members
2101 unsigned int current_left
= 0, current_right
= 0, current_top
= 0,
2104 StrutList::const_iterator it
= strutList
.begin(), end
= strutList
.end();
2106 for(; it
!= end
; ++it
) {
2108 if (strut
->left
> current_left
)
2109 current_left
= strut
->left
;
2110 if (strut
->top
> current_top
)
2111 current_top
= strut
->top
;
2112 if (strut
->right
> current_right
)
2113 current_right
= strut
->right
;
2114 if (strut
->bottom
> current_bottom
)
2115 current_bottom
= strut
->bottom
;
2118 usableArea
.setPos(current_left
, current_top
);
2119 usableArea
.setSize(usableArea
.width() - (current_left
+ current_right
),
2120 usableArea
.height() - (current_top
+ current_bottom
));
2123 if (isXineramaActive()) {
2124 // keep each of the ximerama-defined areas inside the strut
2125 RectList::iterator xit
, xend
= xineramaUsableArea
.end();
2126 for (xit
= xineramaUsableArea
.begin(); xit
!= xend
; ++xit
) {
2127 if (xit
->x() < usableArea
.x()) {
2128 xit
->setX(usableArea
.x());
2129 xit
->setWidth(xit
->width() - usableArea
.x());
2131 if (xit
->y() < usableArea
.y()) {
2132 xit
->setY(usableArea
.y());
2133 xit
->setHeight(xit
->height() - usableArea
.y());
2135 if (xit
->x() + xit
->width() > usableArea
.width())
2136 xit
->setWidth(usableArea
.width() - xit
->x());
2137 if (xit
->y() + xit
->height() > usableArea
.height())
2138 xit
->setHeight(usableArea
.height() - xit
->y());
2143 if (old_area
!= usableArea
) {
2144 BlackboxWindowList::iterator it
= windowList
.begin(),
2145 end
= windowList
.end();
2146 for (; it
!= end
; ++it
)
2147 if ((*it
)->isMaximized()) (*it
)->remaximize();
2154 Workspace
* BScreen::getWorkspace(unsigned int index
) {
2155 assert(index
< workspacesList
.size());
2156 return workspacesList
[index
];
2160 void BScreen::buttonPressEvent(const XButtonEvent
*xbutton
) {
2161 if (xbutton
->button
== 1) {
2162 if (! isRootColormapInstalled())
2163 image_control
->installRootColormap();
2165 if (workspacemenu
->isVisible())
2166 workspacemenu
->hide();
2168 if (rootmenu
->isVisible())
2170 } else if (xbutton
->button
== 2) {
2171 int mx
= xbutton
->x_root
- (workspacemenu
->getWidth() / 2);
2172 int my
= xbutton
->y_root
- (workspacemenu
->getTitleHeight() / 2);
2177 if (mx
+ workspacemenu
->getWidth() > getWidth())
2178 mx
= getWidth() - workspacemenu
->getWidth() - getBorderWidth();
2180 if (my
+ workspacemenu
->getHeight() > getHeight())
2181 my
= getHeight() - workspacemenu
->getHeight() - getBorderWidth();
2183 workspacemenu
->move(mx
, my
);
2185 if (! workspacemenu
->isVisible()) {
2186 workspacemenu
->removeParent();
2187 workspacemenu
->show();
2189 } else if (xbutton
->button
== 3) {
2190 int mx
= xbutton
->x_root
- (rootmenu
->getWidth() / 2);
2191 int my
= xbutton
->y_root
- (rootmenu
->getTitleHeight() / 2);
2196 if (mx
+ rootmenu
->getWidth() > getWidth())
2197 mx
= getWidth() - rootmenu
->getWidth() - getBorderWidth();
2199 if (my
+ rootmenu
->getHeight() > getHeight())
2200 my
= getHeight() - rootmenu
->getHeight() - getBorderWidth();
2202 rootmenu
->move(mx
, my
);
2204 if (! rootmenu
->isVisible()) {
2205 blackbox
->checkMenu();
2209 } else if (xbutton
->button
== 4) {
2210 if (getCurrentWorkspaceID() >= getWorkspaceCount() - 1)
2211 changeWorkspaceID(0);
2213 changeWorkspaceID(getCurrentWorkspaceID() + 1);
2215 } else if (xbutton
->button
== 5) {
2216 if (getCurrentWorkspaceID() == 0)
2217 changeWorkspaceID(getWorkspaceCount() - 1);
2219 changeWorkspaceID(getCurrentWorkspaceID() - 1);
2224 void BScreen::propertyNotifyEvent(const XPropertyEvent
*pe
) {
2225 if (pe
->atom
== xatom
->getAtom(XAtom::net_desktop_names
)) {
2226 // _NET_WM_DESKTOP_NAMES
2227 WorkspaceList::iterator it
= workspacesList
.begin();
2228 const WorkspaceList::iterator end
= workspacesList
.end();
2229 for (; it
!= end
; ++it
) {
2230 (*it
)->readName(); // re-read its name from the window property
2231 workspacemenu
->changeWorkspaceLabel((*it
)->getID(), (*it
)->getName());
2233 workspacemenu
->update();
2234 toolbar
->reconfigure();
2235 saveWorkspaceNames();
2240 void BScreen::toggleFocusModel(FocusModel model
) {
2241 std::for_each(windowList
.begin(), windowList
.end(),
2242 std::mem_fun(&BlackboxWindow::ungrabButtons
));
2244 if (model
== SloppyFocus
) {
2245 saveSloppyFocus(True
);
2247 // we're cheating here to save writing the config file 3 times
2248 resource
.auto_raise
= False
;
2249 resource
.click_raise
= False
;
2250 saveSloppyFocus(False
);
2253 std::for_each(windowList
.begin(), windowList
.end(),
2254 std::mem_fun(&BlackboxWindow::grabButtons
));
2258 BTexture
BScreen::readDatabaseTexture(const string
&rname
,
2259 const string
&default_color
,
2260 const Configuration
&style
) {
2264 if (style
.getValue(rname
, s
))
2265 texture
= BTexture(s
);
2267 texture
.setTexture(BTexture::Solid
| BTexture::Flat
);
2269 // associate this texture with this screen
2270 texture
.setDisplay(getBaseDisplay(), getScreenNumber());
2271 texture
.setImageControl(image_control
);
2273 if (texture
.texture() & BTexture::Solid
) {
2274 texture
.setColor(readDatabaseColor(rname
+ ".color",
2275 default_color
, style
));
2276 texture
.setColorTo(readDatabaseColor(rname
+ ".colorTo",
2277 default_color
, style
));
2278 } else if (texture
.texture() & BTexture::Gradient
) {
2279 texture
.setColor(readDatabaseColor(rname
+ ".color",
2280 default_color
, style
));
2281 texture
.setColorTo(readDatabaseColor(rname
+ ".colorTo",
2282 default_color
, style
));
2289 BColor
BScreen::readDatabaseColor(const string
&rname
,
2290 const string
&default_color
,
2291 const Configuration
&style
) {
2294 if (style
.getValue(rname
, s
))
2295 color
= BColor(s
, getBaseDisplay(), getScreenNumber());
2297 color
= BColor(default_color
, getBaseDisplay(), getScreenNumber());
2302 BFont
*BScreen::readDatabaseFont(const string
&rbasename
,
2303 const Configuration
&style
) {
2310 if (style
.getValue(rbasename
+ "xft.font", s
) &&
2311 style
.getValue(rbasename
+ "xft.size", i
)) {
2314 bool italic
= False
;
2315 if (style
.getValue(rbasename
+ "xft.flags", s
)) {
2316 if (s
.find("bold") != string::npos
)
2318 if (s
.find("italic") != string::npos
)
2322 BFont
*b
= new BFont(blackbox
->getXDisplay(), this, family
, i
, bold
,
2323 italic
, resource
.aa_fonts
);
2327 delete b
; // fall back to the normal X font stuff
2331 style
.getValue(rbasename
+ "font", s
);
2332 // if this fails, a blank string will be used, which will cause the fallback
2335 BFont
*b
= new BFont(blackbox
->getXDisplay(), this, s
);
2337 exit(2); // can't continue without a font