From b9af026688f0945196582af5773d62f5df3f97f3 Mon Sep 17 00:00:00 2001 From: simonb Date: Mon, 17 Apr 2006 23:34:01 +0000 Subject: iconbutton handling fixes --- ChangeLog | 4 ++++ src/IconButton.cc | 33 ++++++++++++++------------------- src/IconbarTool.cc | 7 ------- src/WinButton.cc | 27 ++++++++++----------------- src/WinClient.cc | 10 ++++++++++ src/WinClient.hh | 7 +++++++ src/Window.cc | 5 +++++ src/Window.hh | 5 +++++ 8 files changed, 55 insertions(+), 43 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3d86d64..c5593f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ (Format: Year/Month/Day) Changes for 0.9.16: +*06/04/18: + * Fix iconbar updates (icon and title) + (Thanks Mark Tiefenbruck, mark at tiefenbruck dot org) + WinClient.hh/cc Window.hh/cc IconButton.cc IconbarTool.cc WinButton.cc *06/04/17: * Fix toolbar transparency when autohide enabled (Simon) Toolbar.cc Container.hh/cc ToolbarItem.hh/cc *Tool.hh/cc diff --git a/src/IconButton.cc b/src/IconButton.cc index 015065c..11b2c02 100644 --- a/src/IconButton.cc +++ b/src/IconButton.cc @@ -170,6 +170,7 @@ IconButton::IconButton(const IconbarTool& tool, const FbTk::FbWindow &parent, } m_win.hintSig().attach(this); + m_win.titleSig().attach(this); FbTk::EventManager::instance()->add(*this, m_icon_window); @@ -236,13 +237,9 @@ void IconButton::update(FbTk::Subject *subj) { Display *display = FbTk::App::instance()->display(); - XWMHints *hints = XGetWMHints(display, m_win.winClient().window()); - if (hints == 0) - return; - int screen = m_win.screen().screenNumber(); - if (m_use_pixmap && (hints->flags & IconPixmapHint) && hints->icon_pixmap != 0) { + if (m_use_pixmap && m_win.usePixmap()) { // setup icon window m_icon_window.show(); unsigned int w = width(); @@ -262,7 +259,7 @@ void IconButton::update(FbTk::Subject *subj) { neww = newh; m_icon_window.moveResize(iconx, icony, neww, newh); - m_icon_pixmap.copy(hints->icon_pixmap, DefaultDepth(display, screen), screen); + m_icon_pixmap.copy(m_win.iconPixmap().drawable(), DefaultDepth(display, screen), screen); m_icon_pixmap.scale(m_icon_window.width(), m_icon_window.height()); // rotate the icon or not?? lets go not for now, and see what they say... @@ -277,29 +274,27 @@ void IconButton::update(FbTk::Subject *subj) { m_icon_pixmap = 0; } - if(m_use_pixmap && (hints->flags & IconMaskHint)) { - m_icon_mask.copy(hints->icon_mask, 0, 0); + if(m_use_pixmap && m_win.useMask()) { + m_icon_mask.copy(m_win.iconMask().drawable(), 0, 0); m_icon_mask.scale(m_icon_pixmap.width(), m_icon_pixmap.height()); m_icon_mask.rotate(orientation()); } else m_icon_mask = 0; - XFree(hints); - hints = 0; - #ifdef SHAPE - if (m_icon_mask.drawable() != 0) { - XShapeCombineMask(display, - m_icon_window.drawable(), - ShapeBounding, - 0, 0, - m_icon_mask.drawable(), - ShapeSet); - } + XShapeCombineMask(display, + m_icon_window.drawable(), + ShapeBounding, + 0, 0, + m_icon_mask.drawable(), + ShapeSet); #endif // SHAPE + if (subj == &(m_win.titleSig())) + setText(m_win.title()); + if (subj != 0) { setupWindow(); } else { diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index e2eede4..82fdf26 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc @@ -596,12 +596,6 @@ void IconbarTool::update(FbTk::Subject *subj) { return; - } else if (subj == &(winsubj->win().titleSig())) { - IconButton *button = findButton(winsubj->win()); - if (button == 0) - return; - button->setText(winsubj->win().title()); - return; } else { // signal not handled return; @@ -897,7 +891,6 @@ void IconbarTool::addWindow(FluxboxWindow &win) { win.dieSig().attach(this); win.workspaceSig().attach(this); win.stateSig().attach(this); - win.titleSig().attach(this); } diff --git a/src/WinButton.cc b/src/WinButton.cc index 4f50935..496e63d 100644 --- a/src/WinButton.cc +++ b/src/WinButton.cc @@ -319,26 +319,19 @@ void WinButton::clear() { Display* display = m_listen_to.fbWindow().display(); int screen = m_listen_to.screen().screenNumber(); - XWMHints* hints = XGetWMHints(display, m_listen_to.winClient().window()); - if (hints == 0) { + if (m_listen_to.usePixmap()) { + m_icon_pixmap.copy(m_listen_to.iconPixmap().drawable(), + DefaultDepth(display, screen), screen); + m_icon_pixmap.scale(width() - 4, height() - 4); + } else m_icon_pixmap.release(); - m_icon_mask.release(); - } else { - if ((hints->flags & IconPixmapHint) && hints->icon_pixmap != 0) { - m_icon_pixmap.copy(hints->icon_pixmap, - DefaultDepth(display, screen), screen); - m_icon_pixmap.scale(width() - 4, height() - 4); - } else - m_icon_pixmap.release(); - if ((hints->flags & IconMaskHint)) { - m_icon_mask.copy(hints->icon_mask, 0, 0); - m_icon_mask.scale(width() - 4, height() - 4); - } else - m_icon_mask.release(); - } + if (m_listen_to.useMask()) { + m_icon_mask.copy(m_listen_to.iconMask().drawable(), 0, 0); + m_icon_mask.scale(width() - 4, height() - 4); + } else + m_icon_mask.release(); - XFree(hints); } drawType(); diff --git a/src/WinClient.cc b/src/WinClient.cc index b1187a0..056013a 100644 --- a/src/WinClient.cc +++ b/src/WinClient.cc @@ -484,6 +484,16 @@ void WinClient::updateWMHints() { } else window_group = None; + if ((bool)(wmhint->flags & IconPixmapHint) && wmhint->icon_pixmap != 0) + m_icon_pixmap.copy(wmhint->icon_pixmap, 0, 0); + else + m_icon_pixmap = 0; + + if ((bool)(wmhint->flags & IconMaskHint) && wmhint->icon_mask != 0) + m_icon_mask.copy(wmhint->icon_mask, 0, 0); + else + m_icon_mask = 0; + XFree(wmhint); } } diff --git a/src/WinClient.hh b/src/WinClient.hh index 0f74695..d092aa7 100644 --- a/src/WinClient.hh +++ b/src/WinClient.hh @@ -128,6 +128,10 @@ public: return (m_win == &win); } + const FbTk::FbPixmap &iconPixmap() const { return m_icon_pixmap; } + const FbTk::FbPixmap &iconMask() const { return m_icon_mask; } + const bool usePixmap() const { return m_icon_pixmap.drawable() != None; } + const bool useMask() const { return m_icon_mask.drawable() != None; } inline const std::string &title() const { return m_title; } inline const std::string &iconTitle() const { return m_icon_title; } @@ -192,6 +196,9 @@ private: std::string m_title, m_icon_title; std::string m_class_name, m_instance_name; + FbTk::FbPixmap m_icon_pixmap; + FbTk::FbPixmap m_icon_mask; + FluxboxWindow::BlackboxHints *m_blackbox_hint; MwmHints *m_mwm_hint; diff --git a/src/Window.cc b/src/Window.cc index a165d90..e766cab 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -3680,6 +3680,11 @@ FbTk::Menu &FluxboxWindow::menu() { return screen().windowMenu(); } +const FbTk::FbPixmap &FluxboxWindow::iconPixmap() const { return m_client->iconPixmap(); } +const FbTk::FbPixmap &FluxboxWindow::iconMask() const { return m_client->iconMask(); } +const bool FluxboxWindow::usePixmap() const { return m_client->usePixmap(); } +const bool FluxboxWindow::useMask() const { return m_client->useMask(); } + const FbTk::Menu &FluxboxWindow::menu() const { return screen().windowMenu(); } diff --git a/src/Window.hh b/src/Window.hh index 44214c7..9508d5c 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -331,6 +331,11 @@ public: const FbTk::FbWindow &parent() const { return m_parent; } FbTk::FbWindow &parent() { return m_parent; } + const FbTk::FbPixmap &iconPixmap() const; + const FbTk::FbPixmap &iconMask() const; + const bool usePixmap() const; + const bool useMask() const; + const std::string &title() const; const std::string &iconTitle() const; inline int x() const { return frame().x(); } -- cgit v0.11.2