diff options
author | fluxgen <fluxgen> | 2002-10-25 20:58:14 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2002-10-25 20:58:14 (GMT) |
commit | a42295bccbaba71262d9e86bf36421551e5291df (patch) | |
tree | 8a48c0fc88dd28ce958e68a9a20eaf7e3a1d29de /src | |
parent | cc60dc63d69edbd2ab058cca5d4c4108a00148ad (diff) | |
download | fluxbox-a42295bccbaba71262d9e86bf36421551e5291df.zip fluxbox-a42295bccbaba71262d9e86bf36421551e5291df.tar.bz2 |
rearranged includes, minor cleaning
Diffstat (limited to 'src')
-rw-r--r-- | src/Screen.cc | 260 |
1 files changed, 108 insertions, 152 deletions
diff --git a/src/Screen.cc b/src/Screen.cc index 23d92a1..0dae64b 100644 --- a/src/Screen.cc +++ b/src/Screen.cc | |||
@@ -22,7 +22,22 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: Screen.cc,v 1.75 2002/10/23 17:30:12 fluxgen Exp $ | 25 | // $Id: Screen.cc,v 1.76 2002/10/25 20:58:14 fluxgen Exp $ |
26 | |||
27 | |||
28 | #include "Screen.hh" | ||
29 | |||
30 | #include "i18n.hh" | ||
31 | #include "fluxbox.hh" | ||
32 | #include "Image.hh" | ||
33 | #include "Toolbar.hh" | ||
34 | #include "Window.hh" | ||
35 | #include "Workspace.hh" | ||
36 | #include "Rootmenu.hh" | ||
37 | #include "Workspacemenu.hh" | ||
38 | #include "Configmenu.hh" | ||
39 | #include "Iconmenu.hh" | ||
40 | #include "StringUtil.hh" | ||
26 | 41 | ||
27 | //use GNU extensions | 42 | //use GNU extensions |
28 | #ifndef _GNU_SOURCE | 43 | #ifndef _GNU_SOURCE |
@@ -33,51 +48,37 @@ | |||
33 | #include "config.h" | 48 | #include "config.h" |
34 | #endif // HAVE_CONFIG_H | 49 | #endif // HAVE_CONFIG_H |
35 | 50 | ||
36 | #include "Screen.hh" | ||
37 | |||
38 | #include "i18n.hh" | ||
39 | #include "fluxbox.hh" | ||
40 | #include "Icon.hh" | ||
41 | #include "Image.hh" | ||
42 | #include "StringUtil.hh" | ||
43 | |||
44 | #ifdef SLIT | 51 | #ifdef SLIT |
45 | #include "Slit.hh" | 52 | #include "Slit.hh" |
46 | #endif // SLIT | 53 | #endif // SLIT |
47 | 54 | ||
48 | #include "Rootmenu.hh" | ||
49 | #include "Toolbar.hh" | ||
50 | #include "Window.hh" | ||
51 | #include "Workspace.hh" | ||
52 | #include "Workspacemenu.hh" | ||
53 | |||
54 | #ifdef STDC_HEADERS | 55 | #ifdef STDC_HEADERS |
55 | # include <sys/types.h> | 56 | #include <sys/types.h> |
56 | #endif // STDC_HEADERS | 57 | #endif // STDC_HEADERS |
57 | 58 | ||
58 | #ifdef HAVE_CTYPE_H | 59 | #ifdef HAVE_CTYPE_H |
59 | # include <ctype.h> | 60 | #include <ctype.h> |
60 | #endif // HAVE_CTYPE_H | 61 | #endif // HAVE_CTYPE_H |
61 | 62 | ||
62 | #ifdef HAVE_DIRENT_H | 63 | #ifdef HAVE_DIRENT_H |
63 | # include <dirent.h> | 64 | #include <dirent.h> |
64 | #endif // HAVE_DIRENT_H | 65 | #endif // HAVE_DIRENT_H |
65 | 66 | ||
66 | #ifdef HAVE_LOCALE_H | 67 | #ifdef HAVE_LOCALE_H |
67 | # include <locale.h> | 68 | #include <locale.h> |
68 | #endif // HAVE_LOCALE_H | 69 | #endif // HAVE_LOCALE_H |
69 | 70 | ||
70 | #ifdef HAVE_UNISTD_H | 71 | #ifdef HAVE_UNISTD_H |
71 | # include <sys/types.h> | 72 | #include <sys/types.h> |
72 | # include <unistd.h> | 73 | #include <unistd.h> |
73 | #endif // HAVE_UNISTD_H | 74 | #endif // HAVE_UNISTD_H |
74 | 75 | ||
75 | #ifdef HAVE_SYS_STAT_H | 76 | #ifdef HAVE_SYS_STAT_H |
76 | # include <sys/stat.h> | 77 | #include <sys/stat.h> |
77 | #endif // HAVE_SYS_STAT_H | 78 | #endif // HAVE_SYS_STAT_H |
78 | 79 | ||
79 | #ifdef HAVE_STDARG_H | 80 | #ifdef HAVE_STDARG_H |
80 | # include <stdarg.h> | 81 | #include <stdarg.h> |
81 | #endif // HAVE_STDARG_H | 82 | #endif // HAVE_STDARG_H |
82 | 83 | ||
83 | #ifndef MAXPATHLEN | 84 | #ifndef MAXPATHLEN |
@@ -94,8 +95,9 @@ | |||
94 | using namespace std; | 95 | using namespace std; |
95 | 96 | ||
96 | static bool running = true; | 97 | static bool running = true; |
98 | namespace { | ||
97 | 99 | ||
98 | static int anotherWMRunning(Display *display, XErrorEvent *) { | 100 | int anotherWMRunning(Display *display, XErrorEvent *) { |
99 | fprintf(stderr, | 101 | fprintf(stderr, |
100 | I18n::instance()-> | 102 | I18n::instance()-> |
101 | getMessage( | 103 | getMessage( |
@@ -109,10 +111,12 @@ static int anotherWMRunning(Display *display, XErrorEvent *) { | |||
109 | return(-1); | 111 | return(-1); |
110 | } | 112 | } |
111 | 113 | ||
112 | static int dcmp(const void *one, const void *two) { | 114 | int dcmp(const void *one, const void *two) { |
113 | return (strcmp((*(char **) one), (*(char **) two))); | 115 | return (strcmp((*(char **) one), (*(char **) two))); |
114 | } | 116 | } |
115 | 117 | ||
118 | }; | ||
119 | |||
116 | //---------- resource manipulators --------- | 120 | //---------- resource manipulators --------- |
117 | template<> | 121 | template<> |
118 | void Resource<Tab::Alignment>:: | 122 | void Resource<Tab::Alignment>:: |
@@ -218,26 +222,24 @@ toolbar_placement(rm, Toolbar::BOTTOMCENTER, scrname+".toolbar.placement", altsc | |||
218 | 222 | ||
219 | }; | 223 | }; |
220 | 224 | ||
221 | BScreen::BScreen(ResourceManager &rm, Fluxbox *b, | 225 | BScreen::BScreen(ResourceManager &rm, |
222 | const string &screenname, const string &altscreenname, | 226 | const string &screenname, const string &altscreenname, |
223 | int scrn) : ScreenInfo(b, scrn), | 227 | int scrn) : ScreenInfo(scrn), |
224 | m_clientlist_sig(*this), // client signal | 228 | m_clientlist_sig(*this), // client signal |
225 | m_workspacecount_sig(*this), // workspace count signal | 229 | m_workspacecount_sig(*this), // workspace count signal |
226 | m_workspacenames_sig(*this), // workspace names signal | 230 | m_workspacenames_sig(*this), // workspace names signal |
227 | m_currentworkspace_sig(*this), // current workspace signal | 231 | m_currentworkspace_sig(*this), // current workspace signal |
228 | |||
229 | theme(0), | 232 | theme(0), |
230 | resource(rm, screenname, altscreenname) | 233 | resource(rm, screenname, altscreenname) |
231 | { | 234 | { |
232 | fluxbox = b; | ||
233 | 235 | ||
234 | event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask | | 236 | event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask | |
235 | SubstructureRedirectMask | KeyPressMask | KeyReleaseMask | | 237 | SubstructureRedirectMask | KeyPressMask | KeyReleaseMask | |
236 | ButtonPressMask | ButtonReleaseMask| SubstructureNotifyMask; | 238 | ButtonPressMask | ButtonReleaseMask| SubstructureNotifyMask; |
237 | 239 | ||
238 | XErrorHandler old = XSetErrorHandler((XErrorHandler) anotherWMRunning); | 240 | XErrorHandler old = XSetErrorHandler((XErrorHandler) anotherWMRunning); |
239 | XSelectInput(getBaseDisplay()->getXDisplay(), getRootWindow(), event_mask); | 241 | XSelectInput(BaseDisplay::getXDisplay(), getRootWindow(), event_mask); |
240 | XSync(getBaseDisplay()->getXDisplay(), False); | 242 | XSync(BaseDisplay::getXDisplay(), False); |
241 | XSetErrorHandler((XErrorHandler) old); | 243 | XSetErrorHandler((XErrorHandler) old); |
242 | 244 | ||
243 | managed = running; | 245 | managed = running; |
@@ -256,18 +258,18 @@ resource(rm, screenname, altscreenname) | |||
256 | getDepth()); | 258 | getDepth()); |
257 | 259 | ||
258 | rootmenu = 0; | 260 | rootmenu = 0; |
259 | 261 | Fluxbox * const fluxbox = Fluxbox::instance(); | |
260 | #ifdef HAVE_GETPID | 262 | #ifdef HAVE_GETPID |
261 | pid_t bpid = getpid(); | 263 | pid_t bpid = getpid(); |
262 | 264 | ||
263 | XChangeProperty(getBaseDisplay()->getXDisplay(), getRootWindow(), | 265 | XChangeProperty(BaseDisplay::getXDisplay(), getRootWindow(), |
264 | fluxbox->getFluxboxPidAtom(), XA_CARDINAL, | 266 | Fluxbox::instance()->getFluxboxPidAtom(), XA_CARDINAL, |
265 | sizeof(pid_t) * 8, PropModeReplace, | 267 | sizeof(pid_t) * 8, PropModeReplace, |
266 | (unsigned char *) &bpid, 1); | 268 | (unsigned char *) &bpid, 1); |
267 | #endif // HAVE_GETPID | 269 | #endif // HAVE_GETPID |
268 | 270 | ||
269 | 271 | ||
270 | XDefineCursor(getBaseDisplay()->getXDisplay(), getRootWindow(), | 272 | XDefineCursor(BaseDisplay::getXDisplay(), getRootWindow(), |
271 | fluxbox->getSessionCursor()); | 273 | fluxbox->getSessionCursor()); |
272 | 274 | ||
273 | image_control = | 275 | image_control = |
@@ -288,20 +290,7 @@ resource(rm, screenname, altscreenname) | |||
288 | "0: 0000 x 0: 0000"); | 290 | "0: 0000 x 0: 0000"); |
289 | 291 | ||
290 | int l = strlen(s); | 292 | int l = strlen(s); |
291 | /* | ||
292 | if (i18n->multibyte()) { | ||
293 | XRectangle ink, logical; | ||
294 | XmbTextExtents(theme->getWindowStyle().font.set, s, l, &ink, &logical); | ||
295 | geom_w = logical.width; | ||
296 | 293 | ||
297 | geom_h = theme->getWindowStyle().font.set_extents->max_ink_extent.height; | ||
298 | } else { | ||
299 | geom_h = theme->getWindowStyle().font.fontstruct->ascent + | ||
300 | theme->getWindowStyle().font.fontstruct->descent; | ||
301 | |||
302 | geom_w = XTextWidth(theme->getWindowStyle().font.fontstruct, s, l); | ||
303 | } | ||
304 | */ | ||
305 | geom_h = theme->getWindowStyle().font.height(); | 294 | geom_h = theme->getWindowStyle().font.height(); |
306 | geom_w = theme->getWindowStyle().font.textWidth(s, l); | 295 | geom_w = theme->getWindowStyle().font.textWidth(s, l); |
307 | 296 | ||
@@ -347,7 +336,7 @@ resource(rm, screenname, altscreenname) | |||
347 | } | 336 | } |
348 | 337 | ||
349 | workspacemenu = new Workspacemenu(this); | 338 | workspacemenu = new Workspacemenu(this); |
350 | iconmenu = new Iconmenu(this); | 339 | m_iconmenu = new Iconmenu(this); |
351 | configmenu = new Configmenu(this); | 340 | configmenu = new Configmenu(this); |
352 | 341 | ||
353 | Workspace *wkspc = (Workspace *) 0; | 342 | Workspace *wkspc = (Workspace *) 0; |
@@ -367,13 +356,13 @@ resource(rm, screenname, altscreenname) | |||
367 | getMessage( | 356 | getMessage( |
368 | FBNLS::IconSet, FBNLS::IconIcons, | 357 | FBNLS::IconSet, FBNLS::IconIcons, |
369 | "Icons"), | 358 | "Icons"), |
370 | iconmenu); | 359 | m_iconmenu); |
371 | workspacemenu->update(); | 360 | workspacemenu->update(); |
372 | 361 | ||
373 | current_workspace = workspacesList.front(); | 362 | current_workspace = workspacesList.front(); |
374 | workspacemenu->setItemSelected(2, true); | 363 | workspacemenu->setItemSelected(2, true); |
375 | 364 | ||
376 | toolbar = new Toolbar(this); | 365 | m_toolbar.reset(new Toolbar(this)); |
377 | 366 | ||
378 | #ifdef SLIT | 367 | #ifdef SLIT |
379 | slit = new Slit(this); | 368 | slit = new Slit(this); |
@@ -389,7 +378,7 @@ resource(rm, screenname, altscreenname) | |||
389 | slit->reconfigure(); | 378 | slit->reconfigure(); |
390 | #endif // SLIT | 379 | #endif // SLIT |
391 | 380 | ||
392 | 381 | // start with workspace 0 | |
393 | changeWorkspaceID(0); | 382 | changeWorkspaceID(0); |
394 | updateNetizenWorkspaceCount(); | 383 | updateNetizenWorkspaceCount(); |
395 | 384 | ||
@@ -452,7 +441,7 @@ resource(rm, screenname, altscreenname) | |||
452 | } | 441 | } |
453 | 442 | ||
454 | if (! resource.sloppy_focus) | 443 | if (! resource.sloppy_focus) |
455 | XSetInputFocus(getBaseDisplay()->getXDisplay(), toolbar->getWindowID(), | 444 | XSetInputFocus(getBaseDisplay()->getXDisplay(), m_toolbar->getWindowID(), |
456 | RevertToParent, CurrentTime); | 445 | RevertToParent, CurrentTime); |
457 | 446 | ||
458 | XFree(children); | 447 | XFree(children); |
@@ -501,27 +490,30 @@ BScreen::~BScreen() { | |||
501 | 490 | ||
502 | delete rootmenu; | 491 | delete rootmenu; |
503 | delete workspacemenu; | 492 | delete workspacemenu; |
504 | delete iconmenu; | 493 | delete m_iconmenu; |
505 | delete configmenu; | 494 | delete configmenu; |
506 | 495 | ||
507 | #ifdef SLIT | 496 | #ifdef SLIT |
508 | delete slit; | 497 | delete slit; |
509 | #endif // SLIT | 498 | #endif // SLIT |
510 | 499 | ||
511 | delete toolbar; | ||
512 | delete image_control; | 500 | delete image_control; |
513 | 501 | ||
514 | delete theme; | 502 | delete theme; |
515 | 503 | ||
516 | } | 504 | } |
517 | 505 | ||
506 | void BScreen::iconUpdate() { | ||
507 | m_iconmenu->update(); | ||
508 | } | ||
509 | |||
518 | void BScreen::reconfigure() { | 510 | void BScreen::reconfigure() { |
519 | #ifdef DEBUG | 511 | #ifdef DEBUG |
520 | cerr<<__FILE__<<"("<<__LINE__<<"): BScreen::reconfigure"<<endl; | 512 | cerr<<__FILE__<<"("<<__LINE__<<"): BScreen::reconfigure"<<endl; |
521 | #endif // DEBUG | 513 | #endif // DEBUG |
522 | Fluxbox::instance()->loadRootCommand(this); | 514 | Fluxbox::instance()->loadRootCommand(this); |
523 | theme->setRootCommand(getRootCommand()); | 515 | theme->setRootCommand(getRootCommand()); |
524 | theme->load(fluxbox->getStyleFilename()); | 516 | theme->load(Fluxbox::instance()->getStyleFilename()); |
525 | theme->reconfigure(*resource.antialias); | 517 | theme->reconfigure(*resource.antialias); |
526 | 518 | ||
527 | I18n *i18n = I18n::instance(); | 519 | I18n *i18n = I18n::instance(); |
@@ -530,20 +522,7 @@ void BScreen::reconfigure() { | |||
530 | FBNLS::ScreenSet, FBNLS::ScreenPositionLength, | 522 | FBNLS::ScreenSet, FBNLS::ScreenPositionLength, |
531 | "0: 0000 x 0: 0000"); | 523 | "0: 0000 x 0: 0000"); |
532 | int l = strlen(s); | 524 | int l = strlen(s); |
533 | /* | ||
534 | if (i18n->multibyte()) { | ||
535 | XRectangle ink, logical; | ||
536 | XmbTextExtents(theme->getWindowStyle().font.set, s, l, &ink, &logical); | ||
537 | geom_w = logical.width; | ||
538 | |||
539 | geom_h = theme->getWindowStyle().font.set_extents->max_ink_extent.height; | ||
540 | } else { | ||
541 | geom_w = XTextWidth(theme->getWindowStyle().font.fontstruct, s, l); | ||
542 | 525 | ||
543 | geom_h = theme->getWindowStyle().font.fontstruct->ascent + | ||
544 | theme->getWindowStyle().font.fontstruct->descent; | ||
545 | } | ||
546 | */ | ||
547 | //TODO: repeat from somewhere else? | 526 | //TODO: repeat from somewhere else? |
548 | geom_h = theme->getWindowStyle().font.height(); | 527 | geom_h = theme->getWindowStyle().font.height(); |
549 | geom_w = theme->getWindowStyle().font.textWidth(s, l); | 528 | geom_w = theme->getWindowStyle().font.textWidth(s, l); |
@@ -585,7 +564,7 @@ void BScreen::reconfigure() { | |||
585 | 564 | ||
586 | //reconfigure menus | 565 | //reconfigure menus |
587 | workspacemenu->reconfigure(); | 566 | workspacemenu->reconfigure(); |
588 | iconmenu->reconfigure(); | 567 | m_iconmenu->reconfigure(); |
589 | 568 | ||
590 | configmenu->reconfigure(); | 569 | configmenu->reconfigure(); |
591 | 570 | ||
@@ -598,7 +577,7 @@ void BScreen::reconfigure() { | |||
598 | } | 577 | } |
599 | 578 | ||
600 | 579 | ||
601 | toolbar->reconfigure(); | 580 | m_toolbar->reconfigure(); |
602 | 581 | ||
603 | #ifdef SLIT | 582 | #ifdef SLIT |
604 | slit->reconfigure(); | 583 | slit->reconfigure(); |
@@ -648,9 +627,9 @@ void BScreen::addIcon(FluxboxWindow *w) { | |||
648 | 627 | ||
649 | iconList.push_back(w); | 628 | iconList.push_back(w); |
650 | 629 | ||
651 | iconmenu->insert(w->getIconTitle().c_str()); | 630 | m_iconmenu->insert(w->getIconTitle().c_str()); |
652 | iconmenu->update(); | 631 | m_iconmenu->update(); |
653 | toolbar->addIcon(w); | 632 | m_toolbar->addIcon(w); |
654 | } | 633 | } |
655 | 634 | ||
656 | 635 | ||
@@ -669,9 +648,9 @@ void BScreen::removeIcon(FluxboxWindow *w) { | |||
669 | } | 648 | } |
670 | } | 649 | } |
671 | 650 | ||
672 | iconmenu->remove(w->getWindowNumber()); | 651 | m_iconmenu->remove(w->getWindowNumber()); |
673 | iconmenu->update(); | 652 | m_iconmenu->update(); |
674 | toolbar->delIcon(w); | 653 | m_toolbar->delIcon(w); |
675 | 654 | ||
676 | Icons::iterator it = iconList.begin(); | 655 | Icons::iterator it = iconList.begin(); |
677 | Icons::iterator it_end = iconList.end(); | 656 | Icons::iterator it_end = iconList.end(); |
@@ -712,7 +691,7 @@ int BScreen::addWorkspace() { | |||
712 | 691 | ||
713 | workspacemenu->update(); | 692 | workspacemenu->update(); |
714 | saveWorkspaces(workspacesList.size()); | 693 | saveWorkspaces(workspacesList.size()); |
715 | toolbar->reconfigure(); | 694 | m_toolbar->reconfigure(); |
716 | 695 | ||
717 | updateNetizenWorkspaceCount(); | 696 | updateNetizenWorkspaceCount(); |
718 | 697 | ||
@@ -724,29 +703,28 @@ int BScreen::addWorkspace() { | |||
724 | /// removes last workspace | 703 | /// removes last workspace |
725 | /// @return number of desktops left | 704 | /// @return number of desktops left |
726 | int BScreen::removeLastWorkspace() { | 705 | int BScreen::removeLastWorkspace() { |
727 | if (workspacesList.size() > 1) { | 706 | if (workspacesList.size() <= 1) |
728 | Workspace *wkspc = workspacesList.back(); | 707 | return 0; |
708 | Workspace *wkspc = workspacesList.back(); | ||
729 | 709 | ||
730 | if (current_workspace->workspaceID() == wkspc->workspaceID()) | 710 | if (current_workspace->workspaceID() == wkspc->workspaceID()) |
731 | changeWorkspaceID(current_workspace->workspaceID() - 1); | 711 | changeWorkspaceID(current_workspace->workspaceID() - 1); |
732 | 712 | ||
733 | wkspc->removeAll(); | 713 | wkspc->removeAll(); |
734 | 714 | ||
735 | workspacemenu->remove(wkspc->workspaceID()+2); // + 2 is where workspaces starts | 715 | workspacemenu->remove(wkspc->workspaceID()+2); // + 2 is where workspaces starts |
736 | workspacemenu->update(); | 716 | workspacemenu->update(); |
737 | 717 | ||
738 | //remove last workspace | 718 | //remove last workspace |
739 | workspacesList.pop_back(); | 719 | workspacesList.pop_back(); |
740 | delete wkspc; | 720 | delete wkspc; |
741 | 721 | ||
742 | toolbar->reconfigure(); | 722 | m_toolbar->reconfigure(); |
743 | 723 | ||
744 | updateNetizenWorkspaceCount(); | 724 | updateNetizenWorkspaceCount(); |
745 | saveWorkspaces(workspacesList.size()); | 725 | saveWorkspaces(workspacesList.size()); |
746 | return workspacesList.size(); | ||
747 | } | ||
748 | 726 | ||
749 | return 0; | 727 | return workspacesList.size(); |
750 | } | 728 | } |
751 | 729 | ||
752 | 730 | ||
@@ -755,8 +733,8 @@ void BScreen::changeWorkspaceID(unsigned int id) { | |||
755 | return; | 733 | return; |
756 | 734 | ||
757 | if (id != current_workspace->workspaceID()) { | 735 | if (id != current_workspace->workspaceID()) { |
758 | XSync(fluxbox->getXDisplay(), true); | 736 | XSync(BaseDisplay::getXDisplay(), true); |
759 | FluxboxWindow *focused = fluxbox->getFocusedWindow(); | 737 | FluxboxWindow *focused = Fluxbox::instance()->getFocusedWindow(); |
760 | #ifdef DEBUG | 738 | #ifdef DEBUG |
761 | cerr<<__FILE__<<"("<<__FUNCTION__<<"): focused = "<<focused<<endl; | 739 | cerr<<__FILE__<<"("<<__FUNCTION__<<"): focused = "<<focused<<endl; |
762 | #endif // DEBUG | 740 | #endif // DEBUG |
@@ -782,14 +760,14 @@ void BScreen::changeWorkspaceID(unsigned int id) { | |||
782 | if (focused && focused->getScreen() == this && | 760 | if (focused && focused->getScreen() == this && |
783 | (! focused->isStuck()) && (!focused->isMoving())) { | 761 | (! focused->isStuck()) && (!focused->isMoving())) { |
784 | current_workspace->setLastFocusedWindow(focused); | 762 | current_workspace->setLastFocusedWindow(focused); |
785 | fluxbox->setFocusedWindow(0); // set focused window to none | 763 | Fluxbox::instance()->setFocusedWindow(0); // set focused window to none |
786 | } | 764 | } |
787 | 765 | ||
788 | // set new workspace | 766 | // set new workspace |
789 | current_workspace = getWorkspace(id); | 767 | current_workspace = getWorkspace(id); |
790 | 768 | ||
791 | workspacemenu->setItemSelected(current_workspace->workspaceID() + 2, true); | 769 | workspacemenu->setItemSelected(current_workspace->workspaceID() + 2, true); |
792 | toolbar->redrawWorkspaceLabel(true); | 770 | m_toolbar->redrawWorkspaceLabel(true); |
793 | 771 | ||
794 | current_workspace->showAll(); | 772 | current_workspace->showAll(); |
795 | 773 | ||
@@ -815,7 +793,7 @@ void BScreen::sendToWorkspace(unsigned int id, FluxboxWindow *win, bool changeWS | |||
815 | return; | 793 | return; |
816 | 794 | ||
817 | if (!win) | 795 | if (!win) |
818 | win = fluxbox->getFocusedWindow(); | 796 | win = Fluxbox::instance()->getFocusedWindow(); |
819 | 797 | ||
820 | if (id != current_workspace->workspaceID()) { | 798 | if (id != current_workspace->workspaceID()) { |
821 | XSync(BaseDisplay::getXDisplay(), True); | 799 | XSync(BaseDisplay::getXDisplay(), True); |
@@ -867,8 +845,8 @@ void BScreen::addNetizen(Netizen *n) { | |||
867 | } | 845 | } |
868 | } | 846 | } |
869 | 847 | ||
870 | Window f = ((fluxbox->getFocusedWindow()) ? | 848 | Window f = ((Fluxbox::instance()->getFocusedWindow()) ? |
871 | fluxbox->getFocusedWindow()->getClientWindow() : None); | 849 | Fluxbox::instance()->getFocusedWindow()->getClientWindow() : None); |
872 | n->sendWindowFocus(f); | 850 | n->sendWindowFocus(f); |
873 | } | 851 | } |
874 | 852 | ||
@@ -905,13 +883,6 @@ void BScreen::updateNetizenWorkspaceCount() { | |||
905 | for (; it != it_end; ++it) { | 883 | for (; it != it_end; ++it) { |
906 | (*it)->sendWorkspaceCount(); | 884 | (*it)->sendWorkspaceCount(); |
907 | } | 885 | } |
908 | #ifdef NEWWMSPEC | ||
909 | //update _NET_WM_NUMBER_OF_DESKTOPS | ||
910 | int numworkspaces = getCount()-1; | ||
911 | XChangeProperty(getBaseDisplay()->getXDisplay(), getRootWindow(), | ||
912 | getBaseDisplay()->getNETNumberOfDesktopsAtom(), XA_CARDINAL, 32, PropModeReplace, | ||
913 | (unsigned char *)&numworkspaces, 1); | ||
914 | #endif // NEWWMSPEC | ||
915 | 886 | ||
916 | m_workspacecount_sig.notify(); | 887 | m_workspacecount_sig.notify(); |
917 | 888 | ||
@@ -922,8 +893,8 @@ void BScreen::updateNetizenWindowFocus() { | |||
922 | 893 | ||
923 | Netizens::iterator it = netizenList.begin(); | 894 | Netizens::iterator it = netizenList.begin(); |
924 | Netizens::iterator it_end = netizenList.end(); | 895 | Netizens::iterator it_end = netizenList.end(); |
925 | Window f = ((fluxbox->getFocusedWindow()) ? | 896 | Window f = ((Fluxbox::instance()->getFocusedWindow()) ? |
926 | fluxbox->getFocusedWindow()->getClientWindow() : None); | 897 | Fluxbox::instance()->getFocusedWindow()->getClientWindow() : None); |
927 | for (; it != it_end; ++it) { | 898 | for (; it != it_end; ++it) { |
928 | (*it)->sendWindowFocus(f); | 899 | (*it)->sendWindowFocus(f); |
929 | } | 900 | } |
@@ -984,8 +955,8 @@ void BScreen::raiseWindows(const Workspace::Stack &workspace_stack) { | |||
984 | 955 | ||
985 | Window session_stack[(workspace_stack.size() + workspacesList.size() + rootmenuList.size() + 30)]; | 956 | Window session_stack[(workspace_stack.size() + workspacesList.size() + rootmenuList.size() + 30)]; |
986 | int i = 0; | 957 | int i = 0; |
987 | XRaiseWindow(getBaseDisplay()->getXDisplay(), iconmenu->windowID()); | 958 | XRaiseWindow(getBaseDisplay()->getXDisplay(), m_iconmenu->windowID()); |
988 | session_stack[i++] = iconmenu->windowID(); | 959 | session_stack[i++] = m_iconmenu->windowID(); |
989 | 960 | ||
990 | Workspaces::iterator wit = workspacesList.begin(); | 961 | Workspaces::iterator wit = workspacesList.begin(); |
991 | Workspaces::iterator wit_end = workspacesList.end(); | 962 | Workspaces::iterator wit_end = workspacesList.end(); |
@@ -1012,13 +983,13 @@ void BScreen::raiseWindows(const Workspace::Stack &workspace_stack) { | |||
1012 | #endif // SLIT | 983 | #endif // SLIT |
1013 | 984 | ||
1014 | session_stack[i++] = | 985 | session_stack[i++] = |
1015 | toolbar->getMenu()->getPlacementmenu()->windowID(); | 986 | m_toolbar->getMenu()->getPlacementmenu()->windowID(); |
1016 | #ifdef XINERAMA | 987 | #ifdef XINERAMA |
1017 | if (hasXinerama()) { | 988 | if (hasXinerama()) { |
1018 | session_stack[i++] = toolbar->getMenu()->getHeadmenu()->windowID(); | 989 | session_stack[i++] = m_toolbar->getMenu()->getHeadmenu()->windowID(); |
1019 | } | 990 | } |
1020 | #endif // XINERAMA | 991 | #endif // XINERAMA |
1021 | session_stack[i++] = toolbar->getMenu()->windowID(); | 992 | session_stack[i++] = m_toolbar->getMenu()->windowID(); |
1022 | 993 | ||
1023 | Rootmenus::iterator rit = rootmenuList.begin(); | 994 | Rootmenus::iterator rit = rootmenuList.begin(); |
1024 | Rootmenus::iterator rit_end = rootmenuList.end(); | 995 | Rootmenus::iterator rit_end = rootmenuList.end(); |
@@ -1027,8 +998,8 @@ void BScreen::raiseWindows(const Workspace::Stack &workspace_stack) { | |||
1027 | } | 998 | } |
1028 | session_stack[i++] = rootmenu->windowID(); | 999 | session_stack[i++] = rootmenu->windowID(); |
1029 | 1000 | ||
1030 | if (toolbar->isOnTop()) | 1001 | if (m_toolbar->isOnTop()) |
1031 | session_stack[i++] = toolbar->getWindowID(); | 1002 | session_stack[i++] = m_toolbar->getWindowID(); |
1032 | 1003 | ||
1033 | #ifdef SLIT | 1004 | #ifdef SLIT |
1034 | if (slit->isOnTop()) | 1005 | if (slit->isOnTop()) |
@@ -1106,7 +1077,7 @@ void BScreen::reassociateWindow(FluxboxWindow *w, unsigned int wkspc_id, bool ig | |||
1106 | void BScreen::nextFocus(int opts) { | 1077 | void BScreen::nextFocus(int opts) { |
1107 | bool have_focused = false; | 1078 | bool have_focused = false; |
1108 | int focused_window_number = -1; | 1079 | int focused_window_number = -1; |
1109 | FluxboxWindow *focused = fluxbox->getFocusedWindow(); | 1080 | FluxboxWindow *focused = Fluxbox::instance()->getFocusedWindow(); |
1110 | const int num_windows = getCurrentWorkspace()->getCount(); | 1081 | const int num_windows = getCurrentWorkspace()->getCount(); |
1111 | 1082 | ||
1112 | if (focused != 0) { | 1083 | if (focused != 0) { |
@@ -1151,7 +1122,7 @@ void BScreen::prevFocus(int opts) { | |||
1151 | FluxboxWindow *focused; | 1122 | FluxboxWindow *focused; |
1152 | int num_windows = getCurrentWorkspace()->getCount(); | 1123 | int num_windows = getCurrentWorkspace()->getCount(); |
1153 | 1124 | ||
1154 | if ((focused = fluxbox->getFocusedWindow())) { | 1125 | if ((focused = Fluxbox::instance()->getFocusedWindow())) { |
1155 | if (focused->getScreen()->getScreenNumber() == | 1126 | if (focused->getScreen()->getScreenNumber() == |
1156 | getScreenNumber()) { | 1127 | getScreenNumber()) { |
1157 | have_focused = true; | 1128 | have_focused = true; |
@@ -1192,17 +1163,18 @@ void BScreen::prevFocus(int opts) { | |||
1192 | void BScreen::raiseFocus() { | 1163 | void BScreen::raiseFocus() { |
1193 | bool have_focused = false; | 1164 | bool have_focused = false; |
1194 | int focused_window_number = -1; | 1165 | int focused_window_number = -1; |
1195 | 1166 | Fluxbox * const fb = Fluxbox::instance(); | |
1196 | if (fluxbox->getFocusedWindow()) | 1167 | |
1197 | if (fluxbox->getFocusedWindow()->getScreen()->getScreenNumber() == | 1168 | if (fb->getFocusedWindow()) |
1169 | if (fb->getFocusedWindow()->getScreen()->getScreenNumber() == | ||
1198 | getScreenNumber()) { | 1170 | getScreenNumber()) { |
1199 | have_focused = true; | 1171 | have_focused = true; |
1200 | focused_window_number = fluxbox->getFocusedWindow()->getWindowNumber(); | 1172 | focused_window_number = fb->getFocusedWindow()->getWindowNumber(); |
1201 | } | 1173 | } |
1202 | 1174 | ||
1203 | if ((getCurrentWorkspace()->getCount() > 1) && have_focused) | 1175 | if ((getCurrentWorkspace()->getCount() > 1) && have_focused) |
1204 | getWorkspace(fluxbox->getFocusedWindow()->getWorkspaceNumber())-> | 1176 | getWorkspace(fb->getFocusedWindow()->getWorkspaceNumber())-> |
1205 | raiseWindow(fluxbox->getFocusedWindow()); | 1177 | raiseWindow(fb->getFocusedWindow()); |
1206 | } | 1178 | } |
1207 | 1179 | ||
1208 | void BScreen::initMenu() { | 1180 | void BScreen::initMenu() { |
@@ -1217,9 +1189,9 @@ void BScreen::initMenu() { | |||
1217 | rootmenu = new Rootmenu(this); | 1189 | rootmenu = new Rootmenu(this); |
1218 | 1190 | ||
1219 | bool defaultMenu = true; | 1191 | bool defaultMenu = true; |
1220 | 1192 | Fluxbox * const fb = Fluxbox::instance(); | |
1221 | if (fluxbox->getMenuFilename()) { | 1193 | if (fb->getMenuFilename()) { |
1222 | ifstream menu_file(fluxbox->getMenuFilename()); | 1194 | ifstream menu_file(fb->getMenuFilename()); |
1223 | 1195 | ||
1224 | if (!menu_file.fail()) { | 1196 | if (!menu_file.fail()) { |
1225 | if (! menu_file.eof()) { | 1197 | if (! menu_file.eof()) { |
@@ -1250,11 +1222,11 @@ void BScreen::initMenu() { | |||
1250 | i18n->getMessage( | 1222 | i18n->getMessage( |
1251 | FBNLS::ScreenSet, FBNLS::ScreenEmptyMenuFile, | 1223 | FBNLS::ScreenSet, FBNLS::ScreenEmptyMenuFile, |
1252 | "%s: Empty menu file"), | 1224 | "%s: Empty menu file"), |
1253 | fluxbox->getMenuFilename()); | 1225 | fb->getMenuFilename()); |
1254 | } | 1226 | } |
1255 | menu_file.close(); | 1227 | menu_file.close(); |
1256 | } else | 1228 | } else |
1257 | perror(fluxbox->getMenuFilename()); | 1229 | perror(fb->getMenuFilename()); |
1258 | } | 1230 | } |
1259 | 1231 | ||
1260 | if (defaultMenu) { | 1232 | if (defaultMenu) { |
@@ -1275,7 +1247,7 @@ void BScreen::initMenu() { | |||
1275 | "Exit"), | 1247 | "Exit"), |
1276 | BScreen::EXIT); | 1248 | BScreen::EXIT); |
1277 | } else | 1249 | } else |
1278 | fluxbox->saveMenuFilename(fluxbox->getMenuFilename()); | 1250 | fb->saveMenuFilename(fb->getMenuFilename()); |
1279 | } | 1251 | } |
1280 | 1252 | ||
1281 | // looks through a menufile and adds correct items to the root-menu. | 1253 | // looks through a menufile and adds correct items to the root-menu. |
@@ -1397,7 +1369,7 @@ bool BScreen::parseMenuFile(ifstream &file, Rootmenu *menu, int &row) { | |||
1397 | fclose(submenufile); | 1369 | fclose(submenufile); |
1398 | ifstream subfile(newfile.c_str()); | 1370 | ifstream subfile(newfile.c_str()); |
1399 | if (! parseMenuFile(subfile, menu, row)) | 1371 | if (! parseMenuFile(subfile, menu, row)) |
1400 | fluxbox->saveMenuFilename(newfile.c_str()); | 1372 | Fluxbox::instance()->saveMenuFilename(newfile.c_str()); |
1401 | } | 1373 | } |
1402 | } else | 1374 | } else |
1403 | perror(newfile.c_str()); | 1375 | perror(newfile.c_str()); |
@@ -1541,7 +1513,7 @@ void BScreen::createStyleMenu(Rootmenu *menu, bool newmenu, const char *label, c | |||
1541 | rootmenuList.push_back(stylesmenu); | 1513 | rootmenuList.push_back(stylesmenu); |
1542 | } | 1514 | } |
1543 | 1515 | ||
1544 | fluxbox->saveMenuFilename(stylesdir.c_str()); | 1516 | Fluxbox::instance()->saveMenuFilename(stylesdir.c_str()); |
1545 | } else { // dir | 1517 | } else { // dir |
1546 | fprintf(stderr, | 1518 | fprintf(stderr, |
1547 | i18n-> | 1519 | i18n-> |
@@ -1563,8 +1535,6 @@ void BScreen::createStyleMenu(Rootmenu *menu, bool newmenu, const char *label, c | |||
1563 | } | 1535 | } |
1564 | 1536 | ||
1565 | void BScreen::shutdown() { | 1537 | void BScreen::shutdown() { |
1566 | fluxbox->grab(); | ||
1567 | |||
1568 | XSelectInput(getBaseDisplay()->getXDisplay(), getRootWindow(), NoEventMask); | 1538 | XSelectInput(getBaseDisplay()->getXDisplay(), getRootWindow(), NoEventMask); |
1569 | XSync(getBaseDisplay()->getXDisplay(), False); | 1539 | XSync(getBaseDisplay()->getXDisplay(), False); |
1570 | 1540 | ||
@@ -1587,7 +1557,6 @@ void BScreen::shutdown() { | |||
1587 | slit->shutdown(); | 1557 | slit->shutdown(); |
1588 | #endif // SLIT | 1558 | #endif // SLIT |
1589 | 1559 | ||
1590 | fluxbox->ungrab(); | ||
1591 | } | 1560 | } |
1592 | 1561 | ||
1593 | 1562 | ||
@@ -1619,27 +1588,14 @@ void BScreen::showPosition(int x, int y) { | |||
1619 | "X: %4d x Y: %4d"), x, y); | 1588 | "X: %4d x Y: %4d"), x, y); |
1620 | 1589 | ||
1621 | XClearWindow(getBaseDisplay()->getXDisplay(), geom_window); | 1590 | XClearWindow(getBaseDisplay()->getXDisplay(), geom_window); |
1622 | /* | 1591 | |
1623 | if (I18n::instance()->multibyte()) | ||
1624 | XmbDrawString(getBaseDisplay()->getXDisplay(), geom_window, | ||
1625 | theme->getWindowStyle().font.set, theme->getWindowStyle().l_text_focus_gc, | ||
1626 | theme->getBevelWidth(), theme->getBevelWidth() - | ||
1627 | theme->getWindowStyle().font.set_extents->max_ink_extent.y, | ||
1628 | label, strlen(label)); | ||
1629 | else | ||
1630 | XDrawString(getBaseDisplay()->getXDisplay(), geom_window, | ||
1631 | theme->getWindowStyle().l_text_focus_gc, | ||
1632 | theme->getBevelWidth(), | ||
1633 | theme->getWindowStyle().font.fontstruct->ascent + | ||
1634 | theme->getBevelWidth(), label, strlen(label)); | ||
1635 | */ | ||
1636 | theme->getWindowStyle().font.drawText( | 1592 | theme->getWindowStyle().font.drawText( |
1637 | geom_window, | 1593 | geom_window, |
1638 | getScreenNumber(), | 1594 | getScreenNumber(), |
1639 | theme->getWindowStyle().l_text_focus_gc, | 1595 | theme->getWindowStyle().l_text_focus_gc, |
1640 | label, strlen(label), | 1596 | label, strlen(label), |
1641 | theme->getBevelWidth(), theme->getBevelWidth() + | 1597 | theme->getBevelWidth(), theme->getBevelWidth() + |
1642 | theme->getWindowStyle().font.height()); | 1598 | theme->getWindowStyle().font.ascent()); |
1643 | 1599 | ||
1644 | } | 1600 | } |
1645 | 1601 | ||