aboutsummaryrefslogtreecommitdiff
path: root/src/IconButton.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-08-12 01:19:22 (GMT)
committerfluxgen <fluxgen>2003-08-12 01:19:22 (GMT)
commit060219fca20ff02629d04fd41abfe7c8a36446be (patch)
tree6b4af2a4403a74a557fa3fb3a18bfe5ce21b1dc2 /src/IconButton.cc
parent7be86791e445a6d586528212d905cb02cd96abc3 (diff)
downloadfluxbox_pavel-060219fca20ff02629d04fd41abfe7c8a36446be.zip
fluxbox_pavel-060219fca20ff02629d04fd41abfe7c8a36446be.tar.bz2
extra checks
Diffstat (limited to 'src/IconButton.cc')
-rw-r--r--src/IconButton.cc20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/IconButton.cc b/src/IconButton.cc
index ba6fff8..d7bfd35 100644
--- a/src/IconButton.cc
+++ b/src/IconButton.cc
@@ -20,7 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: IconButton.cc,v 1.2 2003/08/12 00:16:16 fluxgen Exp $ 23// $Id: IconButton.cc,v 1.3 2003/08/12 01:19:22 fluxgen Exp $
24 24
25#include "IconButton.hh" 25#include "IconButton.hh"
26 26
@@ -41,9 +41,6 @@
41#include <X11/extensions/shape.h> 41#include <X11/extensions/shape.h>
42#endif // SHAPE 42#endif // SHAPE
43 43
44#include <iostream>
45using namespace std;
46
47IconButton::IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font, 44IconButton::IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font,
48 FluxboxWindow &win): 45 FluxboxWindow &win):
49 TextButton(parent, font, win.winClient().title()), 46 TextButton(parent, font, win.winClient().title()),
@@ -98,14 +95,20 @@ void IconButton::update(FbTk::Subject *subj) {
98 // icon pixmap was updated, 95 // icon pixmap was updated,
99 // so we refresh everything 96 // so we refresh everything
100 97
98 // we need to check our client first
99 if (m_win.clientList().size() == 0)
100 return;
101
101 XWMHints *hints = XGetWMHints(FbTk::App::instance()->display(), m_win.winClient().window()); 102 XWMHints *hints = XGetWMHints(FbTk::App::instance()->display(), m_win.winClient().window());
102 if (hints == 0) 103 if (hints == 0)
103 return; 104 return;
104 105
105 if (hints->flags & IconPixmapHint) { 106 if (hints->flags & IconPixmapHint && hints->icon_pixmap != 0) {
106 // setup icon window 107 // setup icon window
107 m_icon_window.show(); 108 m_icon_window.show();
108 m_icon_window.resize(height(), height() - m_icon_window.y()); 109 int new_height = height() - m_icon_window.y();
110 int new_width = height();
111 m_icon_window.resize(new_width ? new_width : 1, new_height ? new_height : 1);
109 112
110 m_icon_pixmap.copy(hints->icon_pixmap); 113 m_icon_pixmap.copy(hints->icon_pixmap);
111 m_icon_pixmap.scale(m_icon_window.height(), m_icon_window.height()); 114 m_icon_pixmap.scale(m_icon_window.height(), m_icon_window.height());
@@ -113,6 +116,7 @@ void IconButton::update(FbTk::Subject *subj) {
113 m_icon_window.setBackgroundPixmap(m_icon_pixmap.drawable()); 116 m_icon_window.setBackgroundPixmap(m_icon_pixmap.drawable());
114 } else { 117 } else {
115 // no icon pixmap 118 // no icon pixmap
119 m_icon_window.move(0, 0);
116 m_icon_window.hide(); 120 m_icon_window.hide();
117 m_icon_pixmap = 0; 121 m_icon_pixmap = 0;
118 } 122 }
@@ -145,6 +149,10 @@ void IconButton::update(FbTk::Subject *subj) {
145void IconButton::setupWindow() { 149void IconButton::setupWindow() {
146 150
147 m_icon_window.clear(); 151 m_icon_window.clear();
152
153 if (m_win.clientList().size() == 0)
154 return;
155
148 setText(m_win.winClient().title()); 156 setText(m_win.winClient().title());
149 // draw with x offset and y offset 157 // draw with x offset and y offset
150 drawText(m_icon_window.x() + m_icon_window.width() + 1); 158 drawText(m_icon_window.x() + m_icon_window.width() + 1);