diff options
author | fluxgen <fluxgen> | 2003-02-20 23:31:13 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-02-20 23:31:13 (GMT) |
commit | 6513acb0e0e105f85b1335a46007d8916a855236 (patch) | |
tree | b7e028a0205914582845561a81d698ba429c94a0 /src/Screen.cc | |
parent | 8c67f63d44c018660e3dd0b9b64a8b8fdf1aec17 (diff) | |
download | fluxbox_pavel-6513acb0e0e105f85b1335a46007d8916a855236.zip fluxbox_pavel-6513acb0e0e105f85b1335a46007d8916a855236.tar.bz2 |
focus menu and sorting style menu the other way
Diffstat (limited to 'src/Screen.cc')
-rw-r--r-- | src/Screen.cc | 99 |
1 files changed, 60 insertions, 39 deletions
diff --git a/src/Screen.cc b/src/Screen.cc index 9f0bfe7..ee32f56 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.111 2003/02/18 15:11:07 rathnor Exp $ | 25 | // $Id: Screen.cc,v 1.112 2003/02/20 23:31:13 fluxgen Exp $ |
26 | 26 | ||
27 | 27 | ||
28 | #include "Screen.hh" | 28 | #include "Screen.hh" |
@@ -506,14 +506,13 @@ BScreen::BScreen(ResourceManager &rm, | |||
506 | 506 | ||
507 | workspacemenu.reset(createMenuFromScreen(*this)); | 507 | workspacemenu.reset(createMenuFromScreen(*this)); |
508 | 508 | ||
509 | Workspace *wkspc = (Workspace *) 0; | ||
510 | if (*resource.workspaces != 0) { | 509 | if (*resource.workspaces != 0) { |
511 | for (int i = 0; i < *resource.workspaces; ++i) { | 510 | for (int i = 0; i < *resource.workspaces; ++i) { |
512 | wkspc = new Workspace(*this, m_layermanager, workspacesList.size()); | 511 | Workspace *wkspc = new Workspace(*this, m_layermanager, workspacesList.size()); |
513 | workspacesList.push_back(wkspc); | 512 | workspacesList.push_back(wkspc); |
514 | } | 513 | } |
515 | } else { // create at least one workspace | 514 | } else { // create at least one workspace |
516 | wkspc = new Workspace(*this, m_layermanager, workspacesList.size()); | 515 | Workspace *wkspc = new Workspace(*this, m_layermanager, workspacesList.size()); |
517 | workspacesList.push_back(wkspc); | 516 | workspacesList.push_back(wkspc); |
518 | } | 517 | } |
519 | 518 | ||
@@ -668,24 +667,20 @@ unsigned int BScreen::getMaxLeft() const { | |||
668 | return 0; | 667 | return 0; |
669 | } | 668 | } |
670 | 669 | ||
671 | /// TODO | 670 | ///!! TODO |
672 | unsigned int BScreen::getMaxRight() const { | 671 | unsigned int BScreen::getMaxRight() const { |
673 | return getWidth(); | 672 | return getWidth(); |
674 | } | 673 | } |
675 | 674 | ||
676 | /// TODO | 675 | ///!! TODO |
677 | unsigned int BScreen::getMaxTop() const { | 676 | unsigned int BScreen::getMaxTop() const { |
678 | return 0; | 677 | return 0; |
679 | } | 678 | } |
680 | /// TODO | 679 | ///!! TODO |
681 | unsigned int BScreen::getMaxBottom() const { | 680 | unsigned int BScreen::getMaxBottom() const { |
682 | return getHeight(); | 681 | return getHeight(); |
683 | } | 682 | } |
684 | 683 | ||
685 | void BScreen::iconUpdate() { | ||
686 | |||
687 | } | ||
688 | |||
689 | void BScreen::reconfigure() { | 684 | void BScreen::reconfigure() { |
690 | #ifdef DEBUG | 685 | #ifdef DEBUG |
691 | cerr<<__FILE__<<"("<<__LINE__<<"): BScreen::reconfigure"<<endl; | 686 | cerr<<__FILE__<<"("<<__LINE__<<"): BScreen::reconfigure"<<endl; |
@@ -1147,9 +1142,9 @@ FluxboxWindow *BScreen::createWindow(Window client) { | |||
1147 | setupWindowActions(*win); | 1142 | setupWindowActions(*win); |
1148 | } | 1143 | } |
1149 | if (win->getWorkspaceNumber() == getCurrentWorkspaceID() || win->isStuck()) { | 1144 | if (win->getWorkspaceNumber() == getCurrentWorkspaceID() || win->isStuck()) { |
1150 | win->show(); | 1145 | win->show(); |
1151 | XSync(FbTk::App::instance()->display(), False); | ||
1152 | } | 1146 | } |
1147 | XSync(FbTk::App::instance()->display(), False); | ||
1153 | return win; | 1148 | return win; |
1154 | } | 1149 | } |
1155 | 1150 | ||
@@ -1191,9 +1186,7 @@ void BScreen::setupWindowActions(FluxboxWindow &win) { | |||
1191 | 0, 0, 10, 10); | 1186 | 0, 0, 10, 10); |
1192 | newbutton->setOnClick(iconify_cmd); | 1187 | newbutton->setOnClick(iconify_cmd); |
1193 | 1188 | ||
1194 | #ifdef DEBUG | 1189 | |
1195 | cerr<<__FILE__<<": Creating iconify button"<<endl; | ||
1196 | #endif //DEBUG | ||
1197 | } else if (win.isMaximizable() && (*dir)[i] == Fluxbox::MAXIMIZE) { | 1190 | } else if (win.isMaximizable() && (*dir)[i] == Fluxbox::MAXIMIZE) { |
1198 | newbutton = new WinButton(WinButton::MAXIMIZE, | 1191 | newbutton = new WinButton(WinButton::MAXIMIZE, |
1199 | frame.titlebar(), | 1192 | frame.titlebar(), |
@@ -1203,9 +1196,6 @@ void BScreen::setupWindowActions(FluxboxWindow &win) { | |||
1203 | newbutton->setOnClick(maximize_horiz_cmd, 3); | 1196 | newbutton->setOnClick(maximize_horiz_cmd, 3); |
1204 | newbutton->setOnClick(maximize_vert_cmd, 2); | 1197 | newbutton->setOnClick(maximize_vert_cmd, 2); |
1205 | 1198 | ||
1206 | #ifdef DEBUG | ||
1207 | cerr<<__FILE__<<": Creating maximize button"<<endl; | ||
1208 | #endif // DEBUG | ||
1209 | } else if (win.isClosable() && (*dir)[i] == Fluxbox::CLOSE) { | 1199 | } else if (win.isClosable() && (*dir)[i] == Fluxbox::CLOSE) { |
1210 | newbutton = new WinButton(WinButton::CLOSE, | 1200 | newbutton = new WinButton(WinButton::CLOSE, |
1211 | frame.titlebar(), | 1201 | frame.titlebar(), |
@@ -1220,17 +1210,13 @@ void BScreen::setupWindowActions(FluxboxWindow &win) { | |||
1220 | frame.titlebar(), | 1210 | frame.titlebar(), |
1221 | 0, 0, 10, 10); | 1211 | 0, 0, 10, 10); |
1222 | newbutton->setOnClick(stick_cmd); | 1212 | newbutton->setOnClick(stick_cmd); |
1223 | #ifdef DEBUG | 1213 | |
1224 | cerr<<__FILE__<<": Creating stick button"<<endl; | ||
1225 | #endif // DEBUG | ||
1226 | } else if ((*dir)[i] == Fluxbox::SHADE) { | 1214 | } else if ((*dir)[i] == Fluxbox::SHADE) { |
1227 | newbutton = new WinButton(WinButton::SHADE, | 1215 | newbutton = new WinButton(WinButton::SHADE, |
1228 | frame.titlebar(), | 1216 | frame.titlebar(), |
1229 | 0, 0, 10, 10); | 1217 | 0, 0, 10, 10); |
1230 | newbutton->setOnClick(shade_cmd); | 1218 | newbutton->setOnClick(shade_cmd); |
1231 | #ifdef DEBUG | 1219 | |
1232 | cerr<<__FILE__<<": Creating shade button"<<endl; | ||
1233 | #endif // DEBUG | ||
1234 | } | 1220 | } |
1235 | 1221 | ||
1236 | if (newbutton != 0) { | 1222 | if (newbutton != 0) { |
@@ -1711,8 +1697,8 @@ bool BScreen::parseMenuFile(ifstream &file, FbTk::Menu &menu, int &row) { | |||
1711 | " error, no directory defined\n")); | 1697 | " error, no directory defined\n")); |
1712 | cerr<<"Row: "<<row<<endl; | 1698 | cerr<<"Row: "<<row<<endl; |
1713 | } else { | 1699 | } else { |
1714 | createStyleMenu(menu, newmenu, str_label.c_str(), | 1700 | createStyleMenu(menu, str_label.c_str(), |
1715 | (newmenu) ? str_cmd.c_str() : str_label.c_str()); | 1701 | newmenu ? str_cmd.c_str() : str_label.c_str()); |
1716 | } | 1702 | } |
1717 | } // end of stylesdir | 1703 | } // end of stylesdir |
1718 | else if (str_key == "workspaces") { | 1704 | else if (str_key == "workspaces") { |
@@ -1744,7 +1730,38 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) { | |||
1744 | s_a_reconf_macro->add(saverc_cmd); | 1730 | s_a_reconf_macro->add(saverc_cmd); |
1745 | s_a_reconf_macro->add(reconf_cmd); | 1731 | s_a_reconf_macro->add(reconf_cmd); |
1746 | FbTk::RefCount<FbTk::Command> save_and_reconfigure(s_a_reconf_macro); | 1732 | FbTk::RefCount<FbTk::Command> save_and_reconfigure(s_a_reconf_macro); |
1733 | // create focus menu | ||
1734 | FbTk::Menu *focus_menu = createMenuFromScreen(*this); | ||
1735 | |||
1736 | /* focus_menu->insert(new BoolMenuItem(i18n->getMessage( | ||
1737 | ConfigmenuSet, ConfigmenuClickToFocus, | ||
1738 | "Click To Focus"),*/ | ||
1739 | focus_menu->insert(new BoolMenuItem(i18n->getMessage( | ||
1740 | ConfigmenuSet, | ||
1741 | ConfigmenuSloppyFocus, | ||
1742 | "Sloppy Focus"), | ||
1743 | resource.sloppy_focus, | ||
1744 | save_and_reconfigure)); | ||
1745 | focus_menu->insert(new BoolMenuItem(i18n->getMessage( | ||
1746 | ConfigmenuSet, | ||
1747 | ConfigmenuSemiSloppyFocus, | ||
1748 | "Semi Sloppy Focus"), | ||
1749 | resource.semi_sloppy_focus, | ||
1750 | save_and_reconfigure)); | ||
1751 | focus_menu->insert(new BoolMenuItem(i18n->getMessage( | ||
1752 | ConfigmenuSet, | ||
1753 | ConfigmenuAutoRaise, | ||
1754 | "Auto Raise"), | ||
1755 | resource.auto_raise, | ||
1756 | save_and_reconfigure)); | ||
1757 | |||
1758 | focus_menu->update(); | ||
1759 | rootmenuList.push_back(focus_menu); | ||
1747 | 1760 | ||
1761 | menu.insert(i18n->getMessage( | ||
1762 | ConfigmenuSet, ConfigmenuFocusModel, | ||
1763 | "Focus Model"), | ||
1764 | focus_menu); | ||
1748 | #ifdef SLIT | 1765 | #ifdef SLIT |
1749 | if (getSlit() != 0) | 1766 | if (getSlit() != 0) |
1750 | menu.insert("Slit", &getSlit()->menu()); | 1767 | menu.insert("Slit", &getSlit()->menu()); |
@@ -1800,11 +1817,12 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) { | |||
1800 | menu.insert(new BoolMenuItem("antialias", *resource.antialias, | 1817 | menu.insert(new BoolMenuItem("antialias", *resource.antialias, |
1801 | save_and_reconfigure)); | 1818 | save_and_reconfigure)); |
1802 | 1819 | ||
1820 | |||
1803 | // finaly update menu | 1821 | // finaly update menu |
1804 | menu.update(); | 1822 | menu.update(); |
1805 | } | 1823 | } |
1806 | 1824 | ||
1807 | void BScreen::createStyleMenu(FbTk::Menu &menu, bool newmenu, | 1825 | void BScreen::createStyleMenu(FbTk::Menu &menu, |
1808 | const char *label, const char *directory) { | 1826 | const char *label, const char *directory) { |
1809 | 1827 | ||
1810 | // perform shell style ~ home directory expansion | 1828 | // perform shell style ~ home directory expansion |
@@ -1817,30 +1835,34 @@ void BScreen::createStyleMenu(FbTk::Menu &menu, bool newmenu, | |||
1817 | if (S_ISDIR(statbuf.st_mode)) { // is a directory? | 1835 | if (S_ISDIR(statbuf.st_mode)) { // is a directory? |
1818 | 1836 | ||
1819 | DirHelper d(stylesdir.c_str()); | 1837 | DirHelper d(stylesdir.c_str()); |
1838 | |||
1839 | // create a vector of all the filenames in the directory | ||
1840 | // add sort it | ||
1820 | std::vector<std::string> filelist(d.entries()); | 1841 | std::vector<std::string> filelist(d.entries()); |
1821 | for (size_t file_index = 0; file_index < d.entries(); ++file_index) | 1842 | for (size_t file_index = 0; file_index < d.entries(); ++file_index) |
1822 | filelist[file_index] = d.readFilename(); | 1843 | filelist[file_index] = d.readFilename(); |
1823 | 1844 | std::sort(filelist.begin(), filelist.end(), less<string>()); | |
1824 | std::sort(filelist.begin(), filelist.end(), greater<string>()); | ||
1825 | 1845 | ||
1826 | int slen = stylesdir.size(); | 1846 | int slen = stylesdir.size(); |
1847 | // for each file in directory add filename and path to menu | ||
1827 | for (size_t file_index = 0; file_index < d.entries(); file_index++) { | 1848 | for (size_t file_index = 0; file_index < d.entries(); file_index++) { |
1828 | int nlen = filelist[file_index].size(); | 1849 | int nlen = filelist[file_index].size(); |
1829 | char style[MAXPATHLEN + 1]; | 1850 | char style[MAXPATHLEN + 1]; |
1851 | |||
1830 | strncpy(style, stylesdir.c_str(), slen); | 1852 | strncpy(style, stylesdir.c_str(), slen); |
1831 | *(style + slen) = '/'; | 1853 | *(style + slen) = '/'; |
1832 | strncpy(style + slen + 1, filelist[file_index].c_str(), nlen + 1); | 1854 | strncpy(style + slen + 1, filelist[file_index].c_str(), nlen + 1); |
1855 | |||
1833 | if ( !stat(style, &statbuf) && S_ISREG(statbuf.st_mode)) { | 1856 | if ( !stat(style, &statbuf) && S_ISREG(statbuf.st_mode)) { |
1834 | FbTk::RefCount<FbTk::Command> setstyle_cmd(new FbCommands:: | 1857 | FbTk::RefCount<FbTk::Command> setstyle_cmd(new FbCommands:: |
1835 | SetStyleCmd(style)); | 1858 | SetStyleCmd(style)); |
1836 | menu.insert(filelist[file_index].c_str(), setstyle_cmd); | 1859 | menu.insert(filelist[file_index].c_str(), setstyle_cmd); |
1837 | } | 1860 | } |
1838 | } | 1861 | } |
1839 | 1862 | // update menu graphics | |
1840 | menu.update(); | 1863 | menu.update(); |
1841 | // ?? | ||
1842 | Fluxbox::instance()->saveMenuFilename(stylesdir.c_str()); | 1864 | Fluxbox::instance()->saveMenuFilename(stylesdir.c_str()); |
1843 | } else { // dir | 1865 | } else { // no directory |
1844 | fprintf(stderr, | 1866 | fprintf(stderr, |
1845 | i18n-> | 1867 | i18n-> |
1846 | getMessage( | 1868 | getMessage( |
@@ -1848,8 +1870,8 @@ void BScreen::createStyleMenu(FbTk::Menu &menu, bool newmenu, | |||
1848 | "BScreen::parseMenuFile:" | 1870 | "BScreen::parseMenuFile:" |
1849 | " [stylesdir/stylesmenu] error, %s is not a" | 1871 | " [stylesdir/stylesmenu] error, %s is not a" |
1850 | " directory\n"), stylesdir.c_str()); | 1872 | " directory\n"), stylesdir.c_str()); |
1851 | } // end of 'dir' | 1873 | } // end of directory check |
1852 | } else { // stat | 1874 | } else { // stat failed |
1853 | fprintf(stderr, | 1875 | fprintf(stderr, |
1854 | i18n-> | 1876 | i18n-> |
1855 | getMessage( | 1877 | getMessage( |
@@ -1905,10 +1927,9 @@ void BScreen::showPosition(int x, int y) { | |||
1905 | 1927 | ||
1906 | geom_visible = true; | 1928 | geom_visible = true; |
1907 | } | 1929 | } |
1908 | const int label_size = 1024; | 1930 | char label[256]; |
1909 | char label[label_size]; | ||
1910 | 1931 | ||
1911 | snprintf(label, label_size, | 1932 | sprintf(label, |
1912 | I18n::instance()->getMessage( | 1933 | I18n::instance()->getMessage( |
1913 | FBNLS::ScreenSet, FBNLS::ScreenPositionFormat, | 1934 | FBNLS::ScreenSet, FBNLS::ScreenPositionFormat, |
1914 | "X: %4d x Y: %4d"), x, y); | 1935 | "X: %4d x Y: %4d"), x, y); |
@@ -1944,7 +1965,7 @@ void BScreen::showGeometry(unsigned int gx, unsigned int gy) { | |||
1944 | geom_visible = true; | 1965 | geom_visible = true; |
1945 | } | 1966 | } |
1946 | 1967 | ||
1947 | char label[1024]; | 1968 | char label[256]; |
1948 | 1969 | ||
1949 | sprintf(label, | 1970 | sprintf(label, |
1950 | I18n::instance()->getMessage( | 1971 | I18n::instance()->getMessage( |