diff options
author | rathnor <rathnor> | 2003-02-02 16:32:41 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2003-02-02 16:32:41 (GMT) |
commit | 1b063dcea92e0a7ac5008518fc5c13f03c055f54 (patch) | |
tree | 29d5b622c0870f06a94086ed463ab90e23bc673e /src/Screen.cc | |
parent | 5244fc32447d2649a52a06dc84d96da94e9fd715 (diff) | |
download | fluxbox_pavel-1b063dcea92e0a7ac5008518fc5c13f03c055f54.zip fluxbox_pavel-1b063dcea92e0a7ac5008518fc5c13f03c055f54.tar.bz2 |
Integration of new Layering code, plus updates to the layering code itself
- new KeyActions: Raise/LowerLayer, AlwaysOnTop/Bottom, Top/BottomLayer
Added a "Quit" KeyAction
Diffstat (limited to 'src/Screen.cc')
-rw-r--r-- | src/Screen.cc | 184 |
1 files changed, 171 insertions, 13 deletions
diff --git a/src/Screen.cc b/src/Screen.cc index e96dce8..864bc50 100644 --- a/src/Screen.cc +++ b/src/Screen.cc | |||
@@ -22,7 +22,7 @@ | |||
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.100 2003/01/12 23:56:49 fluxgen Exp $ | 25 | // $Id: Screen.cc,v 1.101 2003/02/02 16:32:38 rathnor Exp $ |
26 | 26 | ||
27 | 27 | ||
28 | #include "Screen.hh" | 28 | #include "Screen.hh" |
@@ -43,6 +43,8 @@ | |||
43 | #include "BoolMenuItem.hh" | 43 | #include "BoolMenuItem.hh" |
44 | //#include "IntResMenuItem.hh" | 44 | //#include "IntResMenuItem.hh" |
45 | #include "MacroCommand.hh" | 45 | #include "MacroCommand.hh" |
46 | #include "XLayerItem.hh" | ||
47 | #include "MultLayers.hh" | ||
46 | 48 | ||
47 | //use GNU extensions | 49 | //use GNU extensions |
48 | #ifndef _GNU_SOURCE | 50 | #ifndef _GNU_SOURCE |
@@ -132,7 +134,11 @@ int dcmp(const void *one, const void *two) { | |||
132 | } | 134 | } |
133 | 135 | ||
134 | FbTk::Menu *createMenuFromScreen(BScreen &screen) { | 136 | FbTk::Menu *createMenuFromScreen(BScreen &screen) { |
135 | return new FbTk::Menu(*screen.menuTheme(), screen.getScreenNumber(), *screen.getImageControl()); | 137 | FbTk::Menu *menu = new FbTk::Menu(*screen.menuTheme(), screen.getScreenNumber(), *screen.getImageControl()); |
138 | menu->setLayerItem(new FbTk::XLayerItem(menu->windowID())); | ||
139 | |||
140 | screen.setLayer(*menu->getLayerItem(), Fluxbox::instance()->getMenuLayer()); | ||
141 | return menu; | ||
136 | } | 142 | } |
137 | }; | 143 | }; |
138 | 144 | ||
@@ -340,7 +346,8 @@ BScreen::BScreen(ResourceManager &rm, | |||
340 | m_workspacecount_sig(*this), // workspace count signal | 346 | m_workspacecount_sig(*this), // workspace count signal |
341 | m_workspacenames_sig(*this), // workspace names signal | 347 | m_workspacenames_sig(*this), // workspace names signal |
342 | m_currentworkspace_sig(*this), // current workspace signal | 348 | m_currentworkspace_sig(*this), // current workspace signal |
343 | theme(0), m_windowtheme(scrn), | 349 | m_layermanager(0), |
350 | theme(0), m_windowtheme(scrn), | ||
344 | m_menutheme(new FbTk::MenuTheme(scrn)), | 351 | m_menutheme(new FbTk::MenuTheme(scrn)), |
345 | resource(rm, screenname, altscreenname), | 352 | resource(rm, screenname, altscreenname), |
346 | m_root_theme(new RootTheme(*this)) | 353 | m_root_theme(new RootTheme(*this)) |
@@ -392,6 +399,7 @@ BScreen::BScreen(ResourceManager &rm, | |||
392 | 399 | ||
393 | fluxbox->load_rc(this); | 400 | fluxbox->load_rc(this); |
394 | 401 | ||
402 | m_layermanager = new FbTk::MultLayers(fluxbox->getNumberOfLayers()); | ||
395 | image_control->setDither(*resource.image_dither); | 403 | image_control->setDither(*resource.image_dither); |
396 | theme = new Theme(disp, getRootWindow(), colormap(), getScreenNumber(), | 404 | theme = new Theme(disp, getRootWindow(), colormap(), getScreenNumber(), |
397 | fluxbox->getStyleFilename(), getRootCommand().c_str()); | 405 | fluxbox->getStyleFilename(), getRootCommand().c_str()); |
@@ -461,12 +469,12 @@ BScreen::BScreen(ResourceManager &rm, | |||
461 | Workspace *wkspc = (Workspace *) 0; | 469 | Workspace *wkspc = (Workspace *) 0; |
462 | if (*resource.workspaces != 0) { | 470 | if (*resource.workspaces != 0) { |
463 | for (int i = 0; i < *resource.workspaces; ++i) { | 471 | for (int i = 0; i < *resource.workspaces; ++i) { |
464 | wkspc = new Workspace(this, workspacesList.size()); | 472 | wkspc = new Workspace(this, *m_layermanager, workspacesList.size()); |
465 | workspacesList.push_back(wkspc); | 473 | workspacesList.push_back(wkspc); |
466 | workspacemenu->insert(wkspc->name().c_str(), &wkspc->menu()); | 474 | workspacemenu->insert(wkspc->name().c_str(), &wkspc->menu()); |
467 | } | 475 | } |
468 | } else { | 476 | } else { |
469 | wkspc = new Workspace(this, workspacesList.size()); | 477 | wkspc = new Workspace(this, *m_layermanager, workspacesList.size()); |
470 | workspacesList.push_back(wkspc); | 478 | workspacesList.push_back(wkspc); |
471 | workspacemenu->insert(wkspc->name().c_str(), &wkspc->menu()); | 479 | workspacemenu->insert(wkspc->name().c_str(), &wkspc->menu()); |
472 | } | 480 | } |
@@ -547,7 +555,6 @@ BScreen::BScreen(ResourceManager &rm, | |||
547 | if (win) { | 555 | if (win) { |
548 | XMapRequestEvent mre; | 556 | XMapRequestEvent mre; |
549 | mre.window = children[i]; | 557 | mre.window = children[i]; |
550 | win->restoreAttributes(); | ||
551 | win->mapRequestEvent(mre); | 558 | win->mapRequestEvent(mre); |
552 | } | 559 | } |
553 | } | 560 | } |
@@ -809,7 +816,7 @@ void BScreen::setAntialias(bool value) { | |||
809 | } | 816 | } |
810 | 817 | ||
811 | int BScreen::addWorkspace() { | 818 | int BScreen::addWorkspace() { |
812 | Workspace *wkspc = new Workspace(this, workspacesList.size()); | 819 | Workspace *wkspc = new Workspace(this, *m_layermanager, workspacesList.size()); |
813 | workspacesList.push_back(wkspc); | 820 | workspacesList.push_back(wkspc); |
814 | addWorkspaceName(wkspc->name().c_str()); // update names | 821 | addWorkspaceName(wkspc->name().c_str()); // update names |
815 | //add workspace to workspacemenu | 822 | //add workspace to workspacemenu |
@@ -902,7 +909,7 @@ void BScreen::changeWorkspaceID(unsigned int id) { | |||
902 | !(focused && focused->isMoving())) { | 909 | !(focused && focused->isMoving())) { |
903 | current_workspace->getLastFocusedWindow()->setInputFocus(); | 910 | current_workspace->getLastFocusedWindow()->setInputFocus(); |
904 | 911 | ||
905 | } else if (focused && focused->isStuck()) { | 912 | } else if (focused && (focused->isStuck() || focused->isMoving())) { |
906 | focused->setInputFocus(); | 913 | focused->setInputFocus(); |
907 | } | 914 | } |
908 | 915 | ||
@@ -1184,6 +1191,13 @@ void BScreen::setupWindowActions(FluxboxWindow &win) { | |||
1184 | } | 1191 | } |
1185 | void BScreen::raiseWindows(const Workspace::Stack &workspace_stack) { | 1192 | void BScreen::raiseWindows(const Workspace::Stack &workspace_stack) { |
1186 | 1193 | ||
1194 | // TODO: I don't think we need this... | ||
1195 | #ifdef DEBUG | ||
1196 | cerr<<"BScreen::raiseWindows() called"<<endl; | ||
1197 | #endif //DEBUG | ||
1198 | |||
1199 | /* | ||
1200 | |||
1187 | Window session_stack[(workspace_stack.size() + workspacesList.size() + rootmenuList.size() + 30)]; | 1201 | Window session_stack[(workspace_stack.size() + workspacesList.size() + rootmenuList.size() + 30)]; |
1188 | int i = 0; | 1202 | int i = 0; |
1189 | 1203 | ||
@@ -1217,7 +1231,7 @@ void BScreen::raiseWindows(const Workspace::Stack &workspace_stack) { | |||
1217 | } | 1231 | } |
1218 | 1232 | ||
1219 | XRestackWindows(getBaseDisplay()->getXDisplay(), session_stack, i); | 1233 | XRestackWindows(getBaseDisplay()->getXDisplay(), session_stack, i); |
1220 | 1234 | */ | |
1221 | } | 1235 | } |
1222 | 1236 | ||
1223 | void BScreen::saveStrftimeFormat(const char *format) { | 1237 | void BScreen::saveStrftimeFormat(const char *format) { |
@@ -1311,7 +1325,7 @@ void BScreen::nextFocus(int opts) { | |||
1311 | } while (*it != focused); | 1325 | } while (*it != focused); |
1312 | 1326 | ||
1313 | if (*it != focused && it != wins.end()) | 1327 | if (*it != focused && it != wins.end()) |
1314 | wksp->raiseWindow(*it); | 1328 | raiseWindow(*it); |
1315 | 1329 | ||
1316 | } | 1330 | } |
1317 | 1331 | ||
@@ -1354,7 +1368,7 @@ void BScreen::prevFocus(int opts) { | |||
1354 | } while (*it != focused); | 1368 | } while (*it != focused); |
1355 | 1369 | ||
1356 | if (*it != focused && it != wins.end()) | 1370 | if (*it != focused && it != wins.end()) |
1357 | wksp->raiseWindow(*it); | 1371 | raiseWindow(*it); |
1358 | 1372 | ||
1359 | } | 1373 | } |
1360 | } | 1374 | } |
@@ -1375,8 +1389,7 @@ void BScreen::raiseFocus() { | |||
1375 | } | 1389 | } |
1376 | 1390 | ||
1377 | if ((getCurrentWorkspace()->getCount() > 1) && have_focused) | 1391 | if ((getCurrentWorkspace()->getCount() > 1) && have_focused) |
1378 | getWorkspace(fb->getFocusedWindow()->getWorkspaceNumber())-> | 1392 | raiseWindow(fb->getFocusedWindow()); |
1379 | raiseWindow(fb->getFocusedWindow()); | ||
1380 | } | 1393 | } |
1381 | 1394 | ||
1382 | void BScreen::initMenu() { | 1395 | void BScreen::initMenu() { |
@@ -1924,6 +1937,151 @@ void BScreen::hideGeometry() { | |||
1924 | } | 1937 | } |
1925 | } | 1938 | } |
1926 | 1939 | ||
1940 | void BScreen::raise(FbTk::XLayerItem &item) { | ||
1941 | item.raise(); | ||
1942 | } | ||
1943 | |||
1944 | void BScreen::lower(FbTk::XLayerItem &item) { | ||
1945 | item.lower(); | ||
1946 | } | ||
1947 | |||
1948 | void BScreen::setLayer(FbTk::XLayerItem &item, int layernum) { | ||
1949 | m_layermanager->moveToLayer(item, layernum); | ||
1950 | } | ||
1951 | |||
1952 | void BScreen::removeLayerItem(FbTk::XLayerItem *item) { | ||
1953 | m_layermanager->remove(*item); | ||
1954 | delete item; | ||
1955 | } | ||
1956 | |||
1957 | void BScreen::raiseWindow(FluxboxWindow *w) { | ||
1958 | FluxboxWindow *win = w; | ||
1959 | |||
1960 | while (win->getTransientFor()) { | ||
1961 | win = win->getTransientFor(); | ||
1962 | assert(win != win->getTransientFor()); | ||
1963 | } | ||
1964 | |||
1965 | if (!win->isIconic()) { | ||
1966 | updateNetizenWindowRaise(win->getClientWindow()); | ||
1967 | win->getLayerItem()->raise(); | ||
1968 | } | ||
1969 | std::list<FluxboxWindow *>::const_iterator it = win->getTransients().begin(); | ||
1970 | std::list<FluxboxWindow *>::const_iterator it_end = win->getTransients().end(); | ||
1971 | for (; it != it_end; ++it) { | ||
1972 | if (!(*it)->isIconic()) { | ||
1973 | updateNetizenWindowRaise((*it)->getClientWindow()); | ||
1974 | (*it)->getLayerItem()->raise(); | ||
1975 | } | ||
1976 | } | ||
1977 | } | ||
1978 | |||
1979 | void BScreen::lowerWindow(FluxboxWindow *w) { | ||
1980 | FluxboxWindow *win = (FluxboxWindow *) 0, *bottom = w; | ||
1981 | |||
1982 | while (bottom->getTransientFor()) { | ||
1983 | bottom = bottom->getTransientFor(); | ||
1984 | assert(bottom != bottom->getTransientFor()); | ||
1985 | } | ||
1986 | |||
1987 | win = bottom; | ||
1988 | |||
1989 | if (!win->isIconic()) { | ||
1990 | updateNetizenWindowLower(win->getClientWindow()); | ||
1991 | win->getLayerItem()->lower(); | ||
1992 | } | ||
1993 | std::list<FluxboxWindow *>::const_iterator it = win->getTransients().begin(); | ||
1994 | std::list<FluxboxWindow *>::const_iterator it_end = win->getTransients().end(); | ||
1995 | for (; it != it_end; ++it) { | ||
1996 | if (!(*it)->isIconic()) { | ||
1997 | updateNetizenWindowLower((*it)->getClientWindow()); | ||
1998 | (*it)->getLayerItem()->lower(); | ||
1999 | } | ||
2000 | } | ||
2001 | |||
2002 | } | ||
2003 | |||
2004 | void BScreen::raiseWindowLayer(FluxboxWindow *w) { | ||
2005 | FluxboxWindow *win = w; | ||
2006 | |||
2007 | while (win->getTransientFor()) { | ||
2008 | win = win->getTransientFor(); | ||
2009 | assert(win != win->getTransientFor()); | ||
2010 | } | ||
2011 | |||
2012 | if (!win->isIconic()) { | ||
2013 | updateNetizenWindowRaise(win->getClientWindow()); | ||
2014 | m_layermanager->raise(*win->getLayerItem()); | ||
2015 | win->setLayerNum(win->getLayerNum()-1); | ||
2016 | } | ||
2017 | std::list<FluxboxWindow *>::const_iterator it = win->getTransients().begin(); | ||
2018 | std::list<FluxboxWindow *>::const_iterator it_end = win->getTransients().end(); | ||
2019 | for (; it != it_end; ++it) { | ||
2020 | if (!(*it)->isIconic()) { | ||
2021 | updateNetizenWindowRaise((*it)->getClientWindow()); | ||
2022 | m_layermanager->raise(*(*it)->getLayerItem()); | ||
2023 | (*it)->setLayerNum((*it)->getLayerNum()-1); | ||
2024 | } | ||
2025 | } | ||
2026 | } | ||
2027 | |||
2028 | void BScreen::lowerWindowLayer(FluxboxWindow *w) { | ||
2029 | FluxboxWindow *win = (FluxboxWindow *) 0, *bottom = w; | ||
2030 | |||
2031 | while (bottom->getTransientFor()) { | ||
2032 | bottom = bottom->getTransientFor(); | ||
2033 | assert(bottom != bottom->getTransientFor()); | ||
2034 | } | ||
2035 | |||
2036 | win = bottom; | ||
2037 | |||
2038 | if (!win->isIconic()) { | ||
2039 | updateNetizenWindowLower(win->getClientWindow()); | ||
2040 | m_layermanager->lower(*win->getLayerItem()); | ||
2041 | win->setLayerNum(win->getLayerNum()+1); | ||
2042 | } | ||
2043 | std::list<FluxboxWindow *>::const_iterator it = win->getTransients().begin(); | ||
2044 | std::list<FluxboxWindow *>::const_iterator it_end = win->getTransients().end(); | ||
2045 | for (; it != it_end; ++it) { | ||
2046 | if (!(*it)->isIconic()) { | ||
2047 | updateNetizenWindowLower((*it)->getClientWindow()); | ||
2048 | m_layermanager->lower(*(*it)->getLayerItem()); | ||
2049 | (*it)->setLayerNum((*it)->getLayerNum()+1); | ||
2050 | } | ||
2051 | } | ||
2052 | |||
2053 | } | ||
2054 | |||
2055 | void BScreen::moveWindowToLayer(FluxboxWindow *win, int layernum) { | ||
2056 | Fluxbox * fluxbox = Fluxbox::instance(); | ||
2057 | |||
2058 | // don't let it set its layer into menu area | ||
2059 | if (layernum <= fluxbox->getMenuLayer()) { | ||
2060 | layernum = fluxbox->getMenuLayer() + 1; | ||
2061 | } | ||
2062 | |||
2063 | while (win->getTransientFor()) { | ||
2064 | win = win->getTransientFor(); | ||
2065 | assert(win != win->getTransientFor()); | ||
2066 | } | ||
2067 | |||
2068 | if (!win->isIconic()) { | ||
2069 | updateNetizenWindowRaise(win->getClientWindow()); | ||
2070 | m_layermanager->moveToLayer(*win->getLayerItem(),layernum); | ||
2071 | win->setLayerNum(layernum); | ||
2072 | } | ||
2073 | std::list<FluxboxWindow *>::const_iterator it = win->getTransients().begin(); | ||
2074 | std::list<FluxboxWindow *>::const_iterator it_end = win->getTransients().end(); | ||
2075 | for (; it != it_end; ++it) { | ||
2076 | if (!(*it)->isIconic()) { | ||
2077 | updateNetizenWindowRaise((*it)->getClientWindow()); | ||
2078 | m_layermanager->moveToLayer(*(*it)->getLayerItem(), layernum); | ||
2079 | (*it)->setLayerNum(layernum); | ||
2080 | } | ||
2081 | } | ||
2082 | } | ||
2083 | |||
2084 | |||
1927 | /** | 2085 | /** |
1928 | Goes to the workspace "right" of the current | 2086 | Goes to the workspace "right" of the current |
1929 | */ | 2087 | */ |