aboutsummaryrefslogtreecommitdiff
path: root/src/Screen.cc
diff options
context:
space:
mode:
authorMathias Gumz <akira@fluxbox.org>2015-01-22 15:28:53 (GMT)
committerMathias Gumz <akira@fluxbox.org>2015-01-22 15:28:53 (GMT)
commitab2eef49371b2c9e45efea128fc84f3d556d1901 (patch)
tree4054a47639da3cf7ac262b1122110d38cb3aad41 /src/Screen.cc
parent3cda1099e265fd8d08bf5f19a0cbd15d6ad5f0d3 (diff)
downloadfluxbox-ab2eef49371b2c9e45efea128fc84f3d556d1901.zip
fluxbox-ab2eef49371b2c9e45efea128fc84f3d556d1901.tar.bz2
Add -no-slit and -no-toolbar flags
Sometimes fluxbox is used as a component of a desktop environment ( e.g., the "Lumina Desktop"). It's easier and more stable for this kind of "users" to disable the toolbar or the slit alltogether. Why not configure these features out? Because then they would need 2 installations of fluxbox: One without the slit and the toolbar (and perhaps other components) and one with them. This implements feature request #314, at least partially. This commit also looks bigger than it actually is: I refactored and cleaned up classes Fluxbox and BScreen.
Diffstat (limited to 'src/Screen.cc')
-rw-r--r--src/Screen.cc109
1 files changed, 56 insertions, 53 deletions
diff --git a/src/Screen.cc b/src/Screen.cc
index 5e6f38e..da4e719 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -189,7 +189,8 @@ void initAtoms(Display* dpy) {
189BScreen::BScreen(FbTk::ResourceManager &rm, 189BScreen::BScreen(FbTk::ResourceManager &rm,
190 const string &screenname, 190 const string &screenname,
191 const string &altscreenname, 191 const string &altscreenname,
192 int scrn, int num_layers) : 192 int scrn, int num_layers,
193 unsigned int opts) :
193 m_layermanager(num_layers), 194 m_layermanager(num_layers),
194 root_colormap_installed(false), 195 root_colormap_installed(false),
195 m_image_control(0), 196 m_image_control(0),
@@ -214,19 +215,20 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
214 m_altname(altscreenname), 215 m_altname(altscreenname),
215 m_focus_control(new FocusControl(*this)), 216 m_focus_control(new FocusControl(*this)),
216 m_placement_strategy(new ScreenPlacement(*this)), 217 m_placement_strategy(new ScreenPlacement(*this)),
217 m_cycling(false), m_cycle_opts(0), 218 m_cycle_opts(0),
218 m_restart(false), 219 m_opts(opts) {
219 m_shutdown(false) {
220 220
221 221
222 m_state.cycling = false;
223 m_state.restart = false;
224 m_state.shutdown = false;
225 m_state.managed = false;
226
222 Fluxbox *fluxbox = Fluxbox::instance(); 227 Fluxbox *fluxbox = Fluxbox::instance();
223 Display *disp = fluxbox->display(); 228 Display *disp = fluxbox->display();
224 229
225 initAtoms(disp); 230 initAtoms(disp);
226 231
227
228 // TODO fluxgen: check if this is the right place (it was not -lis)
229 //
230 // Create the first one, initXinerama will expand this if needed. 232 // Create the first one, initXinerama will expand this if needed.
231 m_head_areas.resize(1); 233 m_head_areas.resize(1);
232 m_head_areas[0] = new HeadArea(); 234 m_head_areas[0] = new HeadArea();
@@ -244,8 +246,8 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
244 246
245 XSetErrorHandler((XErrorHandler) old); 247 XSetErrorHandler((XErrorHandler) old);
246 248
247 managed = running; 249 m_state.managed = running;
248 if (! managed) { 250 if (!m_state.managed) {
249 delete m_placement_strategy; m_placement_strategy = 0; 251 delete m_placement_strategy; m_placement_strategy = 0;
250 delete m_focus_control; m_focus_control = 0; 252 delete m_focus_control; m_focus_control = 0;
251 return; 253 return;
@@ -261,14 +263,12 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
261#endif // HAVE_GETPID 263#endif // HAVE_GETPID
262 264
263 // check if we're the first EWMH compliant window manager on this screen 265 // check if we're the first EWMH compliant window manager on this screen
264 Atom xa_ret_type; 266 union { Atom atom; unsigned long ul; int i; } ignore;
265 int ret_format;
266 unsigned long ret_nitems, ret_bytes_after;
267 unsigned char *ret_prop; 267 unsigned char *ret_prop;
268 if (rootWindow().property(atom_wm_check, 0l, 1l, 268 if (rootWindow().property(atom_wm_check, 0l, 1l,
269 False, XA_WINDOW, &xa_ret_type, &ret_format, &ret_nitems, 269 False, XA_WINDOW, &ignore.atom, &ignore.i, &ignore.ul,
270 &ret_bytes_after, &ret_prop) ) { 270 &ignore.ul, &ret_prop) ) {
271 m_restart = (ret_prop != NULL); 271 m_state.restart = (ret_prop != NULL);
272 XFree(ret_prop); 272 XFree(ret_prop);
273 } 273 }
274 274
@@ -362,7 +362,7 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
362 362
363 // check which desktop we should start on 363 // check which desktop we should start on
364 int first_desktop = 0; 364 int first_desktop = 0;
365 if (m_restart) { 365 if (m_state.restart) {
366 bool exists; 366 bool exists;
367 int ret = (rootWindow().cardinalProperty(atom_net_desktop, &exists)); 367 int ret = (rootWindow().cardinalProperty(atom_net_desktop, &exists));
368 if (exists) { 368 if (exists) {
@@ -373,8 +373,10 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
373 changeWorkspaceID(first_desktop); 373 changeWorkspaceID(first_desktop);
374 374
375#ifdef USE_SLIT 375#ifdef USE_SLIT
376 m_slit.reset(new Slit(*this, *layerManager().getLayer(ResourceLayer::DESKTOP), 376 if (opts & Fluxbox::OPT_SLIT) {
377 fluxbox->getSlitlistFilename().c_str())); 377 Slit* slit = new Slit(*this, *layerManager().getLayer(ResourceLayer::DESKTOP), fluxbox->getSlitlistFilename().c_str());
378 m_slit.reset(slit);
379 }
378#endif // USE_SLIT 380#endif // USE_SLIT
379 381
380 rm.unlock(); 382 rm.unlock();
@@ -386,7 +388,7 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
386 388
387BScreen::~BScreen() { 389BScreen::~BScreen() {
388 390
389 if (! managed) 391 if (!m_state.managed)
390 return; 392 return;
391 393
392 m_toolbar.reset(0); 394 m_toolbar.reset(0);
@@ -445,19 +447,23 @@ BScreen::~BScreen() {
445} 447}
446 448
447bool BScreen::isRestart() { 449bool BScreen::isRestart() {
448 return Fluxbox::instance()->isStartup() && m_restart; 450 return Fluxbox::instance()->isStartup() && m_state.restart;
449} 451}
450 452
451void BScreen::initWindows() { 453void BScreen::initWindows() {
452 454
453#ifdef USE_TOOLBAR 455#ifdef USE_TOOLBAR
454 m_toolbar.reset(new Toolbar(*this, 456 if (m_opts & Fluxbox::OPT_TOOLBAR) {
455 *layerManager().getLayer(::ResourceLayer::NORMAL))); 457 Toolbar* tb = new Toolbar(*this, *layerManager().getLayer(::ResourceLayer::NORMAL));
458 m_toolbar.reset(tb);
459 }
456#endif // USE_TOOLBAR 460#endif // USE_TOOLBAR
457 461
458 unsigned int nchild; 462 unsigned int nchild;
459 Window r, p, *children; 463 Window r, p, *children;
460 Display *disp = FbTk::App::instance()->display(); 464 Fluxbox* fluxbox = Fluxbox::instance();
465 Display* disp = fluxbox->display();
466
461 XQueryTree(disp, rootWindow().window(), &r, &p, &children, &nchild); 467 XQueryTree(disp, rootWindow().window(), &r, &p, &children, &nchild);
462 468
463 // preen the window list of all icon windows... for better dockapp support 469 // preen the window list of all icon windows... for better dockapp support
@@ -483,10 +489,8 @@ void BScreen::initWindows() {
483 } 489 }
484 XFree(wmhints); 490 XFree(wmhints);
485 } 491 }
486
487 } 492 }
488 493
489 Fluxbox *fluxbox = Fluxbox::instance();
490 494
491 // manage shown windows 495 // manage shown windows
492 Window transient_for = 0; 496 Window transient_for = 0;
@@ -611,8 +615,8 @@ void BScreen::focusedWinFrameThemeReconfigured() {
611 Fluxbox *fluxbox = Fluxbox::instance(); 615 Fluxbox *fluxbox = Fluxbox::instance();
612 const std::list<Focusable *> winlist = 616 const std::list<Focusable *> winlist =
613 focusControl().focusedOrderWinList().clientList(); 617 focusControl().focusedOrderWinList().clientList();
614 std::list<Focusable *>::const_iterator it = winlist.begin(), 618 std::list<Focusable *>::const_iterator it = winlist.begin();
615 it_end = winlist.end(); 619 std::list<Focusable *>::const_iterator it_end = winlist.end();
616 for (; it != it_end; ++it) 620 for (; it != it_end; ++it)
617 fluxbox->updateFrameExtents(*(*it)->fbwindow()); 621 fluxbox->updateFrameExtents(*(*it)->fbwindow());
618 622
@@ -661,14 +665,15 @@ void BScreen::keyPressEvent(XKeyEvent &ke) {
661} 665}
662 666
663void BScreen::keyReleaseEvent(XKeyEvent &ke) { 667void BScreen::keyReleaseEvent(XKeyEvent &ke) {
664 if (m_cycling) { 668 if (m_state.cycling) {
669
665 unsigned int state = FbTk::KeyUtil::instance().cleanMods(ke.state); 670 unsigned int state = FbTk::KeyUtil::instance().cleanMods(ke.state);
666 state &= ~FbTk::KeyUtil::instance().keycodeToModmask(ke.keycode); 671 state &= ~FbTk::KeyUtil::instance().keycodeToModmask(ke.keycode);
667 672
668 if (state) // still cycling 673 if (state) // still cycling
669 return; 674 return;
670 675
671 m_cycling = false; 676 m_state.cycling = false;
672 focusControl().stopCyclingFocus(); 677 focusControl().stopCyclingFocus();
673 } 678 }
674 if (!Fluxbox::instance()->keys()->inKeychain()) 679 if (!Fluxbox::instance()->keys()->inKeychain())
@@ -693,8 +698,8 @@ void BScreen::cycleFocus(int options, const ClientPattern *pat, bool reverse) {
693 else if (ev.type == ButtonPress) 698 else if (ev.type == ButtonPress)
694 mods = FbTk::KeyUtil::instance().cleanMods(ev.xbutton.state); 699 mods = FbTk::KeyUtil::instance().cleanMods(ev.xbutton.state);
695 700
696 if (!m_cycling && mods) { 701 if (!m_state.cycling && mods) {
697 m_cycling = true; 702 m_state.cycling = true;
698 FbTk::EventManager::instance()->grabKeyboard(rootWindow().window()); 703 FbTk::EventManager::instance()->grabKeyboard(rootWindow().window());
699 } 704 }
700 705
@@ -849,13 +854,12 @@ void BScreen::removeClient(WinClient &client) {
849int BScreen::addWorkspace() { 854int BScreen::addWorkspace() {
850 855
851 bool save_name = getNameOfWorkspace(m_workspaces_list.size()) == ""; 856 bool save_name = getNameOfWorkspace(m_workspaces_list.size()) == "";
852 Workspace *wkspc = new Workspace(*this, 857 std::string name = getNameOfWorkspace(m_workspaces_list.size());
853 getNameOfWorkspace(m_workspaces_list.size()), 858 Workspace *ws = new Workspace(*this, name, m_workspaces_list.size());
854 m_workspaces_list.size()); 859 m_workspaces_list.push_back(ws);
855 m_workspaces_list.push_back(wkspc);
856 860
857 if (save_name) { 861 if (save_name) {
858 addWorkspaceName(wkspc->name().c_str()); 862 addWorkspaceName(ws->name().c_str());
859 m_workspacenames_sig.emit(*this); 863 m_workspacenames_sig.emit(*this);
860 } 864 }
861 865
@@ -1065,7 +1069,9 @@ bool BScreen::addKdeDockapp(Window client) {
1065} 1069}
1066 1070
1067FluxboxWindow *BScreen::createWindow(Window client) { 1071FluxboxWindow *BScreen::createWindow(Window client) {
1068 FbTk::App::instance()->sync(false); 1072
1073 Fluxbox* fluxbox = Fluxbox::instance();
1074 fluxbox->sync(false);
1069 1075
1070 if (isKdeDockapp(client) && addKdeDockapp(client)) { 1076 if (isKdeDockapp(client) && addKdeDockapp(client)) {
1071 return 0; // dont create a FluxboxWindow for this one 1077 return 0; // dont create a FluxboxWindow for this one
@@ -1084,14 +1090,14 @@ FluxboxWindow *BScreen::createWindow(Window client) {
1084 } 1090 }
1085 1091
1086 // check if it should be grouped with something else 1092 // check if it should be grouped with something else
1087 FluxboxWindow *win; 1093 WinClient* other = findGroupLeft(*winclient);
1088 WinClient *other; 1094 FluxboxWindow* win = other ? other->fbwindow() : 0;
1089 if ((other = findGroupLeft(*winclient)) && (win = other->fbwindow())) { 1095
1096 if (other && win) {
1090 win->attachClient(*winclient); 1097 win->attachClient(*winclient);
1091 Fluxbox::instance()->attachSignals(*winclient); 1098 fluxbox->attachSignals(*winclient);
1092 } else { 1099 } else {
1093 1100 fluxbox->attachSignals(*winclient);
1094 Fluxbox::instance()->attachSignals(*winclient);
1095 if (winclient->fbwindow()) { // may have been set in an atomhandler 1101 if (winclient->fbwindow()) { // may have been set in an atomhandler
1096 win = winclient->fbwindow(); 1102 win = winclient->fbwindow();
1097 Workspace *workspace = getWorkspace(win->workspaceNumber()); 1103 Workspace *workspace = getWorkspace(win->workspaceNumber());
@@ -1109,7 +1115,7 @@ FluxboxWindow *BScreen::createWindow(Window client) {
1109 1115
1110 // add the window to the focus list 1116 // add the window to the focus list
1111 // always add to front on startup to keep the focus order the same 1117 // always add to front on startup to keep the focus order the same
1112 if (win->isFocused() || Fluxbox::instance()->isStartup()) 1118 if (win->isFocused() || fluxbox->isStartup())
1113 focusControl().addFocusFront(*winclient); 1119 focusControl().addFocusFront(*winclient);
1114 else 1120 else
1115 focusControl().addFocusBack(*winclient); 1121 focusControl().addFocusBack(*winclient);
@@ -1123,7 +1129,7 @@ FluxboxWindow *BScreen::createWindow(Window client) {
1123 1129
1124 m_clientlist_sig.emit(*this); 1130 m_clientlist_sig.emit(*this);
1125 1131
1126 FbTk::App::instance()->sync(false); 1132 fluxbox->sync(false);
1127 return win; 1133 return win;
1128} 1134}
1129 1135
@@ -1386,7 +1392,7 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) {
1386void BScreen::shutdown() { 1392void BScreen::shutdown() {
1387 rootWindow().setEventMask(NoEventMask); 1393 rootWindow().setEventMask(NoEventMask);
1388 FbTk::App::instance()->sync(false); 1394 FbTk::App::instance()->sync(false);
1389 m_shutdown = true; 1395 m_state.shutdown = true;
1390 m_focus_control->shutdown(); 1396 m_focus_control->shutdown();
1391 for_each(m_workspaces_list.begin(), 1397 for_each(m_workspaces_list.begin(),
1392 m_workspaces_list.end(), 1398 m_workspaces_list.end(),
@@ -1701,15 +1707,12 @@ int BScreen::getCurrHead() const {
1701 if (!hasXinerama()) return 0; 1707 if (!hasXinerama()) return 0;
1702 int root_x = 0, root_y = 0; 1708 int root_x = 0, root_y = 0;
1703#ifdef XINERAMA 1709#ifdef XINERAMA
1704 int ignore_i; 1710 union { int i; unsigned int ui; Window w; } ignore;
1705 unsigned int ignore_ui;
1706
1707 Window ignore_w;
1708 1711
1709 XQueryPointer(FbTk::App::instance()->display(), 1712 XQueryPointer(FbTk::App::instance()->display(),
1710 rootWindow().window(), &ignore_w, 1713 rootWindow().window(), &ignore.w,
1711 &ignore_w, &root_x, &root_y, 1714 &ignore.w, &root_x, &root_y,
1712 &ignore_i, &ignore_i, &ignore_ui); 1715 &ignore.i, &ignore.i, &ignore.ui);
1713#endif // XINERAMA 1716#endif // XINERAMA
1714 return getHead(root_x, root_y); 1717 return getHead(root_x, root_y);
1715} 1718}