aboutsummaryrefslogtreecommitdiff
path: root/src/Screen.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-08-18 11:26:17 (GMT)
committerfluxgen <fluxgen>2003-08-18 11:26:17 (GMT)
commit2ae58a7e491bcf76dd7da3cc2ecdf52765d84de5 (patch)
tree559fb3877777bfae3c4e7d79fcb2ffa53c9590a6 /src/Screen.cc
parentf1f5472711fe4e8514697b4ccb8681a7f1771902 (diff)
downloadfluxbox-2ae58a7e491bcf76dd7da3cc2ecdf52765d84de5.zip
fluxbox-2ae58a7e491bcf76dd7da3cc2ecdf52765d84de5.tar.bz2
cleaning
Diffstat (limited to 'src/Screen.cc')
-rw-r--r--src/Screen.cc121
1 files changed, 34 insertions, 87 deletions
diff --git a/src/Screen.cc b/src/Screen.cc
index efe7cb8..04d73af 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.221 2003/08/17 19:06:10 fluxgen Exp $ 25// $Id: Screen.cc,v 1.222 2003/08/18 11:26:17 fluxgen Exp $
26 26
27 27
28#include "Screen.hh" 28#include "Screen.hh"
@@ -79,23 +79,11 @@
79#include <ctype.h> 79#include <ctype.h>
80#endif // HAVE_CTYPE_H 80#endif // HAVE_CTYPE_H
81 81
82#ifdef HAVE_DIRENT_H
83#include <dirent.h>
84#endif // HAVE_DIRENT_H
85
86#ifdef HAVE_LOCALE_H
87#include <locale.h>
88#endif // HAVE_LOCALE_H
89
90#ifdef HAVE_UNISTD_H 82#ifdef HAVE_UNISTD_H
91#include <sys/types.h> 83#include <sys/types.h>
92#include <unistd.h> 84#include <unistd.h>
93#endif // HAVE_UNISTD_H 85#endif // HAVE_UNISTD_H
94 86
95#ifdef HAVE_SYS_STAT_H
96#include <sys/stat.h>
97#endif // HAVE_SYS_STAT_H
98
99#ifdef HAVE_STDARG_H 87#ifdef HAVE_STDARG_H
100#include <stdarg.h> 88#include <stdarg.h>
101#endif // HAVE_STDARG_H 89#endif // HAVE_STDARG_H
@@ -111,10 +99,6 @@
111#endif // HAVE_SYS_TIME_H 99#endif // HAVE_SYS_TIME_H
112#endif // TIME_WITH_SYS_TIME 100#endif // TIME_WITH_SYS_TIME
113 101
114#ifndef MAXPATHLEN
115#define MAXPATHLEN 255
116#endif // MAXPATHLEN
117
118#include <X11/Xatom.h> 102#include <X11/Xatom.h>
119#include <X11/keysym.h> 103#include <X11/keysym.h>
120#include <X11/cursorfont.h> 104#include <X11/cursorfont.h>
@@ -433,8 +417,8 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
433 m_configmenu->update(); 417 m_configmenu->update();
434 418
435#ifdef SLIT 419#ifdef SLIT
436 // if (slit()) // this will load theme and reconfigure slit 420 if (slit()) // this will load theme and reconfigure slit
437 // FbTk::ThemeManager::instance().loadTheme(slit()->theme()); 421 FbTk::ThemeManager::instance().loadTheme(slit()->theme());
438#endif // SLIT 422#endif // SLIT
439 423
440 FbTk::ThemeManager::instance().load(Fluxbox::instance()->getStyleFilename()); 424 FbTk::ThemeManager::instance().load(Fluxbox::instance()->getStyleFilename());
@@ -530,11 +514,9 @@ BScreen::~BScreen() {
530 514
531 m_netizen_list.clear(); 515 m_netizen_list.clear();
532 516
533#ifdef XINERAMA
534 if (hasXinerama() && m_xinerama_headinfo) { 517 if (hasXinerama() && m_xinerama_headinfo) {
535 delete [] m_xinerama_headinfo; 518 delete [] m_xinerama_headinfo;
536 } 519 }
537#endif // XINERAMA
538} 520}
539 521
540unsigned int BScreen::currentWorkspaceID() const { 522unsigned int BScreen::currentWorkspaceID() const {
@@ -602,9 +584,6 @@ unsigned int BScreen::maxBottom(int head) const {
602} 584}
603 585
604void BScreen::reconfigure() { 586void BScreen::reconfigure() {
605#ifdef DEBUG
606 cerr<<__FILE__<<"("<<__LINE__<<"): BScreen::reconfigure"<<endl;
607#endif // DEBUG
608 m_menutheme->setAlpha(*resource.menu_alpha); 587 m_menutheme->setAlpha(*resource.menu_alpha);
609 Fluxbox::instance()->loadRootCommand(*this); 588 Fluxbox::instance()->loadRootCommand(*this);
610 589
@@ -865,11 +844,6 @@ void BScreen::changeWorkspaceID(unsigned int id) {
865 if (focused_client) 844 if (focused_client)
866 focused = focused_client->fbwindow(); 845 focused = focused_client->fbwindow();
867 846
868#ifdef DEBUG
869 cerr<<__FILE__<<"("<<__FUNCTION__<<"): "<<focused_client<<endl;
870 cerr<<__FILE__<<"("<<__FUNCTION__<<"): focused = "<<focused<<endl;
871#endif // DEBUG
872
873 if (focused && focused->isMoving()) { 847 if (focused && focused->isMoving()) {
874 if (doOpaqueMove()) 848 if (doOpaqueMove())
875 reassociateWindow(focused, id, true); 849 reassociateWindow(focused, id, true);
@@ -1268,12 +1242,8 @@ void BScreen::reassociateWindow(FluxboxWindow *w, unsigned int wkspc_id,
1268 if (w == 0) 1242 if (w == 0)
1269 return; 1243 return;
1270 1244
1271 if (wkspc_id >= getCount()) { 1245 if (wkspc_id >= getCount())
1272 wkspc_id = currentWorkspace()->workspaceID(); 1246 wkspc_id = currentWorkspace()->workspaceID();
1273#ifdef DEBUG
1274 cerr<<__FILE__<<"("<<__LINE__<<"): wkspc_id >= getCount()"<<endl;
1275#endif // DEBUG
1276 }
1277 1247
1278 if (!w->isIconic() && w->workspaceNumber() == wkspc_id) 1248 if (!w->isIconic() && w->workspaceNumber() == wkspc_id)
1279 return; 1249 return;
@@ -1660,16 +1630,13 @@ void BScreen::initMenu() {
1660 FbTk::RefCount<FbTk::Command> exit_fb(new FbCommands::ExitFluxboxCmd()); 1630 FbTk::RefCount<FbTk::Command> exit_fb(new FbCommands::ExitFluxboxCmd());
1661 FbTk::RefCount<FbTk::Command> execute_xterm(new FbCommands::ExecuteCmd("xterm", screenNumber())); 1631 FbTk::RefCount<FbTk::Command> execute_xterm(new FbCommands::ExecuteCmd("xterm", screenNumber()));
1662 m_rootmenu->setInternalMenu(); 1632 m_rootmenu->setInternalMenu();
1663 m_rootmenu->insert(i18n->getMessage( 1633 m_rootmenu->insert(i18n->getMessage(FBNLS::ScreenSet, FBNLS::Screenxterm,
1664 FBNLS::ScreenSet, FBNLS::Screenxterm,
1665 "xterm"), 1634 "xterm"),
1666 execute_xterm); 1635 execute_xterm);
1667 m_rootmenu->insert(i18n->getMessage( 1636 m_rootmenu->insert(i18n->getMessage(FBNLS::ScreenSet, FBNLS::ScreenRestart,
1668 FBNLS::ScreenSet, FBNLS::ScreenRestart,
1669 "Restart"), 1637 "Restart"),
1670 restart_fb); 1638 restart_fb);
1671 m_rootmenu->insert(i18n->getMessage( 1639 m_rootmenu->insert(i18n->getMessage(FBNLS::ScreenSet, FBNLS::ScreenExit,
1672 FBNLS::ScreenSet, FBNLS::ScreenExit,
1673 "Exit"), 1640 "Exit"),
1674 exit_fb); 1641 exit_fb);
1675 } 1642 }
@@ -1727,8 +1694,7 @@ bool BScreen::parseMenuFile(ifstream &file, FbTk::Menu &menu, int &row) {
1727 } else if (str_key == "exec") { // exec 1694 } else if (str_key == "exec") { // exec
1728 if (!(str_label.size() && str_cmd.size())) { 1695 if (!(str_label.size() && str_cmd.size())) {
1729 fprintf(stderr, 1696 fprintf(stderr,
1730 i18n->getMessage( 1697 i18n->getMessage(FBNLS::ScreenSet, FBNLS::ScreenEXECError,
1731 FBNLS::ScreenSet, FBNLS::ScreenEXECError,
1732 "BScreen::parseMenuFile: [exec] error, " 1698 "BScreen::parseMenuFile: [exec] error, "
1733 "no menu label and/or command defined\n")); 1699 "no menu label and/or command defined\n"));
1734 cerr<<"Row: "<<row<<endl; 1700 cerr<<"Row: "<<row<<endl;
@@ -1743,8 +1709,7 @@ bool BScreen::parseMenuFile(ifstream &file, FbTk::Menu &menu, int &row) {
1743 } else if (str_key == "exit") { // exit 1709 } else if (str_key == "exit") { // exit
1744 if (!str_label.size()) { 1710 if (!str_label.size()) {
1745 fprintf(stderr, 1711 fprintf(stderr,
1746 i18n->getMessage( 1712 i18n->getMessage(FBNLS::ScreenSet, FBNLS::ScreenEXITError,
1747 FBNLS::ScreenSet, FBNLS::ScreenEXITError,
1748 "BScreen::parseMenuFile: [exit] error, " 1713 "BScreen::parseMenuFile: [exit] error, "
1749 "no menu label defined\n")); 1714 "no menu label defined\n"));
1750 cerr<<"Row: "<<row<<endl; 1715 cerr<<"Row: "<<row<<endl;
@@ -1767,8 +1732,7 @@ bool BScreen::parseMenuFile(ifstream &file, FbTk::Menu &menu, int &row) {
1767 if (! str_label.size()) { 1732 if (! str_label.size()) {
1768 fprintf(stderr, 1733 fprintf(stderr,
1769 i18n-> 1734 i18n->
1770 getMessage( 1735 getMessage(FBNLS::ScreenSet, FBNLS::ScreenCONFIGError,
1771 FBNLS::ScreenSet, FBNLS::ScreenCONFIGError,
1772 "BScreen::parseMenufile: [config] error, " 1736 "BScreen::parseMenufile: [config] error, "
1773 "no label defined")); 1737 "no label defined"));
1774 cerr<<"Row: "<<row<<endl; 1738 cerr<<"Row: "<<row<<endl;
@@ -1784,8 +1748,7 @@ bool BScreen::parseMenuFile(ifstream &file, FbTk::Menu &menu, int &row) {
1784 if (!str_label.size()) { 1748 if (!str_label.size()) {
1785 fprintf(stderr, 1749 fprintf(stderr,
1786 i18n-> 1750 i18n->
1787 getMessage( 1751 getMessage(FBNLS::ScreenSet, FBNLS::ScreenINCLUDEError,
1788 FBNLS::ScreenSet, FBNLS::ScreenINCLUDEError,
1789 "BScreen::parseMenuFile: [include] error, " 1752 "BScreen::parseMenuFile: [include] error, "
1790 "no filename defined\n")); 1753 "no filename defined\n"));
1791 cerr<<"Row: "<<row<<endl; 1754 cerr<<"Row: "<<row<<endl;
@@ -1794,32 +1757,22 @@ bool BScreen::parseMenuFile(ifstream &file, FbTk::Menu &menu, int &row) {
1794 string newfile(FbTk::StringUtil::expandFilename(str_label)); 1757 string newfile(FbTk::StringUtil::expandFilename(str_label));
1795 1758
1796 if (newfile.size() != 0) { 1759 if (newfile.size() != 0) {
1797 FILE *submenufile = fopen(newfile.c_str(), "r"); 1760 if (!FbTk::Directory::isRegularFile(newfile)) {
1798 1761 fprintf(stderr,
1799 if (submenufile) { 1762 i18n->
1800 struct stat buf; 1763 getMessage(
1801 if (fstat(fileno(submenufile), &buf) || 1764 FBNLS::ScreenSet,
1802 (! S_ISREG(buf.st_mode))) { 1765 FBNLS::ScreenINCLUDEErrorReg,
1803 fprintf(stderr, 1766 "BScreen::parseMenuFile: [include] error: "
1804 i18n-> 1767 "'%s' is not a regular file\n"),
1805 getMessage( 1768 newfile.c_str());
1806 FBNLS::ScreenSet, 1769 cerr<<"Row: "<<row<<endl;
1807 FBNLS::ScreenINCLUDEErrorReg, 1770 } else {
1808 "BScreen::parseMenuFile: [include] error: " 1771 // the file is a regular file, lets open and parse it
1809 "'%s' is not a regular file\n"), 1772 ifstream subfile(newfile.c_str());
1810 newfile.c_str()); 1773 if (!parseMenuFile(subfile, menu, row))
1811 1774 Fluxbox::instance()->saveMenuFilename(newfile.c_str());
1812 cerr<<"Row: "<<row<<endl; 1775 }
1813 }
1814
1815 if (! feof(submenufile)) {
1816 fclose(submenufile);
1817 ifstream subfile(newfile.c_str());
1818 if (! parseMenuFile(subfile, menu, row))
1819 Fluxbox::instance()->saveMenuFilename(newfile.c_str());
1820 }
1821 } else
1822 perror(newfile.c_str());
1823 } 1776 }
1824 } // end of else 'x' 1777 } // end of else 'x'
1825 } // end of include 1778 } // end of include
@@ -2028,7 +1981,7 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) {
2028 "AntiAlias"), 1981 "AntiAlias"),
2029 *resource.antialias, 1982 *resource.antialias,
2030 save_and_reconfigure)); 1983 save_and_reconfigure));
2031 1984 //!! TODO: antialias
2032 FbTk::MenuItem *menu_alpha_item = new IntResMenuItem("Menu Alpha", resource.menu_alpha, 1985 FbTk::MenuItem *menu_alpha_item = new IntResMenuItem("Menu Alpha", resource.menu_alpha,
2033 0, 255); 1986 0, 255);
2034 menu_alpha_item->setCommand(saverc_cmd); 1987 menu_alpha_item->setCommand(saverc_cmd);
@@ -2046,8 +1999,6 @@ void BScreen::createStyleMenu(FbTk::Menu &menu,
2046 // perform shell style ~ home directory expansion 1999 // perform shell style ~ home directory expansion
2047 string stylesdir(FbTk::StringUtil::expandFilename(directory ? directory : "")); 2000 string stylesdir(FbTk::StringUtil::expandFilename(directory ? directory : ""));
2048 2001
2049 I18n *i18n = I18n::instance();
2050
2051 if (!FbTk::Directory::isDirectory(stylesdir)) { 2002 if (!FbTk::Directory::isDirectory(stylesdir)) {
2052 //!! TODO: NLS 2003 //!! TODO: NLS
2053 cerr<<"Error creating style menu! Stylesdir: "<<stylesdir<<" does not exist or is not a directory!"<<endl; 2004 cerr<<"Error creating style menu! Stylesdir: "<<stylesdir<<" does not exist or is not a directory!"<<endl;
@@ -2065,15 +2016,12 @@ void BScreen::createStyleMenu(FbTk::Menu &menu,
2065 2016
2066 std::sort(filelist.begin(), filelist.end(), less<string>()); 2017 std::sort(filelist.begin(), filelist.end(), less<string>());
2067 2018
2068 int slen = stylesdir.size();
2069 // for each file in directory add filename and path to menu 2019 // for each file in directory add filename and path to menu
2070 for (size_t file_index = 0; file_index < dir.entries(); file_index++) { 2020 for (size_t file_index = 0; file_index < dir.entries(); file_index++) {
2071 std::string style(stylesdir + '/' + filelist[file_index]); 2021 std::string style(stylesdir + '/' + filelist[file_index]);
2072 2022 // add to menu only if the file is a regular file
2073 if (FbTk::Directory::isRegularFile(style)) { 2023 if (FbTk::Directory::isRegularFile(style))
2074 FbTk::MenuItem *item = new StyleMenuItem(filelist[file_index], style); 2024 menu.insert(new StyleMenuItem(filelist[file_index], style));
2075 menu.insert(item);
2076 }
2077 } 2025 }
2078 // update menu graphics 2026 // update menu graphics
2079 menu.update(); 2027 menu.update();
@@ -2104,7 +2052,7 @@ void BScreen::showPosition(int x, int y) {
2104 unsigned int head = getCurrHead(); 2052 unsigned int head = getCurrHead();
2105 2053
2106 m_geom_window.move(getHeadX(head) + (getHeadWidth(head) - m_geom_window.width()) / 2, 2054 m_geom_window.move(getHeadX(head) + (getHeadWidth(head) - m_geom_window.width()) / 2,
2107 getHeadY(head) + (getHeadHeight(head) - m_geom_window.height()) / 2); 2055 getHeadY(head) + (getHeadHeight(head) - m_geom_window.height()) / 2);
2108 2056
2109 } else { 2057 } else {
2110 m_geom_window.move((width() - m_geom_window.width()) / 2, (height() - m_geom_window.height()) / 2); 2058 m_geom_window.move((width() - m_geom_window.width()) / 2, (height() - m_geom_window.height()) / 2);
@@ -2154,13 +2102,12 @@ void BScreen::showGeometry(unsigned int gx, unsigned int gy) {
2154 char label[256]; 2102 char label[256];
2155 2103
2156 sprintf(label, 2104 sprintf(label,
2157 I18n::instance()->getMessage( 2105 I18n::instance()->getMessage(FBNLS::ScreenSet, FBNLS::ScreenGeometryFormat,
2158 FBNLS::ScreenSet, FBNLS::ScreenGeometryFormat,
2159 "W: %4d x H: %4d"), gx, gy); 2106 "W: %4d x H: %4d"), gx, gy);
2160 2107
2161 m_geom_window.clear(); 2108 m_geom_window.clear();
2162 2109
2163 //TODO: geom window again?! repeated 2110 //!! TODO: geom window again?! repeated
2164 winFrameTheme().font().drawText(m_geom_window.window(), 2111 winFrameTheme().font().drawText(m_geom_window.window(),
2165 screenNumber(), 2112 screenNumber(),
2166 winFrameTheme().labelTextFocusGC(), 2113 winFrameTheme().labelTextFocusGC(),