From cd28ddec7b719fd10f5b7740cf25fa77891526ae Mon Sep 17 00:00:00 2001 From: markt Date: Sun, 25 Mar 2007 06:53:09 +0000 Subject: added session.screen0.tabs.usePixmap --- ChangeLog | 4 ++++ src/FbWinFrame.cc | 15 +++++---------- src/FbWinFrame.hh | 10 ++++------ src/FocusControl.cc | 3 ++- src/Screen.cc | 1 + src/Screen.hh | 2 ++ src/WinClient.cc | 4 ++++ src/Window.cc | 37 ++++++++++++++----------------------- src/Window.hh | 3 +-- 9 files changed, 37 insertions(+), 42 deletions(-) diff --git a/ChangeLog b/ChangeLog index 443f335..1c52fda 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ (Format: Year/Month/Day) Changes for 1.1: +*07/03/25: + * Added new resource session.screen.tabs.usePixmap that puts the window's + icon in the tab, if available. This is on by default. (Mark) + Window.cc FbWinFrame.cc/hh WinClient.cc Screen.cc/hh *07/03/24: * Updated French translations (thanks Ulrich Etile) nls/fr_FR/Translation.m diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 99dd93d..84f47f4 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -33,6 +33,7 @@ #include "FbWinFrameTheme.hh" #include "Screen.hh" +#include "IconButton.hh" #include "Container.hh" #ifdef SHAPE @@ -619,11 +620,9 @@ void FbWinFrame::removeAllButtons() { } } -FbWinFrame::ButtonId FbWinFrame::createTab(const string &title, FbTk::Command *command, - int tabs_padding) { - FbTk::TextButton *button = new FbTk::TextButton(m_tab_container, - theme().font(), - title); +IconButton *FbWinFrame::createTab(Focusable &client) { + IconButton *button = new IconButton(m_tab_container, theme().font(), + client); button->show(); button->setEventMask(ExposureMask | ButtonPressMask | @@ -631,10 +630,6 @@ FbWinFrame::ButtonId FbWinFrame::createTab(const string &title, FbTk::Command *c EnterWindowMask); FbTk::EventManager::instance()->add(*button, button->window()); - FbTk::RefCount refcmd(command); - button->setOnClick(refcmd); - - button->setTextPadding(tabs_padding); button->setJustify(theme().justify()); button->setBorderColor(theme().border().color()); button->setBorderWidth(m_window.borderWidth()); @@ -647,7 +642,7 @@ FbWinFrame::ButtonId FbWinFrame::createTab(const string &title, FbTk::Command *c return button; } -void FbWinFrame::removeTab(ButtonId btn) { +void FbWinFrame::removeTab(IconButton *btn) { if (btn == m_current_label) m_current_label = 0; diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index 182add4..a75d8a1 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh @@ -42,6 +42,8 @@ class Shape; class FbWinFrameTheme; class BScreen; +class IconButton; +class Focusable; namespace FbTk { class TextButton; @@ -70,8 +72,6 @@ public: }; - typedef FbTk::TextButton *ButtonId; ///< defines a button id - /// create a top level window FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl, FbTk::XLayer &layer, @@ -141,10 +141,9 @@ public: /// remove all buttons from titlebar void removeAllButtons(); /// adds a button to label window with specified title and command - ButtonId createTab(const std::string &title, FbTk::Command *cmd, int tab_padding); - // void addLabelButton(FbTk::TextButton &btn); + IconButton *createTab(Focusable &client); /// removes a specific button from label window - void removeTab(ButtonId id); + void removeTab(IconButton *id); /// move label button to the left void moveLabelButtonLeft(FbTk::TextButton &btn); /// move label button to the right @@ -322,7 +321,6 @@ private: m_buttons_right; ///< buttons to the right typedef std::list LabelList; FbTk::TextButton *m_current_label; ///< which client button is focused at the moment - std::string m_titletext; ///< text to be displayed int m_label int m_bevel; ///< bevel between titlebar items and titlebar bool m_use_titlebar; ///< if we should use titlebar bool m_use_tabs; ///< if we should use tabs (turns them off in external mode only) diff --git a/src/FocusControl.cc b/src/FocusControl.cc index e653e22..71b289b 100644 --- a/src/FocusControl.cc +++ b/src/FocusControl.cc @@ -291,7 +291,8 @@ Focusable *FocusControl::lastFocusedWindow(int workspace) { * Stuck, iconic etc don't matter within a group */ WinClient *FocusControl::lastFocusedWindow(FluxboxWindow &group, WinClient *ignore_client) { - if (m_focused_list.empty()) return 0; + if (m_focused_list.empty() || m_screen.isShuttingdown()) + return 0; Focusables::iterator it = m_focused_list.begin(); Focusables::iterator it_end = m_focused_list.end(); diff --git a/src/Screen.cc b/src/Screen.cc index fca932d..a0bc01d 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -325,6 +325,7 @@ BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm, altscrname+".overlay.CapStyle"), scroll_action(rm, "", scrname+".windowScrollAction", altscrname+".WindowScrollAction"), scroll_reverse(rm, false, scrname+".windowScrollReverse", altscrname+".WindowScrollReverse"), + tabs_use_pixmap(rm, true, scrname+".tabs.usePixmap", altscrname+".Tabs.UsePixmap"), max_over_tabs(rm, false, scrname+".tabs.maxOver", altscrname+".Tabs.MaxOver"), default_internal_tabs(rm, false /* TODO: autoconf option? */ , scrname+".tabs.intitlebar", altscrname+".Tabs.InTitlebar") { diff --git a/src/Screen.hh b/src/Screen.hh index 352a015..53198fc 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -147,6 +147,7 @@ public: inline const std::string &getScrollAction() const { return *resource.scroll_action; } inline const bool getScrollReverse() const { return *resource.scroll_reverse; } inline const bool getDefaultInternalTabs() const { return *resource.default_internal_tabs; } + inline const bool getTabsUsePixmap() const { return *resource.tabs_use_pixmap; } inline const bool getMaxOverTabs() const { return *resource.max_over_tabs; } inline unsigned int getTabWidth() const { return *resource.tab_width; } @@ -468,6 +469,7 @@ private: FbTk::Resource gc_cap_style; FbTk::Resource scroll_action; FbTk::Resource scroll_reverse; + FbTk::Resource tabs_use_pixmap; FbTk::Resource max_over_tabs; FbTk::Resource default_internal_tabs; diff --git a/src/WinClient.cc b/src/WinClient.cc index 6ede82c..4e491f0 100644 --- a/src/WinClient.cc +++ b/src/WinClient.cc @@ -353,11 +353,15 @@ void WinClient::updateTitle() { return; m_title = string(Xutil::getWMName(window()), 0, 512); + titleSig().notify(); + if (fbwindow()) + fbwindow()->updateTitleFromClient(*this); } void WinClient::setTitle(FbTk::FbString &title) { m_title = title; m_title_override = true; + titleSig().notify(); if (fbwindow()) fbwindow()->updateTitleFromClient(*this); } diff --git a/src/Window.cc b/src/Window.cc index ce14d08..560bf96 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -42,8 +42,8 @@ #include "StringUtil.hh" #include "FocusControl.hh" #include "Layer.hh" +#include "IconButton.hh" -#include "FbTk/TextButton.hh" #include "FbTk/Compose.hh" #include "FbTk/EventManager.hh" #include "FbTk/KeyUtil.hh" @@ -739,7 +739,7 @@ bool FluxboxWindow::removeClient(WinClient &client) { FbTk::EventManager &evm = *FbTk::EventManager::instance(); evm.remove(client.window()); - FbTk::TextButton *label_btn = m_labelbuttons[&client]; + IconButton *label_btn = m_labelbuttons[&client]; if (label_btn != 0) { frame().removeTab(label_btn); label_btn = 0; @@ -1015,8 +1015,8 @@ void FluxboxWindow::associateClientWindow(bool use_attrs, int x, int y, unsigned int width, unsigned int height, int gravity, unsigned int client_bw) { - updateTitleFromClient(*m_client); - updateIconNameFromClient(*m_client); + m_client->updateTitle(); + m_client->updateIconTitle(); if (use_attrs) frame().moveResizeForClient(x, y, @@ -1099,21 +1099,12 @@ void FluxboxWindow::reconfigure() { /// update current client title and title in our frame void FluxboxWindow::updateTitleFromClient(WinClient &client) { - client.updateTitle(); - // compare old title with new and see if we need to update - // graphics - if (m_labelbuttons[&client]->text() != client.title()) { - m_labelbuttons[&client]->setText(client.title()); - if (&client == m_client) - frame().setFocusTitle(client.title()); + if (&client == m_client) { + frame().setFocusTitle(client.title()); + titleSig().notify(); } } -/// update icon title from client -void FluxboxWindow::updateIconNameFromClient(WinClient &client) { - client.updateIconTitle(); -} - void FluxboxWindow::updateMWMHintsFromClient(WinClient &client) { const WinClient::MwmHints *hint = client.getMwmHint(); @@ -2457,8 +2448,7 @@ void FluxboxWindow::propertyNotifyEvent(WinClient &client, Atom atom) { // update icon title and then do normal XA_WM_NAME stuff client.updateIconTitle(); case XA_WM_NAME: - updateTitleFromClient(client); - titleSig().notify(); + client.updateTitle(); break; case XA_WM_NORMAL_HINTS: { @@ -4191,13 +4181,14 @@ void FluxboxWindow::ungrabPointer(Time time) { void FluxboxWindow::associateClient(WinClient &client) { - FbWinFrame::ButtonId btn = frame().createTab(client.title(), - new SetClientCmd(client), - Fluxbox::instance()->getTabsPadding()); - - m_labelbuttons[&client] = btn; + IconButton *btn = frame().createTab(client); + FbTk::RefCount setcmd(new SetClientCmd(client)); + btn->setOnClick(setcmd, 1); + btn->setTextPadding(Fluxbox::instance()->getTabsPadding()); + btn->setPixmap(screen().getTabsUsePixmap()); + m_labelbuttons[&client] = btn; FbTk::EventManager &evm = *FbTk::EventManager::instance(); diff --git a/src/Window.hh b/src/Window.hh index 9991bb6..d04f171 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -456,7 +456,6 @@ private: /// gets title string from client window and updates frame's title void updateTitleFromClient(WinClient &client); /// gets icon name from client window - void updateIconNameFromClient(WinClient &client); void updateMWMHintsFromClient(WinClient &client); void updateBlackboxHintsFromClient(const WinClient &client); void updateRememberStateFromClient(WinClient &client); @@ -529,7 +528,7 @@ private: ClientList m_clientlist; WinClient *m_client; ///< current client - typedef std::map Client2ButtonMap; + typedef std::map Client2ButtonMap; Client2ButtonMap m_labelbuttons; // just temporary solution -- cgit v0.11.2