From ec3125aeb95a06f08cd4895c5b7c3a8911c1b368 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Mon, 7 Jan 2008 12:08:56 -0800 Subject: switch FbWinFrameTheme to use FocusableTheme --- src/CommandDialog.cc | 12 +++--- src/Ewmh.cc | 4 +- src/FbWinFrame.cc | 97 +++++++++++++++++++------------------------ src/FbWinFrame.hh | 8 ++-- src/FbWinFrameTheme.cc | 46 +++++++-------------- src/FbWinFrameTheme.hh | 60 +++++++++------------------ src/Screen.cc | 110 +++++++++++++++++++++++++++---------------------- src/Screen.hh | 10 +++-- src/Window.cc | 20 +++++---- src/Window.hh | 6 ++- 10 files changed, 173 insertions(+), 200 deletions(-) diff --git a/src/CommandDialog.cc b/src/CommandDialog.cc index 17bd771..1c9005e 100644 --- a/src/CommandDialog.cc +++ b/src/CommandDialog.cc @@ -50,8 +50,8 @@ using std::out_of_range; CommandDialog::CommandDialog(BScreen &screen, const string &title, const string precommand) : FbTk::FbWindow(screen.rootWindow().screenNumber(), 0, 0, 200, 1, ExposureMask), - m_textbox(*this, screen.winFrameTheme()->font(), ""), - m_label(*this, screen.winFrameTheme()->font(), title), + m_textbox(*this, screen.focusedWinFrameTheme()->font(), ""), + m_label(*this, screen.focusedWinFrameTheme()->font(), title), m_gc(m_textbox), m_screen(screen), m_move_x(0), @@ -190,12 +190,12 @@ void CommandDialog::tabComplete() { void CommandDialog::render() { Pixmap tmp = m_pixmap; - if (!m_screen.winFrameTheme()->focusedIconbarTheme().texture().usePixmap()) { - m_label.setBackgroundColor(m_screen.winFrameTheme()->focusedIconbarTheme().texture().color()); + if (!m_screen.focusedWinFrameTheme()->iconbarTheme().texture().usePixmap()) { + m_label.setBackgroundColor(m_screen.focusedWinFrameTheme()->iconbarTheme().texture().color()); m_pixmap = 0; } else { m_pixmap = m_screen.imageControl().renderImage(m_label.width(), m_label.height(), - m_screen.winFrameTheme()->focusedIconbarTheme().texture()); + m_screen.focusedWinFrameTheme()->iconbarTheme().texture()); m_label.setBackgroundPixmap(m_pixmap); } @@ -210,7 +210,7 @@ void CommandDialog::init() { // setup label // we listen to motion notify too m_label.setEventMask(m_label.eventMask() | ButtonPressMask | ButtonMotionMask); - m_label.setGC(m_screen.winFrameTheme()->focusedIconbarTheme().text().textGC()); + m_label.setGC(m_screen.focusedWinFrameTheme()->iconbarTheme().text().textGC()); m_label.show(); // setup text box diff --git a/src/Ewmh.cc b/src/Ewmh.cc index f0b23b3..953d474 100644 --- a/src/Ewmh.cc +++ b/src/Ewmh.cc @@ -974,8 +974,8 @@ bool Ewmh::checkClientMessage(const XClientMessageEvent &ce, } else if (ce.message_type == m_net->request_frame_extents) { if (!screen) return true; - FbTk::ThemeProxy &theme = screen->winFrameTheme(); - unsigned int bw = theme->border(true).width(); + FbTk::ThemeProxy &theme = screen->focusedWinFrameTheme(); + unsigned int bw = theme->border().width(); long title_h = theme->titleHeight() || theme->font().height() + 2*theme->bevelWidth() + 2 + 2*bw; long handle_h = theme->handleWidth() + 2*bw; diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 5cc7631..ea1236a 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -28,9 +28,10 @@ #include "FbTk/Compose.hh" #include "FbTk/Transparent.hh" #include "FbTk/CompareEqual.hh" + #include "FbWinFrameTheme.hh" #include "Screen.hh" - +#include "FocusableTheme.hh" #include "IconButton.hh" #include @@ -40,7 +41,7 @@ using std::mem_fun; using std::string; FbWinFrame::FbWinFrame(BScreen &screen, - FbTk::ThemeProxy &theme, + FocusableTheme &theme, FbTk::ImageControl &imgctrl, FbTk::XLayer &layer, int x, int y, @@ -90,8 +91,8 @@ FbWinFrame::FbWinFrame(BScreen &screen, m_button_size(1), m_height_before_shade(1), m_shaded(false), - m_focused_alpha(AlphaAcc(*theme, &FbWinFrameTheme::focusedAlpha)), - m_unfocused_alpha(AlphaAcc(*theme, &FbWinFrameTheme::unfocusedAlpha)), + m_focused_alpha(AlphaAcc(*theme.focusedTheme(), &FbWinFrameTheme::alpha)), + m_unfocused_alpha(AlphaAcc(*theme.unfocusedTheme(), &FbWinFrameTheme::alpha)), m_shape(m_window, theme->shapePlace()), m_disable_themeshape(false) { init(); @@ -119,7 +120,7 @@ bool FbWinFrame::setTabMode(TabMode tabmode) { if (tabmode == EXTERNAL) { m_label.show(); m_tab_container.setBorderWidth(m_window.borderWidth()); - m_tab_container.setBorderColor(theme()->border(m_focused).color()); + m_tab_container.setBorderColor(theme()->border().color()); m_tab_container.setEventMask( ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | ExposureMask | @@ -486,10 +487,11 @@ void FbWinFrame::setFocus(bool newvalue) { } if (m_decoration_mask & DECORM_BORDER && - (theme()->border(true).width() != theme()->border(false).width() || - theme()->border(true).color().pixel() != - theme()->border(false).color().pixel())) - setBorderWidth(theme()->border(newvalue).width()); + (theme().focusedTheme()->border().width() != + theme().unfocusedTheme()->border().width() || + theme().focusedTheme()->border().color().pixel() != + theme().unfocusedTheme()->border().color().pixel())) + setBorderWidth(theme()->border().width()); applyAll(); clearAll(); @@ -1125,22 +1127,22 @@ void FbWinFrame::renderTitlebar() { } // render pixmaps - render(theme()->titleFocusTexture(), m_title_focused_color, + render(theme().focusedTheme()->titleTexture(), m_title_focused_color, m_title_focused_pm, m_titlebar.width(), m_titlebar.height()); - render(theme()->titleUnfocusTexture(), m_title_unfocused_color, + render(theme().unfocusedTheme()->titleTexture(), m_title_unfocused_color, m_title_unfocused_pm, m_titlebar.width(), m_titlebar.height()); //!! TODO: don't render label if internal tabs - render(theme()->focusedIconbarTheme()->texture(), m_label_focused_color, - m_label_focused_pm, + render(theme().focusedTheme()->iconbarTheme()->texture(), + m_label_focused_color, m_label_focused_pm, m_label.width(), m_label.height()); - render(theme()->unfocusedIconbarTheme()->texture(), m_label_unfocused_color, - m_label_unfocused_pm, + render(theme().unfocusedTheme()->iconbarTheme()->texture(), + m_label_unfocused_color, m_label_unfocused_pm, m_label.width(), m_label.height()); } @@ -1151,13 +1153,13 @@ void FbWinFrame::renderTabContainer() { return; } - const FbTk::Texture *tc_focused = &theme()->focusedIconbarTheme()->texture(); - const FbTk::Texture *tc_unfocused = &theme()->unfocusedIconbarTheme()->texture(); + const FbTk::Texture *tc_focused = &theme().focusedTheme()->iconbarTheme()->texture(); + const FbTk::Texture *tc_unfocused = &theme().unfocusedTheme()->iconbarTheme()->texture(); if (m_tabmode == EXTERNAL && tc_focused->type() & FbTk::Texture::PARENTRELATIVE) - tc_focused = &theme()->titleFocusTexture(); + tc_focused = &theme().focusedTheme()->titleTexture(); if (m_tabmode == EXTERNAL && tc_unfocused->type() & FbTk::Texture::PARENTRELATIVE) - tc_unfocused = &theme()->titleUnfocusTexture(); + tc_unfocused = &theme().unfocusedTheme()->titleTexture(); render(*tc_focused, m_tabcontainer_focused_color, m_tabcontainer_focused_pm, @@ -1186,12 +1188,8 @@ void FbWinFrame::applyTitlebar() { m_label.setAlpha(alpha); if (m_tabmode != INTERNAL) { - m_label.setGC(m_focused ? - theme()->focusedIconbarTheme()->text().textGC() : - theme()->unfocusedIconbarTheme()->text().textGC()); - m_label.setJustify(m_focused ? - theme()->focusedIconbarTheme()->text().justify() : - theme()->unfocusedIconbarTheme()->text().justify()); + m_label.setGC(theme()->iconbarTheme()->text().textGC()); + m_label.setJustify(theme()->iconbarTheme()->text().justify()); if (label_pm != 0) m_label.setBackgroundPixmap(label_pm); @@ -1217,18 +1215,19 @@ void FbWinFrame::renderHandles() { return; } - render(theme()->handleFocusTexture(), m_handle_focused_color, + render(theme().focusedTheme()->handleTexture(), m_handle_focused_color, m_handle_focused_pm, m_handle.width(), m_handle.height()); - render(theme()->handleUnfocusTexture(), m_handle_unfocused_color, + render(theme().unfocusedTheme()->handleTexture(), m_handle_unfocused_color, m_handle_unfocused_pm, m_handle.width(), m_handle.height()); - render(theme()->gripFocusTexture(), m_grip_focused_color, m_grip_focused_pm, + render(theme().focusedTheme()->gripTexture(), m_grip_focused_color, + m_grip_focused_pm, m_grip_left.width(), m_grip_left.height()); - render(theme()->gripUnfocusTexture(), m_grip_unfocused_color, + render(theme().unfocusedTheme()->gripTexture(), m_grip_unfocused_color, m_grip_unfocused_pm, m_grip_left.width(), m_grip_left.height()); @@ -1283,11 +1282,11 @@ void FbWinFrame::renderButtons() { return; } - render(theme()->buttonFocusTexture(), m_button_color, + render(theme().focusedTheme()->buttonTexture(), m_button_color, m_button_pm, m_button_size, m_button_size); - render(theme()->buttonUnfocusTexture(), m_button_unfocused_color, + render(theme().unfocusedTheme()->buttonTexture(), m_button_unfocused_color, m_button_unfocused_pm, m_button_size, m_button_size); @@ -1351,24 +1350,14 @@ void FbWinFrame::applyButton(FbTk::Button &btn) { else btn.setPressedColor(m_button_pressed_color); - if (focused()) { // focused - btn.setAlpha(getAlpha(true)); - - btn.setGC(theme()->buttonPicFocusGC()); - if (m_button_pm) - btn.setBackgroundPixmap(m_button_pm); - else - btn.setBackgroundColor(m_button_color); - } else { // unfocused - btn.setAlpha(getAlpha(false)); - - btn.setGC(theme()->buttonPicUnfocusGC()); - if (m_button_unfocused_pm) - btn.setBackgroundPixmap(m_button_unfocused_pm); - else - btn.setBackgroundColor(m_button_unfocused_color); - } - + Pixmap pm = m_focused ? m_button_pm : m_button_unfocused_pm; + btn.setAlpha(getAlpha(m_focused)); + btn.setGC(theme()->buttonPicGC()); + if (pm) + btn.setBackgroundPixmap(pm); + else + btn.setBackgroundColor(m_focused ? m_button_color + : m_button_unfocused_color); } void FbWinFrame::render(const FbTk::Texture &tex, FbTk::Color &col, Pixmap &pm, @@ -1460,21 +1449,21 @@ void FbWinFrame::setBorderWidth(unsigned int border_width) { bw_changes += static_cast(border_width - handle().borderWidth()); window().setBorderWidth(border_width); - window().setBorderColor(theme()->border(m_focused).color()); + window().setBorderColor(theme()->border().color()); setTabMode(NOTSET); titlebar().setBorderWidth(border_width); - titlebar().setBorderColor(theme()->border(m_focused).color()); + titlebar().setBorderColor(theme()->border().color()); handle().setBorderWidth(border_width); - handle().setBorderColor(theme()->border(m_focused).color()); + handle().setBorderColor(theme()->border().color()); gripLeft().setBorderWidth(border_width); - gripLeft().setBorderColor(theme()->border(m_focused).color()); + gripLeft().setBorderColor(theme()->border().color()); gripRight().setBorderWidth(border_width); - gripRight().setBorderColor(theme()->border(m_focused).color()); + gripRight().setBorderColor(theme()->border().color()); if (bw_changes != 0) resize(width(), height() + bw_changes); diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index 800bc0e..6196cf3 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh @@ -40,13 +40,13 @@ class FbWinFrameTheme; class BScreen; class IconButton; class Focusable; +template class FocusableTheme; namespace FbTk { class ImageControl; class Command; class Texture; class XLayer; -template class ThemeProxy; } /// holds a window frame with a client window @@ -96,7 +96,7 @@ public: }; /// create a top level window - FbWinFrame(BScreen &screen, FbTk::ThemeProxy &theme, + FbWinFrame(BScreen &screen, FocusableTheme &theme, FbTk::ImageControl &imgctrl, FbTk::XLayer &layer, int x, int y, @@ -255,7 +255,7 @@ public: FbTk::FbWindow &gripRight() { return m_grip_right; } bool focused() const { return m_focused; } bool isShaded() const { return m_shaded; } - FbTk::ThemeProxy &theme() const { return m_theme; } + FocusableTheme &theme() const { return m_theme; } /// @return titlebar height unsigned int titlebarHeight() const { return (m_use_titlebar?m_titlebar.height()+m_window.borderWidth():0); } unsigned int handleHeight() const { return (m_use_handle?m_handle.height()+m_window.borderWidth():0); } @@ -314,7 +314,7 @@ private: BScreen &m_screen; - FbTk::ThemeProxy &m_theme; ///< theme to be used + FocusableTheme &m_theme; ///< theme to be used FbTk::ImageControl &m_imagectrl; ///< Image control for rendering /** @name windows diff --git a/src/FbWinFrameTheme.cc b/src/FbWinFrameTheme.cc index 634a0fd..5431532 100644 --- a/src/FbWinFrameTheme.cc +++ b/src/FbWinFrameTheme.cc @@ -26,39 +26,26 @@ #include -FbWinFrameTheme::FbWinFrameTheme(int screen_num): +FbWinFrameTheme::FbWinFrameTheme(int screen_num, const std::string &extra, + const std::string &altextra): FbTk::Theme(screen_num), - m_title_focus(*this, "window.title.focus", "Window.Title.Focus"), - m_title_unfocus(*this, "window.title.unfocus", "Window.Title.Unfocus"), - - m_handle_focus(*this, "window.handle.focus", "Window.Handle.Focus"), - m_handle_unfocus(*this, "window.handle.unfocus", "Window.Handle.Unfocus"), - - m_button_focus(*this, "window.button.focus", "Window.Button.Focus"), - m_button_unfocus(*this, "window.button.unfocus", "Window.Button.Unfocus"), + m_title(*this, "window.title" + extra, "Window.Title" + altextra), + m_handle(*this, "window.handle" + extra, "Window.Handle" + altextra), + m_button(*this, "window.button" + extra, "Window.Button" + altextra), m_button_pressed(*this, "window.button.pressed", "Window.Button.Pressed"), - - m_grip_focus(*this, "window.grip.focus", "Window.Grip.Focus"), - m_grip_unfocus(*this, "window.grip.unfocus", "Window.Grip.Unfocus"), - - m_button_focus_color(*this, "window.button.focus.picColor", "Window.Button.Focus.PicColor"), - m_button_unfocus_color(*this, "window.button.unfocus.picColor", "Window.Button.Unfocus.PicColor"), - + m_grip(*this, "window.grip" + extra, "Window.Grip" + altextra), + m_button_color(*this, "window.button" + extra + ".picColor", + "Window.Button" + altextra + ".PicColor"), m_font(*this, "window.font", "Window.Font"), m_shape_place(*this, "window.roundCorners", "Window.RoundCorners"), m_title_height(*this, "window.title.height", "Window.Title.Height"), m_bevel_width(*this, "window.bevelWidth", "Window.BevelWidth"), m_handle_width(*this, "window.handleWidth", "Window.handleWidth"), - m_border_focus(*this, "window.focus", "Window.Focus"), - m_border_unfocus(*this, "window.unfocus", "Window.Unfocus"), - m_button_pic_focus_gc(RootWindow(FbTk::App::instance()->display(), screen_num)), - m_button_pic_unfocus_gc(RootWindow(FbTk::App::instance()->display(), screen_num)), - m_focused_alpha(255), - m_unfocused_alpha(255), - m_focused_iconbar_theme(screen_num, "window.label.focus", - "Window.Label.Unfocus"), - m_unfocused_iconbar_theme(screen_num, "window.label.unfocus", - "Window.Label.Unfocus") { + m_border(*this, "window" + extra, "Window" + altextra), + m_button_pic_gc(RootWindow(FbTk::App::instance()->display(), screen_num)), + m_alpha(255), + m_iconbar_theme(screen_num, "window.label" + extra, + "Window.Label" + altextra) { *m_title_height = 0; // set defaults @@ -111,10 +98,7 @@ void FbWinFrameTheme::reconfigTheme() { else if (*m_handle_width < 0) *m_handle_width = 1; - m_button_pic_focus_gc.setForeground(*m_button_focus_color); - m_button_pic_unfocus_gc.setForeground(*m_button_unfocus_color); - - m_focused_iconbar_theme.reconfigTheme(); - m_unfocused_iconbar_theme.reconfigTheme(); + m_button_pic_gc.setForeground(*m_button_color); + m_iconbar_theme.reconfigTheme(); } diff --git a/src/FbWinFrameTheme.hh b/src/FbWinFrameTheme.hh index bc8ed40..fd2a7e9 100644 --- a/src/FbWinFrameTheme.hh +++ b/src/FbWinFrameTheme.hh @@ -31,41 +31,28 @@ #include "FbTk/Shape.hh" #include "IconbarTheme.hh" +#include class FbWinFrameTheme: public FbTk::Theme, public FbTk::ThemeProxy { public: - explicit FbWinFrameTheme(int screen_num); + explicit FbWinFrameTheme(int screen_num, const std::string &extra, + const std::string &altextra); ~FbWinFrameTheme(); /** @name textures */ //@{ - const FbTk::Texture &titleFocusTexture() const { return *m_title_focus; } - const FbTk::Texture &titleUnfocusTexture() const { return *m_title_unfocus; } - - const FbTk::Texture &handleFocusTexture() const { return *m_handle_focus; } - const FbTk::Texture &handleUnfocusTexture() const { return *m_handle_unfocus; } - - const FbTk::Texture &buttonFocusTexture() const { return *m_button_focus; } - const FbTk::Texture &buttonUnfocusTexture() const { return *m_button_unfocus; } + const FbTk::Texture &titleTexture() const { return *m_title; } + const FbTk::Texture &handleTexture() const { return *m_handle; } + const FbTk::Texture &buttonTexture() const { return *m_button; } const FbTk::Texture &buttonPressedTexture() const { return *m_button_pressed; } - - const FbTk::Texture &gripFocusTexture() const { return *m_grip_focus; } - const FbTk::Texture &gripUnfocusTexture() const { return *m_grip_unfocus; } + const FbTk::Texture &gripTexture() const { return *m_grip; } //@} - /** - @name colors - */ - //@{ - const FbTk::Color &buttonFocuscolor() const { return *m_button_focus_color; } - const FbTk::Color &buttonUnfocuscolor() const { return *m_button_unfocus_color; } - //@} + const FbTk::Color &buttonColor() const { return *m_button_color; } FbTk::Font &font() { return *m_font; } - - GC buttonPicFocusGC() const { return m_button_pic_focus_gc.gc(); } - GC buttonPicUnfocusGC() const { return m_button_pic_unfocus_gc.gc(); } + GC buttonPicGC() const { return m_button_pic_gc.gc(); } bool fallback(FbTk::ThemeItem_base &item); void reconfigTheme(); @@ -81,19 +68,16 @@ public: Cursor bottomSideCursor() const { return m_cursor_bottom_side; } FbTk::Shape::ShapePlace shapePlace() const { return *m_shape_place; } - const FbTk::BorderTheme &border(bool focus) const { return (focus ? m_border_focus : m_border_unfocus); } + const FbTk::BorderTheme &border() const { return m_border; } unsigned int titleHeight() const { return *m_title_height; } unsigned int bevelWidth() const { return *m_bevel_width; } unsigned int handleWidth() const { return *m_handle_width; } - unsigned char focusedAlpha() const { return m_focused_alpha; } - unsigned char unfocusedAlpha() const { return m_unfocused_alpha; } - void setFocusedAlpha(unsigned char alpha) { m_focused_alpha = alpha; } - void setUnfocusedAlpha(unsigned char alpha) { m_unfocused_alpha = alpha; } + unsigned char alpha() const { return m_alpha; } + void setAlpha(unsigned char alpha) { m_alpha = alpha; } - IconbarTheme &focusedIconbarTheme() { return m_focused_iconbar_theme; } - IconbarTheme &unfocusedIconbarTheme() { return m_unfocused_iconbar_theme; } + IconbarTheme &iconbarTheme() { return m_iconbar_theme; } virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } @@ -102,20 +86,17 @@ public: virtual const FbWinFrameTheme &operator *() const { return *this; } private: - FbTk::ThemeItem m_title_focus, m_title_unfocus; - FbTk::ThemeItem m_handle_focus, m_handle_unfocus; - FbTk::ThemeItem m_button_focus, m_button_unfocus, m_button_pressed; - FbTk::ThemeItem m_grip_focus, m_grip_unfocus; - - FbTk::ThemeItem m_button_focus_color, m_button_unfocus_color; + FbTk::ThemeItem m_title, m_handle, m_button, + m_button_pressed, m_grip; + FbTk::ThemeItem m_button_color; FbTk::ThemeItem m_font; FbTk::ThemeItem m_shape_place; FbTk::ThemeItem m_title_height, m_bevel_width, m_handle_width; - FbTk::BorderTheme m_border_focus, m_border_unfocus; + FbTk::BorderTheme m_border; - FbTk::GContext m_button_pic_focus_gc, m_button_pic_unfocus_gc; + FbTk::GContext m_button_pic_gc; Cursor m_cursor_move; Cursor m_cursor_lower_left_angle; @@ -126,10 +107,9 @@ private: Cursor m_cursor_right_side; Cursor m_cursor_top_side; Cursor m_cursor_bottom_side; - unsigned char m_focused_alpha; - unsigned char m_unfocused_alpha; + unsigned char m_alpha; - IconbarTheme m_focused_iconbar_theme, m_unfocused_iconbar_theme; + IconbarTheme m_iconbar_theme; }; #endif // FBWINFRAMETHEME_HH diff --git a/src/Screen.cc b/src/Screen.cc index 7174cda..8e5d8af 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -321,11 +321,12 @@ BScreen::BScreen(FbTk::ResourceManager &rm, m_resize_sig(*this), m_bg_change_sig(*this), m_layermanager(num_layers), - m_windowtheme(new FbWinFrameTheme(scrn)), + m_focused_windowtheme(new FbWinFrameTheme(scrn, ".focus", ".Focus")), + m_unfocused_windowtheme(new FbWinFrameTheme(scrn, ".unfocus", ".Unfocus")), // the order of windowtheme and winbutton theme is important // because winbutton need to rescale the pixmaps in winbutton theme // after fbwinframe have resized them - m_winbutton_theme(new WinButtonTheme(scrn, *m_windowtheme)), + m_winbutton_theme(new WinButtonTheme(scrn, *m_focused_windowtheme)), m_menutheme(new FbTk::MenuTheme(scrn)), m_root_window(scrn), m_geom_window(m_root_window, @@ -425,8 +426,8 @@ BScreen::BScreen(FbTk::ResourceManager &rm, m_root_theme.reset(new RootTheme(imageControl())); m_root_theme->reconfigTheme(); - m_windowtheme->setFocusedAlpha(*resource.focused_alpha); - m_windowtheme->setUnfocusedAlpha(*resource.unfocused_alpha); + focusedWinFrameTheme()->setAlpha(*resource.focused_alpha); + unfocusedWinFrameTheme()->setAlpha(*resource.unfocused_alpha); m_menutheme->setAlpha(*resource.menu_alpha); m_menutheme->setMenuMode(*resource.menu_mode); // clamp values @@ -445,7 +446,7 @@ BScreen::BScreen(FbTk::ResourceManager &rm, imageControl().setDither(*resource.image_dither); - winFrameTheme()->reconfigSig().attach(this);// for geom window + focusedWinFrameTheme()->reconfigSig().attach(this);// for geom window geom_visible = false; @@ -867,8 +868,8 @@ void BScreen::addExtraWindowMenu(const FbTk::FbString &label, FbTk::Menu *menu) void BScreen::reconfigure() { Fluxbox *fluxbox = Fluxbox::instance(); - m_windowtheme->setFocusedAlpha(*resource.focused_alpha); - m_windowtheme->setUnfocusedAlpha(*resource.unfocused_alpha); + focusedWinFrameTheme()->setAlpha(*resource.focused_alpha); + unfocusedWinFrameTheme()->setAlpha(*resource.unfocused_alpha); m_menutheme->setAlpha(*resource.menu_alpha); m_menutheme->setMenuMode(*resource.menu_mode); @@ -1301,7 +1302,6 @@ FluxboxWindow *BScreen::createWindow(Window client) { workspace->updateClientmenu(); } else { win = new FluxboxWindow(*winclient, - winFrameTheme(), *layerManager().getLayer(Layer::NORMAL)); if (!win->isManaged()) { @@ -1339,7 +1339,6 @@ FluxboxWindow *BScreen::createWindow(WinClient &client) { } FluxboxWindow *win = new FluxboxWindow(client, - winFrameTheme(), *layerManager().getLayer(Layer::NORMAL)); #ifdef SLIT @@ -1793,13 +1792,12 @@ void BScreen::showPosition(int x, int y) { m_pos_window.clear(); - winFrameTheme()->font().drawText(m_pos_window, - screenNumber(), - winFrameTheme()->focusedIconbarTheme().text().textGC(), - label, strlen(label), - winFrameTheme()->bevelWidth(), - winFrameTheme()->bevelWidth() + - winFrameTheme()->font().ascent()); + focusedWinFrameTheme()->font().drawText(m_pos_window, screenNumber(), + focusedWinFrameTheme()->iconbarTheme().text().textGC(), + label, strlen(label), + focusedWinFrameTheme()->bevelWidth(), + focusedWinFrameTheme()->bevelWidth() + + focusedWinFrameTheme()->font().ascent()); } @@ -1845,13 +1843,12 @@ void BScreen::showGeometry(int gx, int gy) { m_geom_window.clear(); //!! TODO: geom window again?! repeated - winFrameTheme()->font().drawText(m_geom_window, - screenNumber(), - winFrameTheme()->focusedIconbarTheme().text().textGC(), - label, strlen(label), - winFrameTheme()->bevelWidth(), - winFrameTheme()->bevelWidth() + - winFrameTheme()->font().ascent()); + focusedWinFrameTheme()->font().drawText(m_geom_window, screenNumber(), + focusedWinFrameTheme()->iconbarTheme().text().textGC(), + label, strlen(label), + focusedWinFrameTheme()->bevelWidth(), + focusedWinFrameTheme()->bevelWidth() + + focusedWinFrameTheme()->font().ascent()); } @@ -1908,32 +1905,39 @@ void BScreen::renderGeomWindow() { "W: %04d x H: %04d", "Representative maximum sized text for width and height dialog").c_str(), 0, 0); - int geom_h = winFrameTheme()->font().height() + winFrameTheme()->bevelWidth()*2; - int geom_w = winFrameTheme()->font().textWidth(label, strlen(label)) + winFrameTheme()->bevelWidth()*2; + int geom_h = focusedWinFrameTheme()->font().height() + + focusedWinFrameTheme()->bevelWidth()*2; + int geom_w = focusedWinFrameTheme()->font().textWidth(label, strlen(label)) + + focusedWinFrameTheme()->bevelWidth()*2; m_geom_window.resize(geom_w, geom_h); - m_geom_window.setBorderWidth(winFrameTheme()->border(true).width()); - m_geom_window.setBorderColor(winFrameTheme()->border(true).color()); + m_geom_window.setBorderWidth(focusedWinFrameTheme()->border().width()); + m_geom_window.setBorderColor(focusedWinFrameTheme()->border().color()); Pixmap tmp = geom_pixmap; - if (winFrameTheme()->focusedIconbarTheme().texture().type() & FbTk::Texture::PARENTRELATIVE) { - if (!winFrameTheme()->titleFocusTexture().usePixmap()) { + if (focusedWinFrameTheme()->iconbarTheme().texture().type() & + FbTk::Texture::PARENTRELATIVE) { + if (!focusedWinFrameTheme()->titleTexture().usePixmap()) { geom_pixmap = None; - m_geom_window.setBackgroundColor(winFrameTheme()->titleFocusTexture().color()); + m_geom_window.setBackgroundColor( + focusedWinFrameTheme()->titleTexture().color()); } else { - geom_pixmap = imageControl().renderImage(m_geom_window.width(), m_geom_window.height(), - winFrameTheme()->titleFocusTexture()); + geom_pixmap = imageControl().renderImage(m_geom_window.width(), + m_geom_window.height(), + focusedWinFrameTheme()->titleTexture()); m_geom_window.setBackgroundPixmap(geom_pixmap); } } else { - if (!winFrameTheme()->focusedIconbarTheme().texture().usePixmap()) { + if (!focusedWinFrameTheme()->iconbarTheme().texture().usePixmap()) { geom_pixmap = None; - m_geom_window.setBackgroundColor(winFrameTheme()->focusedIconbarTheme().texture().color()); + m_geom_window.setBackgroundColor( + focusedWinFrameTheme()->iconbarTheme().texture().color()); } else { - geom_pixmap = imageControl().renderImage(m_geom_window.width(), m_geom_window.height(), - winFrameTheme()->focusedIconbarTheme().texture()); + geom_pixmap = imageControl().renderImage(m_geom_window.width(), + m_geom_window.height(), + focusedWinFrameTheme()->iconbarTheme().texture()); m_geom_window.setBackgroundPixmap(geom_pixmap); } } @@ -1946,32 +1950,40 @@ void BScreen::renderGeomWindow() { void BScreen::renderPosWindow() { - int pos_h = winFrameTheme()->font().height() + winFrameTheme()->bevelWidth()*2; - int pos_w = winFrameTheme()->font().textWidth("0:00000 x 0:00000", 17) + winFrameTheme()->bevelWidth()*2; + int pos_h = focusedWinFrameTheme()->font().height() + + focusedWinFrameTheme()->bevelWidth()*2; + int pos_w = focusedWinFrameTheme()->font().textWidth("0:00000 x 0:00000", + 17) + + focusedWinFrameTheme()->bevelWidth()*2; m_pos_window.resize(pos_w, pos_h); - m_pos_window.setBorderWidth(winFrameTheme()->border(true).width()); - m_pos_window.setBorderColor(winFrameTheme()->border(true).color()); + m_pos_window.setBorderWidth(focusedWinFrameTheme()->border().width()); + m_pos_window.setBorderColor(focusedWinFrameTheme()->border().color()); Pixmap tmp = pos_pixmap; - if (winFrameTheme()->focusedIconbarTheme().texture().type() & FbTk::Texture::PARENTRELATIVE) { - if (!winFrameTheme()->titleFocusTexture().usePixmap()) { + if (focusedWinFrameTheme()->iconbarTheme().texture().type() & + FbTk::Texture::PARENTRELATIVE) { + if (!focusedWinFrameTheme()->titleTexture().usePixmap()) { pos_pixmap = None; - m_pos_window.setBackgroundColor(winFrameTheme()->titleFocusTexture().color()); + m_pos_window.setBackgroundColor( + focusedWinFrameTheme()->titleTexture().color()); } else { - pos_pixmap = imageControl().renderImage(m_pos_window.width(), m_pos_window.height(), - winFrameTheme()->titleFocusTexture()); + pos_pixmap = imageControl().renderImage(m_pos_window.width(), + m_pos_window.height(), + focusedWinFrameTheme()->titleTexture()); m_pos_window.setBackgroundPixmap(pos_pixmap); } } else { - if (!winFrameTheme()->focusedIconbarTheme().texture().usePixmap()) { + if (!focusedWinFrameTheme()->iconbarTheme().texture().usePixmap()) { pos_pixmap = None; - m_pos_window.setBackgroundColor(winFrameTheme()->focusedIconbarTheme().texture().color()); + m_pos_window.setBackgroundColor( + focusedWinFrameTheme()->iconbarTheme().texture().color()); } else { - pos_pixmap = imageControl().renderImage(m_pos_window.width(), m_pos_window.height(), - winFrameTheme()->focusedIconbarTheme().texture()); + pos_pixmap = imageControl().renderImage(m_pos_window.width(), + m_pos_window.height(), + focusedWinFrameTheme()->iconbarTheme().texture()); m_pos_window.setBackgroundPixmap(pos_pixmap); } } diff --git a/src/Screen.hh b/src/Screen.hh index deb51b8..5815395 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -273,8 +273,11 @@ public: void saveMenu(FbTk::Menu &menu) { m_rootmenu_list.push_back(&menu); } - FbTk::ThemeProxy &winFrameTheme() { return *m_windowtheme.get(); } - const FbTk::ThemeProxy &winFrameTheme() const { return *m_windowtheme.get(); } + FbTk::ThemeProxy &focusedWinFrameTheme() { return *m_focused_windowtheme.get(); } + const FbTk::ThemeProxy &focusedWinFrameTheme() const { return *m_focused_windowtheme.get(); } + FbTk::ThemeProxy &unfocusedWinFrameTheme() { return *m_unfocused_windowtheme.get(); } + const FbTk::ThemeProxy &unfocusedWinFrameTheme() const { return *m_unfocused_windowtheme.get(); } + FbTk::ThemeProxy &menuTheme() { return *m_menutheme.get(); } const FbTk::ThemeProxy &menuTheme() const { return *m_menutheme.get(); } const FbTk::ThemeProxy &rootTheme() const { return *m_root_theme.get(); } @@ -514,7 +517,8 @@ private: WorkspaceNames m_workspace_names; Workspaces m_workspaces_list; - std::auto_ptr m_windowtheme; + std::auto_ptr m_focused_windowtheme, + m_unfocused_windowtheme; std::auto_ptr m_winbutton_theme; std::auto_ptr m_menutheme; std::auto_ptr m_root_theme; diff --git a/src/Window.cc b/src/Window.cc index 5c6043d..250109e 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -261,8 +261,7 @@ private: int FluxboxWindow::s_num_grabs = 0; -FluxboxWindow::FluxboxWindow(WinClient &client, - FbTk::ThemeProxy &tm, FbTk::XLayer &layer): +FluxboxWindow::FluxboxWindow(WinClient &client, FbTk::XLayer &layer): Focusable(client.screen(), this), oplock(false), m_hintsig(*this), @@ -291,14 +290,18 @@ FluxboxWindow::FluxboxWindow(WinClient &client, m_old_pos_x(0), m_old_pos_y(0), m_old_width(1), m_old_height(1), m_last_button_x(0), m_last_button_y(0), - m_frame(client.screen(), tm, client.screen().imageControl(), layer, 0, 0, 100, 100), + m_theme(*this, screen().focusedWinFrameTheme(), + screen().unfocusedWinFrameTheme()), + m_frame(client.screen(), m_theme, client.screen().imageControl(), layer, + 0, 0, 100, 100), m_placed(false), m_layernum(layer.getLayerNum()), m_old_layernum(0), m_parent(client.screen().rootWindow()), m_resize_corner(RIGHTBOTTOM) { - tm.reconfigSig().attach(this); + screen().focusedWinFrameTheme().reconfigSig().attach(this); + screen().unfocusedWinFrameTheme().reconfigSig().attach(this); init(); @@ -3022,7 +3025,7 @@ void FluxboxWindow::applyDecorations(bool initial) { unsigned int border_width = 0; if (decorations.border) - border_width = frame().theme()->border(m_focused).width(); + border_width = frame().theme()->border().width(); bool client_move = false; @@ -4073,7 +4076,7 @@ void FluxboxWindow::updateButtons() { void FluxboxWindow::reconfigTheme() { m_frame.setBorderWidth(decorations.border ? - frame().theme()->border(m_focused).width() : 0); + frame().theme()->border().width() : 0); if (decorations.handle && frame().theme()->handleWidth() != 0) frame().showHandle(); else @@ -4129,9 +4132,8 @@ void FluxboxWindow::ungrabPointer(Time time) { void FluxboxWindow::associateClient(WinClient &client) { IconButton *btn = new IconButton(frame().tabcontainer(), - frame().theme()->focusedIconbarTheme(), - frame().theme()->unfocusedIconbarTheme(), - client); + frame().theme().focusedTheme()->iconbarTheme(), + frame().theme().unfocusedTheme()->iconbarTheme(), client); frame().createTab(*btn); FbTk::RefCount setcmd(new SetClientCmd(client)); diff --git a/src/Window.hh b/src/Window.hh index a4c0fa2..c66024a 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -33,6 +33,7 @@ #include "FbTk/XLayerItem.hh" #include "FbWinFrame.hh" #include "Focusable.hh" +#include "FocusableTheme.hh" #include "WinButton.hh" #include @@ -150,8 +151,7 @@ public: typedef std::list ClientList; /// create a window from a client - FluxboxWindow(WinClient &client, - FbTk::ThemeProxy &tm, FbTk::XLayer &layer); + FluxboxWindow(WinClient &client, FbTk::XLayer &layer); virtual ~FluxboxWindow(); @@ -610,6 +610,8 @@ private: unsigned int m_old_width, m_old_height; ///< old size so we can restore from maximized state int m_last_button_x, ///< last known x position of the mouse button m_last_button_y; ///< last known y position of the mouse button + + FocusableTheme m_theme; FbWinFrame m_frame; ///< the actuall window frame bool m_placed; ///< determine whether or not we should place the window -- cgit v0.11.2