aboutsummaryrefslogtreecommitdiff
path: root/src/fluxbox.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/fluxbox.cc')
-rw-r--r--src/fluxbox.cc71
1 files changed, 45 insertions, 26 deletions
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index 471f46a..3d9cc58 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -42,7 +42,6 @@
42#include "FbTk/I18n.hh" 42#include "FbTk/I18n.hh"
43#include "FbTk/Image.hh" 43#include "FbTk/Image.hh"
44#include "FbTk/FileUtil.hh" 44#include "FbTk/FileUtil.hh"
45#include "FbTk/KeyUtil.hh"
46#include "FbTk/ImageControl.hh" 45#include "FbTk/ImageControl.hh"
47#include "FbTk/EventManager.hh" 46#include "FbTk/EventManager.hh"
48#include "FbTk/StringUtil.hh" 47#include "FbTk/StringUtil.hh"
@@ -56,6 +55,7 @@
56#include "FbTk/Transparent.hh" 55#include "FbTk/Transparent.hh"
57#include "FbTk/Select2nd.hh" 56#include "FbTk/Select2nd.hh"
58#include "FbTk/Compose.hh" 57#include "FbTk/Compose.hh"
58#include "FbTk/KeyUtil.hh"
59 59
60//Use GNU extensions 60//Use GNU extensions
61#ifndef _GNU_SOURCE 61#ifndef _GNU_SOURCE
@@ -160,8 +160,8 @@ using namespace FbTk;
160namespace { 160namespace {
161 161
162Window last_bad_window = None; 162Window last_bad_window = None;
163 163
164// *** NOTE: if you want to debug here the X errors are 164// *** NOTE: if you want to debug here the X errors are
165// coming from, you should turn on the XSynchronise call below 165// coming from, you should turn on the XSynchronise call below
166int handleXErrors(Display *d, XErrorEvent *e) { 166int handleXErrors(Display *d, XErrorEvent *e) {
167 if (e->error_code == BadWindow) 167 if (e->error_code == BadWindow)
@@ -215,7 +215,7 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile
215 m_rc_cache_life(m_resourcemanager, 5, "session.cacheLife", "Session.CacheLife"), 215 m_rc_cache_life(m_resourcemanager, 5, "session.cacheLife", "Session.CacheLife"),
216 m_rc_cache_max(m_resourcemanager, 200, "session.cacheMax", "Session.CacheMax"), 216 m_rc_cache_max(m_resourcemanager, 200, "session.cacheMax", "Session.CacheMax"),
217 m_rc_auto_raise_delay(m_resourcemanager, 250, "session.autoRaiseDelay", "Session.AutoRaiseDelay"), 217 m_rc_auto_raise_delay(m_resourcemanager, 250, "session.autoRaiseDelay", "Session.AutoRaiseDelay"),
218 m_rc_use_mod1(m_resourcemanager, true, "session.useMod1", "Session.UseMod1"), 218 m_rc_mod_key(m_resourcemanager, "Mod1", "session.modKey", "Session.ModKey"),
219 m_masked_window(0), 219 m_masked_window(0),
220 m_mousescreen(0), 220 m_mousescreen(0),
221 m_keyscreen(0), 221 m_keyscreen(0),
@@ -347,7 +347,7 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile
347 vector<int> scrtmp; 347 vector<int> scrtmp;
348 int scrnr = 0; 348 int scrnr = 0;
349 FbTk::StringUtil::stringtok(vals, m_argv[i], ",:"); 349 FbTk::StringUtil::stringtok(vals, m_argv[i], ",:");
350 for (vector<string>::iterator scrit = vals.begin(); 350 for (vector<string>::iterator scrit = vals.begin();
351 scrit != vals.end(); scrit++) { 351 scrit != vals.end(); scrit++) {
352 scrnr = atoi(scrit->c_str()); 352 scrnr = atoi(scrit->c_str());
353 if (scrnr >= 0 && scrnr < ScreenCount(disp)) 353 if (scrnr >= 0 && scrnr < ScreenCount(disp))
@@ -358,17 +358,17 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile
358 swap(scrtmp, screens); 358 swap(scrtmp, screens);
359 } 359 }
360 } 360 }
361 361
362 // init all "screens" 362 // init all "screens"
363 for(size_t s = 0; s < screens.size(); s++) 363 for(size_t s = 0; s < screens.size(); s++)
364 initScreen(screens[s]); 364 initScreen(screens[s]);
365 365
366 XAllowEvents(disp, ReplayPointer, CurrentTime); 366 XAllowEvents(disp, ReplayPointer, CurrentTime);
367 367
368 368
369 if (m_screen_list.empty()) { 369 if (m_screen_list.empty()) {
370 throw _FB_CONSOLETEXT(Fluxbox, ErrorNoScreens, 370 throw _FB_CONSOLETEXT(Fluxbox, ErrorNoScreens,
371 "Couldn't find screens to manage.\nMake sure you don't have another window manager running.", 371 "Couldn't find screens to manage.\nMake sure you don't have another window manager running.",
372 "Error message when no unmanaged screens found - usually means another window manager is running"); 372 "Error message when no unmanaged screens found - usually means another window manager is running");
373 } 373 }
374 374
@@ -388,7 +388,7 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile
388 388
389 m_resourcemanager.unlock(); 389 m_resourcemanager.unlock();
390 ungrab(); 390 ungrab();
391 391
392#ifdef DEBUG 392#ifdef DEBUG
393 if (m_resourcemanager.lockDepth() != 0) 393 if (m_resourcemanager.lockDepth() != 0)
394 cerr<<"--- resource manager lockdepth = "<<m_resourcemanager.lockDepth()<<endl; 394 cerr<<"--- resource manager lockdepth = "<<m_resourcemanager.lockDepth()<<endl;
@@ -439,7 +439,7 @@ Fluxbox::~Fluxbox() {
439 439
440 440
441int Fluxbox::initScreen(int scrnr) { 441int Fluxbox::initScreen(int scrnr) {
442 442
443 Display* disp = display(); 443 Display* disp = display();
444 char scrname[128], altscrname[128]; 444 char scrname[128], altscrname[128];
445 sprintf(scrname, "session.screen%d", scrnr); 445 sprintf(scrname, "session.screen%d", scrnr);
@@ -453,7 +453,7 @@ int Fluxbox::initScreen(int scrnr) {
453 delete screen; 453 delete screen;
454 return 0; 454 return 0;
455 } 455 }
456 456
457 // add to our list 457 // add to our list
458 m_screen_list.push_back(screen); 458 m_screen_list.push_back(screen);
459 459
@@ -595,8 +595,8 @@ void Fluxbox::setupConfigFiles() {
595 // create directory with perm 700 595 // create directory with perm 700
596 if (mkdir(dirname.c_str(), 0700)) { 596 if (mkdir(dirname.c_str(), 0700)) {
597 fprintf(stderr, _FB_CONSOLETEXT(Fluxbox, ErrorCreatingDirectory, 597 fprintf(stderr, _FB_CONSOLETEXT(Fluxbox, ErrorCreatingDirectory,
598 "Can't create %s directory", 598 "Can't create %s directory",
599 "Can't create a directory, one %s for directory name").c_str(), 599 "Can't create a directory, one %s for directory name").c_str(),
600 dirname.c_str()); 600 dirname.c_str());
601 cerr<<endl; 601 cerr<<endl;
602 return; 602 return;
@@ -658,7 +658,7 @@ void Fluxbox::handleEvent(XEvent * const e) {
658 } else if (e->type == PropertyNotify) { 658 } else if (e->type == PropertyNotify) {
659 m_last_time = e->xproperty.time; 659 m_last_time = e->xproperty.time;
660 // check transparency atoms if it's a root pm 660 // check transparency atoms if it's a root pm
661 661
662 BScreen *screen = searchScreen(e->xproperty.window); 662 BScreen *screen = searchScreen(e->xproperty.window);
663 if (screen) { 663 if (screen) {
664 FbTk::FbPixmap::rootwinPropertyNotify(screen->screenNumber(), e->xproperty.atom); 664 FbTk::FbPixmap::rootwinPropertyNotify(screen->screenNumber(), e->xproperty.atom);
@@ -966,7 +966,7 @@ void Fluxbox::handleButtonEvent(XButtonEvent &be) {
966void Fluxbox::handleUnmapNotify(XUnmapEvent &ue) { 966void Fluxbox::handleUnmapNotify(XUnmapEvent &ue) {
967 967
968 BScreen *screen = searchScreen(ue.event); 968 BScreen *screen = searchScreen(ue.event);
969 969
970 if (ue.event != ue.window && (!screen || !ue.send_event)) { 970 if (ue.event != ue.window && (!screen || !ue.send_event)) {
971 return; 971 return;
972 } 972 }
@@ -996,7 +996,7 @@ void Fluxbox::handleUnmapNotify(XUnmapEvent &ue) {
996 } 996 }
997 997
998 // according to http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.4 998 // according to http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.4
999 // a XWithdrawWindow is 999 // a XWithdrawWindow is
1000 // 1) unmapping the window (which leads to the upper branch 1000 // 1) unmapping the window (which leads to the upper branch
1001 // 2) sends an synthetic unampevent (which is handled below) 1001 // 2) sends an synthetic unampevent (which is handled below)
1002 } else if (screen && ue.send_event) { 1002 } else if (screen && ue.send_event) {
@@ -1108,7 +1108,7 @@ void Fluxbox::handleKeyEvent(XKeyEvent &ke) {
1108 // won't mask anything if it isn't a mod 1108 // won't mask anything if it isn't a mod
1109 unsigned int state = FbTk::KeyUtil::instance().isolateModifierMask(ke.state); 1109 unsigned int state = FbTk::KeyUtil::instance().isolateModifierMask(ke.state);
1110 state &= ~FbTk::KeyUtil::instance().keycodeToModmask(ke.keycode); 1110 state &= ~FbTk::KeyUtil::instance().keycodeToModmask(ke.keycode);
1111 1111
1112 if ((m_watch_keyrelease & state) == 0) { 1112 if ((m_watch_keyrelease & state) == 0) {
1113 1113
1114 m_watching_screen->notifyReleasedKeys(ke); 1114 m_watching_screen->notifyReleasedKeys(ke);
@@ -1217,7 +1217,7 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
1217 (*it).first->updateLayer(win); 1217 (*it).first->updateLayer(win);
1218 } 1218 }
1219 } else if ((&(win.dieSig())) == changedsub) { // window death signal 1219 } else if ((&(win.dieSig())) == changedsub) { // window death signal
1220 1220
1221 for (AtomHandlerContainerIt it= m_atomhandler.begin(); 1221 for (AtomHandlerContainerIt it= m_atomhandler.begin();
1222 it != m_atomhandler.end(); ++it) { 1222 it != m_atomhandler.end(); ++it) {
1223 if ((*it).first->update()) 1223 if ((*it).first->update())
@@ -1585,7 +1585,7 @@ void Fluxbox::load_rc(BScreen &screen) {
1585 1585
1586 string values(value.addr); 1586 string values(value.addr);
1587 BScreen::WorkspaceNames names; 1587 BScreen::WorkspaceNames names;
1588 1588
1589 StringUtil::removeTrailingWhitespace(values); 1589 StringUtil::removeTrailingWhitespace(values);
1590 StringUtil::removeFirstWhitespace(values); 1590 StringUtil::removeFirstWhitespace(values);
1591 StringUtil::stringtok<BScreen::WorkspaceNames>(names, values, ","); 1591 StringUtil::stringtok<BScreen::WorkspaceNames>(names, values, ",");
@@ -1703,7 +1703,7 @@ bool Fluxbox::menuTimestampsChanged() const {
1703 std::list<MenuTimestamp *>::const_iterator it = m_menu_timestamps.begin(); 1703 std::list<MenuTimestamp *>::const_iterator it = m_menu_timestamps.begin();
1704 std::list<MenuTimestamp *>::const_iterator it_end = m_menu_timestamps.end(); 1704 std::list<MenuTimestamp *>::const_iterator it_end = m_menu_timestamps.end();
1705 for (; it != it_end; ++it) { 1705 for (; it != it_end; ++it) {
1706 1706
1707 time_t timestamp = FbTk::FileUtil::getLastStatusChangeTimestamp((*it)->filename.c_str()); 1707 time_t timestamp = FbTk::FileUtil::getLastStatusChangeTimestamp((*it)->filename.c_str());
1708 1708
1709 if (timestamp >= 0) { 1709 if (timestamp >= 0) {
@@ -1743,11 +1743,11 @@ void Fluxbox::rereadMenu(bool show_after_reread) {
1743 1743
1744 1744
1745void Fluxbox::real_rereadMenu() { 1745void Fluxbox::real_rereadMenu() {
1746 1746
1747 clearMenuFilenames(); 1747 clearMenuFilenames();
1748 1748
1749 for_each(m_screen_list.begin(), 1749 for_each(m_screen_list.begin(),
1750 m_screen_list.end(), 1750 m_screen_list.end(),
1751 mem_fun(&BScreen::rereadMenu)); 1751 mem_fun(&BScreen::rereadMenu));
1752 1752
1753 if(m_show_menu_after_reread) { 1753 if(m_show_menu_after_reread) {
@@ -1806,7 +1806,7 @@ void Fluxbox::timed_reconfigure() {
1806} 1806}
1807 1807
1808bool Fluxbox::validateClient(const WinClient *client) const { 1808bool Fluxbox::validateClient(const WinClient *client) const {
1809 WinClientMap::const_iterator it = 1809 WinClientMap::const_iterator it =
1810 find_if(m_window_search.begin(), 1810 find_if(m_window_search.begin(),
1811 m_window_search.end(), 1811 m_window_search.end(),
1812 Compose(bind2nd(equal_to<WinClient *>(), client), 1812 Compose(bind2nd(equal_to<WinClient *>(), client),
@@ -1834,7 +1834,7 @@ void Fluxbox::updateFocusedWindow(BScreen *screen, BScreen *old_screen) {
1834} 1834}
1835 1835
1836void Fluxbox::watchKeyRelease(BScreen &screen, unsigned int mods) { 1836void Fluxbox::watchKeyRelease(BScreen &screen, unsigned int mods) {
1837 1837
1838 if (mods == 0) { 1838 if (mods == 0) {
1839 cerr<<"WARNING: attempt to grab without modifiers!"<<endl; 1839 cerr<<"WARNING: attempt to grab without modifiers!"<<endl;
1840 return; 1840 return;
@@ -1855,3 +1855,22 @@ void Fluxbox::updateFrameExtents(FluxboxWindow &win) {
1855 (*it).first->updateFrameExtents(win); 1855 (*it).first->updateFrameExtents(win);
1856 } 1856 }
1857} 1857}
1858
1859unsigned int Fluxbox::getModKey() const {
1860 if (!(m_rc_mod_key->c_str()))
1861 return 0;
1862 else
1863 return FbTk::KeyUtil::instance().getModifier(m_rc_mod_key->c_str());
1864}
1865
1866void Fluxbox::setModKey(const char* modkeyname) {
1867
1868 if (!modkeyname)
1869 return;
1870
1871 unsigned int modkey = FbTk::KeyUtil::instance().getModifier(modkeyname);
1872
1873 if (modkey > 0) {
1874 m_rc_mod_key = modkeyname;
1875 }
1876}