aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMark Tiefenbruck <mark@fluxbox.org>2008-01-19 12:00:46 (GMT)
committerMark Tiefenbruck <mark@fluxbox.org>2008-01-19 12:00:46 (GMT)
commitdb4ec8cf20b4e72cd32d0632a5ab6a8584d2515a (patch)
treef89bd2773b284aed8c1bbb7f9e5d1fe64d694070 /src
parent7b055cc54a2db2398a7da012b57f0dcbc9f85a35 (diff)
downloadfluxbox_pavel-db4ec8cf20b4e72cd32d0632a5ab6a8584d2515a.zip
fluxbox_pavel-db4ec8cf20b4e72cd32d0632a5ab6a8584d2515a.tar.bz2
move position and geometry windows into their own class
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/OSDWindow.cc94
-rw-r--r--src/OSDWindow.hh59
-rw-r--r--src/Screen.cc180
-rw-r--r--src/Screen.hh8
5 files changed, 169 insertions, 173 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 683179d..f41a30a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -101,6 +101,7 @@ fluxbox_SOURCES = AtomHandler.hh ArrowButton.hh ArrowButton.cc \
101 Keys.cc Keys.hh main.cc \ 101 Keys.cc Keys.hh main.cc \
102 RootTheme.hh RootTheme.cc \ 102 RootTheme.hh RootTheme.cc \
103 FbRootWindow.hh FbRootWindow.cc \ 103 FbRootWindow.hh FbRootWindow.cc \
104 OSDWindow.hh OSDWindow.cc \
104 Screen.cc Screen.hh ScreenResources.cc \ 105 Screen.cc Screen.hh ScreenResources.cc \
105 Slit.cc Slit.hh SlitTheme.hh SlitTheme.cc SlitClient.hh SlitClient.cc \ 106 Slit.cc Slit.hh SlitTheme.hh SlitTheme.cc SlitClient.hh SlitClient.cc \
106 WinButton.hh WinButton.cc \ 107 WinButton.hh WinButton.cc \
diff --git a/src/OSDWindow.cc b/src/OSDWindow.cc
new file mode 100644
index 0000000..005e07b
--- /dev/null
+++ b/src/OSDWindow.cc
@@ -0,0 +1,94 @@
1// OSDWindow.cc
2// Copyright (c) 2008 Fluxbox Team (fluxgen at fluxbox dot org)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22#include "OSDWindow.hh"
23
24#include "Screen.hh"
25#include "FbWinFrameTheme.hh"
26
27#include "FbTk/ImageControl.hh"
28
29void OSDWindow::reconfigTheme() {
30
31 setBorderWidth(m_theme->border().width());
32 setBorderColor(m_theme->border().color());
33
34 if (m_pixmap)
35 m_screen.imageControl().removeImage(m_pixmap);
36
37 if (m_theme->iconbarTheme().texture().type() &
38 FbTk::Texture::PARENTRELATIVE) {
39 if (!m_theme->titleTexture().usePixmap()) {
40 m_pixmap = None;
41 setBackgroundColor(m_theme->titleTexture().color());
42 } else {
43 m_pixmap = m_screen.imageControl().renderImage(width(), height(),
44 m_theme->titleTexture());
45 setBackgroundPixmap(m_pixmap);
46 }
47 } else {
48 if (!m_theme->iconbarTheme().texture().usePixmap()) {
49 m_pixmap = None;
50 setBackgroundColor(m_theme->iconbarTheme().texture().color());
51 } else {
52 m_pixmap = m_screen.imageControl().renderImage(width(), height(),
53 m_theme->iconbarTheme().texture());
54 setBackgroundPixmap(m_pixmap);
55 }
56 }
57
58}
59
60void OSDWindow::resize(const std::string &text) {
61
62 int h = m_theme->font().height() + m_theme->bevelWidth()*2;
63 int w = m_theme->font().textWidth(text, text.size()) +
64 m_theme->bevelWidth()*2;
65 FbTk::FbWindow::resize(w, h);
66}
67
68void OSDWindow::showText(const std::string &text) {
69 show();
70 clear();
71 m_theme->font().drawText(*this, m_screen.screenNumber(),
72 m_theme->iconbarTheme().text().textGC(), text, text.size(),
73 m_theme->bevelWidth(),
74 m_theme->bevelWidth() + m_theme->font().ascent());
75}
76
77void OSDWindow::show() {
78 if (m_visible)
79 return;
80
81 m_visible = true;
82 unsigned int head = m_screen.getCurrHead();
83 move(m_screen.getHeadX(head) + (m_screen.getHeadWidth(head) - width()) / 2,
84 m_screen.getHeadY(head) + (m_screen.getHeadHeight(head) - height()) / 2);
85 raise();
86 FbTk::FbWindow::show();
87}
88
89void OSDWindow::hide() {
90 if (!m_visible)
91 return;
92 m_visible = false;
93 FbTk::FbWindow::hide();
94}
diff --git a/src/OSDWindow.hh b/src/OSDWindow.hh
new file mode 100644
index 0000000..3fd5c42
--- /dev/null
+++ b/src/OSDWindow.hh
@@ -0,0 +1,59 @@
1// OSDWindow.hh
2// Copyright (c) 2008 Fluxbox Team (fluxgen at fluxbox dot org)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22#ifndef OSDWINDOW_HH
23#define OSDWINDOW_HH
24
25#include "FbTk/FbWindow.hh"
26#include <string>
27
28class BScreen;
29class FbWinFrameTheme;
30
31namespace FbTk {
32template <class T> class ThemeProxy;
33}
34
35class OSDWindow: public FbTk::FbWindow {
36public:
37 OSDWindow(const FbTk::FbWindow &parent, BScreen &screen,
38 FbTk::ThemeProxy<FbWinFrameTheme> &theme):
39 FbTk::FbWindow(parent, 0, 0, 10, 10, 0, false, true),
40 m_screen(screen), m_theme(theme),
41 m_pixmap(None), m_visible(false) { }
42
43 void reconfigTheme();
44 void resize(const std::string &text);
45 void showText(const std::string &text);
46 void hide();
47
48 bool isVisible() const { return m_visible; }
49
50private:
51 void show();
52
53 BScreen &m_screen;
54 FbTk::ThemeProxy<FbWinFrameTheme> &m_theme;
55 Pixmap m_pixmap;
56 bool m_visible;
57};
58
59#endif // OSDWINDOW_HH
diff --git a/src/Screen.cc b/src/Screen.cc
index 6af65a9..9002ad2 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -341,14 +341,8 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
341 m_pressed_winbutton_theme(new WinButtonTheme(scrn, ".pressed", ".Pressed", *m_focused_windowtheme)), 341 m_pressed_winbutton_theme(new WinButtonTheme(scrn, ".pressed", ".Pressed", *m_focused_windowtheme)),
342 m_menutheme(new FbTk::MenuTheme(scrn)), 342 m_menutheme(new FbTk::MenuTheme(scrn)),
343 m_root_window(scrn), 343 m_root_window(scrn),
344 m_geom_window(m_root_window, 344 m_geom_window(m_root_window, *this, *m_focused_windowtheme),
345 0, 0, 10, 10, 345 m_pos_window(m_root_window, *this, *m_focused_windowtheme),
346 false, // override redirect
347 true), // save under
348 m_pos_window(m_root_window,
349 0, 0, 10, 10,
350 false, // override redirect
351 true), // save under
352 m_dummy_window(scrn, -1, -1, 1, 1, 0, true, false, CopyFromParent, 346 m_dummy_window(scrn, -1, -1, 1, 1, 0, true, false, CopyFromParent,
353 InputOnly), 347 InputOnly),
354 resource(rm, screenname, altscreenname), 348 resource(rm, screenname, altscreenname),
@@ -483,11 +477,6 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
483 focusedWinFrameTheme()->reconfigSig().attach(this);// for geom window 477 focusedWinFrameTheme()->reconfigSig().attach(this);// for geom window
484 478
485 479
486 geom_visible = false;
487 geom_pixmap = 0;
488 pos_visible = false;
489 pos_pixmap = 0;
490
491 renderGeomWindow(); 480 renderGeomWindow();
492 renderPosWindow(); 481 renderPosWindow();
493 482
@@ -585,12 +574,6 @@ BScreen::~BScreen() {
585 } 574 }
586 } 575 }
587 576
588 if (geom_pixmap != None)
589 imageControl().removeImage(geom_pixmap);
590
591 if (pos_pixmap != None)
592 imageControl().removeImage(pos_pixmap);
593
594 removeWorkspaceNames(); 577 removeWorkspaceNames();
595 using namespace FbTk::STLUtil; 578 using namespace FbTk::STLUtil;
596 destroyAndClear(m_workspaces_list); 579 destroyAndClear(m_workspaces_list);
@@ -938,9 +921,6 @@ void BScreen::reconfigure() {
938 m_menutheme->setDelayOpen(*resource.menu_delay); 921 m_menutheme->setDelayOpen(*resource.menu_delay);
939 m_menutheme->setDelayClose(*resource.menu_delay_close); 922 m_menutheme->setDelayClose(*resource.menu_delay_close);
940 923
941 renderGeomWindow();
942 renderPosWindow();
943
944 // realize the number of workspaces from the init-file 924 // realize the number of workspaces from the init-file
945 const unsigned int nr_ws = *resource.workspaces; 925 const unsigned int nr_ws = *resource.workspaces;
946 if (nr_ws > m_workspaces_list.size()) { 926 if (nr_ws > m_workspaces_list.size()) {
@@ -1812,47 +1792,17 @@ void BScreen::shutdown() {
1812 1792
1813 1793
1814void BScreen::showPosition(int x, int y) { 1794void BScreen::showPosition(int x, int y) {
1815 if (!doShowWindowPos()) 1795 if (!doShowWindowPos())
1816 return; 1796 return;
1817 1797
1818 if (! pos_visible) {
1819 if (hasXinerama()) {
1820 unsigned int head = getCurrHead();
1821
1822 m_pos_window.move(getHeadX(head) + (getHeadWidth(head) - m_pos_window.width()) / 2,
1823 getHeadY(head) + (getHeadHeight(head) - m_pos_window.height()) / 2);
1824
1825 } else {
1826 m_pos_window.move((width() - m_pos_window.width()) / 2,
1827 (height() - m_pos_window.height()) / 2);
1828 }
1829
1830 m_pos_window.show();
1831 m_pos_window.raise();
1832
1833 pos_visible = true;
1834 }
1835
1836 char label[256]; 1798 char label[256];
1837 sprintf(label, "X:%5d x Y:%5d", x, y); 1799 sprintf(label, "X:%5d x Y:%5d", x, y);
1838 1800 m_pos_window.showText(label);
1839 m_pos_window.clear();
1840
1841 focusedWinFrameTheme()->font().drawText(m_pos_window, screenNumber(),
1842 focusedWinFrameTheme()->iconbarTheme().text().textGC(),
1843 label, strlen(label),
1844 focusedWinFrameTheme()->bevelWidth(),
1845 focusedWinFrameTheme()->bevelWidth() +
1846 focusedWinFrameTheme()->font().ascent());
1847
1848} 1801}
1849 1802
1850 1803
1851void BScreen::hidePosition() { 1804void BScreen::hidePosition() {
1852 if (pos_visible) { 1805 m_pos_window.hide();
1853 m_pos_window.hide();
1854 pos_visible = false;
1855 }
1856} 1806}
1857 1807
1858// can be negative when base_width/height > min_width/height 1808// can be negative when base_width/height > min_width/height
@@ -1860,23 +1810,6 @@ void BScreen::showGeometry(int gx, int gy) {
1860 if (!doShowWindowPos()) 1810 if (!doShowWindowPos())
1861 return; 1811 return;
1862 1812
1863 if (! geom_visible) {
1864 if (hasXinerama()) {
1865 unsigned int head = getCurrHead();
1866
1867 m_geom_window.move(getHeadX(head) + (getHeadWidth(head) - m_geom_window.width()) / 2,
1868 getHeadY(head) + (getHeadHeight(head) - m_geom_window.height()) / 2);
1869 } else {
1870 m_geom_window.move((width() - m_geom_window.width()) / 2,
1871 (height() - m_geom_window.height()) / 2);
1872
1873 }
1874 m_geom_window.show();
1875 m_geom_window.raise();
1876
1877 geom_visible = true;
1878 }
1879
1880 char label[256]; 1813 char label[256];
1881 _FB_USES_NLS; 1814 _FB_USES_NLS;
1882 1815
@@ -1885,24 +1818,12 @@ void BScreen::showGeometry(int gx, int gy) {
1885 "W: %4d x H: %4d", 1818 "W: %4d x H: %4d",
1886 "Format for width and height window, %4d for width, and %4d for height").c_str(), 1819 "Format for width and height window, %4d for width, and %4d for height").c_str(),
1887 gx, gy); 1820 gx, gy);
1888 1821 m_geom_window.showText(label);
1889 m_geom_window.clear();
1890
1891 //!! TODO: geom window again?! repeated
1892 focusedWinFrameTheme()->font().drawText(m_geom_window, screenNumber(),
1893 focusedWinFrameTheme()->iconbarTheme().text().textGC(),
1894 label, strlen(label),
1895 focusedWinFrameTheme()->bevelWidth(),
1896 focusedWinFrameTheme()->bevelWidth() +
1897 focusedWinFrameTheme()->font().ascent());
1898} 1822}
1899 1823
1900 1824
1901void BScreen::hideGeometry() { 1825void BScreen::hideGeometry() {
1902 if (geom_visible) { 1826 m_geom_window.hide();
1903 m_geom_window.hide();
1904 geom_visible = false;
1905 }
1906} 1827}
1907 1828
1908void BScreen::setLayer(FbTk::XLayerItem &item, int layernum) { 1829void BScreen::setLayer(FbTk::XLayerItem &item, int layernum) {
@@ -1950,93 +1871,14 @@ void BScreen::renderGeomWindow() {
1950 _FB_XTEXT(Screen, GeometrySpacing, 1871 _FB_XTEXT(Screen, GeometrySpacing,
1951 "W: %04d x H: %04d", "Representative maximum sized text for width and height dialog").c_str(), 1872 "W: %04d x H: %04d", "Representative maximum sized text for width and height dialog").c_str(),
1952 0, 0); 1873 0, 0);
1953 1874 m_geom_window.resize(label);
1954 int geom_h = focusedWinFrameTheme()->font().height() + 1875 m_geom_window.reconfigTheme();
1955 focusedWinFrameTheme()->bevelWidth()*2;
1956 int geom_w = focusedWinFrameTheme()->font().textWidth(label, strlen(label))
1957 + focusedWinFrameTheme()->bevelWidth()*2;
1958 m_geom_window.resize(geom_w, geom_h);
1959
1960 m_geom_window.setBorderWidth(focusedWinFrameTheme()->border().width());
1961 m_geom_window.setBorderColor(focusedWinFrameTheme()->border().color());
1962
1963
1964 Pixmap tmp = geom_pixmap;
1965
1966 if (focusedWinFrameTheme()->iconbarTheme().texture().type() &
1967 FbTk::Texture::PARENTRELATIVE) {
1968 if (!focusedWinFrameTheme()->titleTexture().usePixmap()) {
1969 geom_pixmap = None;
1970 m_geom_window.setBackgroundColor(
1971 focusedWinFrameTheme()->titleTexture().color());
1972 } else {
1973 geom_pixmap = imageControl().renderImage(m_geom_window.width(),
1974 m_geom_window.height(),
1975 focusedWinFrameTheme()->titleTexture());
1976 m_geom_window.setBackgroundPixmap(geom_pixmap);
1977 }
1978 } else {
1979 if (!focusedWinFrameTheme()->iconbarTheme().texture().usePixmap()) {
1980 geom_pixmap = None;
1981 m_geom_window.setBackgroundColor(
1982 focusedWinFrameTheme()->iconbarTheme().texture().color());
1983 } else {
1984 geom_pixmap = imageControl().renderImage(m_geom_window.width(),
1985 m_geom_window.height(),
1986 focusedWinFrameTheme()->iconbarTheme().texture());
1987 m_geom_window.setBackgroundPixmap(geom_pixmap);
1988 }
1989 }
1990
1991 if (tmp)
1992 imageControl().removeImage(tmp);
1993
1994} 1876}
1995 1877
1996 1878
1997void BScreen::renderPosWindow() { 1879void BScreen::renderPosWindow() {
1998 1880 m_pos_window.resize("0:00000 x 0:00000");
1999 int pos_h = focusedWinFrameTheme()->font().height() + 1881 m_pos_window.reconfigTheme();
2000 focusedWinFrameTheme()->bevelWidth()*2;
2001 int pos_w = focusedWinFrameTheme()->font().textWidth("0:00000 x 0:00000",
2002 17) +
2003 focusedWinFrameTheme()->bevelWidth()*2;
2004 m_pos_window.resize(pos_w, pos_h);
2005
2006 m_pos_window.setBorderWidth(focusedWinFrameTheme()->border().width());
2007 m_pos_window.setBorderColor(focusedWinFrameTheme()->border().color());
2008
2009
2010 Pixmap tmp = pos_pixmap;
2011
2012 if (focusedWinFrameTheme()->iconbarTheme().texture().type() &
2013 FbTk::Texture::PARENTRELATIVE) {
2014 if (!focusedWinFrameTheme()->titleTexture().usePixmap()) {
2015 pos_pixmap = None;
2016 m_pos_window.setBackgroundColor(
2017 focusedWinFrameTheme()->titleTexture().color());
2018 } else {
2019 pos_pixmap = imageControl().renderImage(m_pos_window.width(),
2020 m_pos_window.height(),
2021 focusedWinFrameTheme()->titleTexture());
2022 m_pos_window.setBackgroundPixmap(pos_pixmap);
2023 }
2024 } else {
2025 if (!focusedWinFrameTheme()->iconbarTheme().texture().usePixmap()) {
2026 pos_pixmap = None;
2027 m_pos_window.setBackgroundColor(
2028 focusedWinFrameTheme()->iconbarTheme().texture().color());
2029 } else {
2030 pos_pixmap = imageControl().renderImage(m_pos_window.width(),
2031 m_pos_window.height(),
2032 focusedWinFrameTheme()->iconbarTheme().texture());
2033 m_pos_window.setBackgroundPixmap(pos_pixmap);
2034 }
2035 }
2036
2037 if (tmp)
2038 imageControl().removeImage(tmp);
2039
2040} 1882}
2041 1883
2042void BScreen::updateSize() { 1884void BScreen::updateSize() {
diff --git a/src/Screen.hh b/src/Screen.hh
index 99c23ff..a503285 100644
--- a/src/Screen.hh
+++ b/src/Screen.hh
@@ -30,6 +30,7 @@
30#include "RootTheme.hh" 30#include "RootTheme.hh"
31#include "WinButtonTheme.hh" 31#include "WinButtonTheme.hh"
32#include "FbWinFrameTheme.hh" 32#include "FbWinFrameTheme.hh"
33#include "OSDWindow.hh"
33 34
34#include "FbTk/MenuTheme.hh" 35#include "FbTk/MenuTheme.hh"
35#include "FbTk/EventHandler.hh" 36#include "FbTk/EventHandler.hh"
@@ -496,11 +497,9 @@ private:
496 497
497 FbTk::MultLayers m_layermanager; 498 FbTk::MultLayers m_layermanager;
498 499
499 bool root_colormap_installed, managed, geom_visible, pos_visible; 500 bool root_colormap_installed, managed;
500 501
501 GC opGC; 502 GC opGC;
502 Pixmap geom_pixmap, pos_pixmap;
503
504 503
505 504
506 std::auto_ptr<FbTk::ImageControl> m_image_control; 505 std::auto_ptr<FbTk::ImageControl> m_image_control;
@@ -532,7 +531,8 @@ private:
532 std::auto_ptr<RootTheme> m_root_theme; 531 std::auto_ptr<RootTheme> m_root_theme;
533 532
534 FbRootWindow m_root_window; 533 FbRootWindow m_root_window;
535 FbTk::FbWindow m_geom_window, m_pos_window, m_dummy_window; 534 OSDWindow m_geom_window, m_pos_window;
535 FbTk::FbWindow m_dummy_window;
536 536
537 struct ScreenResource { 537 struct ScreenResource {
538 ScreenResource(FbTk::ResourceManager &rm, const std::string &scrname, 538 ScreenResource(FbTk::ResourceManager &rm, const std::string &scrname,