From 82047e6a391a12be9583168f28ac72c1154108d6 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Wed, 27 Aug 2008 18:29:33 -0400 Subject: move some things from FluxboxWindow to WindowState --- src/Ewmh.cc | 16 ++++++------ src/FbWinFrame.cc | 7 +++-- src/FbWinFrame.hh | 4 +-- src/Focusable.hh | 13 --------- src/Screen.cc | 6 ++--- src/WinClient.cc | 6 ++--- src/WinClient.hh | 6 ++--- src/Window.cc | 77 +++++++++++++++++++++++++----------------------------- src/Window.hh | 20 ++++++-------- src/WindowState.hh | 26 ++++++++++++++---- 10 files changed, 85 insertions(+), 96 deletions(-) diff --git a/src/Ewmh.cc b/src/Ewmh.cc index 2617491..aacb2ed 100644 --- a/src/Ewmh.cc +++ b/src/Ewmh.cc @@ -586,22 +586,22 @@ void Ewmh::setupClient(WinClient &winclient) { winclient.property(m_net->wm_window_type, 0, 0x7fffffff, False, XA_ATOM, &ret_type, &fmt, &nitems, &bytes_after, &data); - Focusable::WindowType type = Focusable::TYPE_NORMAL; + WindowState::WindowType type = WindowState::TYPE_NORMAL; if (data) { Atom *atoms = (unsigned long *)data; for (unsigned long l = 0; l < nitems; ++l) { if (atoms[l] == m_net->wm_window_type_dock) - type = Focusable::TYPE_DOCK; + type = WindowState::TYPE_DOCK; else if (atoms[l] == m_net->wm_window_type_desktop) - type = Focusable::TYPE_DESKTOP; + type = WindowState::TYPE_DESKTOP; else if (atoms[l] == m_net->wm_window_type_splash) - type = Focusable::TYPE_SPLASH; + type = WindowState::TYPE_SPLASH; else if (atoms[l] == m_net->wm_window_type_dialog) - type = Focusable::TYPE_DIALOG; + type = WindowState::TYPE_DIALOG; else if (atoms[l] == m_net->wm_window_type_menu) - type = Focusable::TYPE_MENU; + type = WindowState::TYPE_MENU; else if (atoms[l] == m_net->wm_window_type_toolbar) - type = Focusable::TYPE_TOOLBAR; + type = WindowState::TYPE_TOOLBAR; else if (atoms[l] != m_net->wm_window_type_normal) continue; /* @@ -615,7 +615,7 @@ void Ewmh::setupClient(WinClient &winclient) { // if _NET_WM_WINDOW_TYPE not set and this window // has transient_for the type must be set to _NET_WM_WINDOW_TYPE_DIALOG if (winclient.isTransient()) { - type = Focusable::TYPE_DIALOG; + type = WindowState::TYPE_DIALOG; winclient. changeProperty(m_net->wm_window_type, XA_ATOM, 32, PropModeReplace, diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 0fa71d5..8617c1b 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -41,9 +41,8 @@ using std::mem_fun; using std::string; -FbWinFrame::FbWinFrame(BScreen &screen, - FocusableTheme &theme, - FbTk::XLayer &layer, WindowState &state): +FbWinFrame::FbWinFrame(BScreen &screen, WindowState &state, + FocusableTheme &theme): m_screen(screen), m_theme(theme), m_imagectrl(screen.imageControl()), @@ -52,7 +51,7 @@ FbWinFrame::FbWinFrame(BScreen &screen, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | EnterWindowMask | LeaveWindowMask, true), - m_layeritem(window(), layer), + m_layeritem(window(), *screen.layerManager().getLayer(Layer::NORMAL)), m_titlebar(m_window, 0, 0, 100, 16, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | ExposureMask | diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index 7891c36..45953ba 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh @@ -71,8 +71,8 @@ public: }; /// create a top level window - FbWinFrame(BScreen &screen, FocusableTheme &theme, - FbTk::XLayer &layer, WindowState &state); + FbWinFrame(BScreen &screen, WindowState &state, + FocusableTheme &theme); /* /// create a frame window inside another FbWindow, NOT IMPLEMENTED! FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl, diff --git a/src/Focusable.hh b/src/Focusable.hh index 007aea9..453a114 100644 --- a/src/Focusable.hh +++ b/src/Focusable.hh @@ -45,16 +45,6 @@ public: m_attentionsig(*this) { } virtual ~Focusable() { } - enum WindowType { - TYPE_NORMAL, - TYPE_DOCK, - TYPE_DESKTOP, - TYPE_SPLASH, - TYPE_DIALOG, - TYPE_MENU, - TYPE_TOOLBAR - }; - /** * Take focus. * @return true if the focuable took focus @@ -96,9 +86,6 @@ public: /// @return wm role string (for pattern matching) virtual std::string getWMRole() const { return "Focusable"; } - /// @return window type - virtual WindowType getWindowType() const { return TYPE_NORMAL; } - /// @return whether this window is a transient (for pattern matching) virtual bool isTransient() const { return false; } diff --git a/src/Screen.cc b/src/Screen.cc index 34cb829..4340ef1 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -1357,8 +1357,7 @@ FluxboxWindow *BScreen::createWindow(Window client) { if (workspace) workspace->updateClientmenu(); } else { - win = new FluxboxWindow(*winclient, - *layerManager().getLayer(Layer::NORMAL)); + win = new FluxboxWindow(*winclient); if (!win->isManaged()) { delete win; @@ -1394,8 +1393,7 @@ FluxboxWindow *BScreen::createWindow(WinClient &client) { return 0; } - FluxboxWindow *win = new FluxboxWindow(client, - *layerManager().getLayer(Layer::NORMAL)); + FluxboxWindow *win = new FluxboxWindow(client); #ifdef SLIT if (win->initialState() == WithdrawnState && slit() != 0) { diff --git a/src/WinClient.cc b/src/WinClient.cc index aa8c6ed..3a22e4a 100644 --- a/src/WinClient.cc +++ b/src/WinClient.cc @@ -77,7 +77,7 @@ WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin): send_close_message(false), m_title_override(false), m_icon_override(false), - m_window_type(Focusable::TYPE_NORMAL), + m_window_type(WindowState::TYPE_NORMAL), m_mwm_hint(0), m_strut(0) { @@ -163,8 +163,8 @@ WinClient::~WinClient() { bool WinClient::acceptsFocus() const { return ((accepts_input || send_focus_message) && // focusing fbpanel messes up quite a few things - m_window_type != Focusable::TYPE_DOCK && - m_window_type != Focusable::TYPE_SPLASH); + m_window_type != WindowState::TYPE_DOCK && + m_window_type != WindowState::TYPE_SPLASH); } bool WinClient::sendFocus() { diff --git a/src/WinClient.hh b/src/WinClient.hh index 1903040..90c5b14 100644 --- a/src/WinClient.hh +++ b/src/WinClient.hh @@ -95,8 +95,8 @@ public: bool getWMName(XTextProperty &textprop) const; bool getWMIconName(XTextProperty &textprop) const; std::string getWMRole() const; - Focusable::WindowType getWindowType() const { return m_window_type; } - void setWindowType(Focusable::WindowType type) { m_window_type = type; } + WindowState::WindowType getWindowType() const { return m_window_type; } + void setWindowType(WindowState::WindowType type) { m_window_type = type; } WinClient *transientFor() { return transient_for; } const WinClient *transientFor() const { return transient_for; } @@ -156,7 +156,7 @@ private: bool m_title_override; bool m_icon_override; - Focusable::WindowType m_window_type; + WindowState::WindowType m_window_type; MwmHints *m_mwm_hint; SizeHints m_size_hints; diff --git a/src/Window.cc b/src/Window.cc index 57fa1f5..7c3e36c 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -39,7 +39,6 @@ #include "Remember.hh" #include "MenuCreator.hh" #include "FocusControl.hh" -#include "Layer.hh" #include "IconButton.hh" #include "ScreenPlacement.hh" @@ -261,7 +260,7 @@ private: int FluxboxWindow::s_num_grabs = 0; -FluxboxWindow::FluxboxWindow(WinClient &client, FbTk::XLayer &layer): +FluxboxWindow::FluxboxWindow(WinClient &client): Focusable(client.screen(), this), oplock(false), m_hintsig(*this), @@ -269,7 +268,7 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbTk::XLayer &layer): m_layersig(*this), m_workspacesig(*this), m_creation_time(0), - moving(false), resizing(false), iconic(false), stuck(false), + moving(false), resizing(false), m_initialized(false), m_attaching_tab(0), display(FbTk::App::instance()->display()), @@ -281,8 +280,6 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbTk::XLayer &layer): m_old_decoration_mask(0), m_client(&client), m_toggled_decos(false), - m_icon_hidden(false), - m_focus_hidden(false), m_focus_new(BoolAcc(screen().focusControl(), &FocusControl::focusNew)), m_mouse_focus(BoolAcc(screen().focusControl(), &FocusControl::isMouseFocus)), m_click_focus(true), @@ -291,9 +288,8 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbTk::XLayer &layer): screen().unfocusedWinButtonTheme()), m_theme(*this, screen().focusedWinFrameTheme(), screen().unfocusedWinFrameTheme()), - m_frame(client.screen(), m_theme, layer, m_state), + m_frame(client.screen(), m_state, m_theme), m_placed(false), - m_layernum(layer.getLayerNum()), m_old_layernum(0), m_parent(client.screen().rootWindow()), m_resize_corner(RIGHTBOTTOM) { @@ -440,7 +436,7 @@ void FluxboxWindow::init() { /**************************************************/ if (m_client->isTransient() && m_client->transientFor()->fbwindow()) - stuck = m_client->transientFor()->fbwindow()->isStuck(); + m_state.stuck = m_client->transientFor()->fbwindow()->isStuck(); if (!m_client->sizeHints().isResizable()) { functions.resize = functions.maximize = false; @@ -485,7 +481,7 @@ void FluxboxWindow::init() { m_client->transientFor()->fbwindow() != this) layerItem().setLayer(m_client->transientFor()->fbwindow()->layerItem().getLayer()); else // if no parent then set default layer - moveToLayer(m_layernum, m_layernum != ::Layer::NORMAL); + moveToLayer(m_state.layernum, m_state.layernum != ::Layer::NORMAL); // transients should be on the same workspace as parent if (m_client->isTransient() && @@ -515,8 +511,8 @@ void FluxboxWindow::init() { setFocusFlag(false); // update graphics before mapping - if (stuck) { - stuck = false; + if (m_state.stuck) { + m_state.stuck = false; stick(); } @@ -525,11 +521,11 @@ void FluxboxWindow::init() { shade(); } - if (iconic) { - iconic = false; + if (m_state.iconic) { + m_state.iconic = false; iconify(); } else if (m_workspace_number == screen().currentWorkspaceID()) { - iconic = true; + m_state.iconic = true; deiconify(false); // check if we should prevent this window from gaining focus m_focused = false; // deiconify sets this @@ -1374,7 +1370,7 @@ void FluxboxWindow::iconify() { if (isIconic()) // no need to iconify if we're already return; - iconic = true; + m_state.iconic = true; m_statesig.notify(); hide(true); @@ -1396,14 +1392,14 @@ void FluxboxWindow::iconify() { } void FluxboxWindow::deiconify(bool do_raise) { - if (numClients() == 0 || !iconic || oplock) + if (numClients() == 0 || !m_state.iconic || oplock) return; oplock = true; // reassociate first, so it gets removed from screen's icon list screen().reassociateWindow(this, m_workspace_number, false); - iconic = false; + m_state.iconic = false; m_statesig.notify(); // deiconify all transients @@ -1544,7 +1540,7 @@ void FluxboxWindow::setWorkspace(int n) { m_workspace_number = n; // notify workspace change - if (m_initialized && !stuck && old_wkspc != m_workspace_number) { + if (m_initialized && old_wkspc != m_workspace_number) { #ifdef DEBUG cerr<transientList().end(); for (; it != it_end; ++it) { if ((*it)->fbwindow()) - (*it)->fbwindow()->setStuck(stuck); + (*it)->fbwindow()->setStuck(m_state.stuck); } } @@ -1619,7 +1615,7 @@ void FluxboxWindow::stick() { } void FluxboxWindow::setStuck(bool val) { - if (val != stuck) + if (val != m_state.stuck) stick(); } @@ -1685,11 +1681,11 @@ void FluxboxWindow::tempRaise() { void FluxboxWindow::raiseLayer() { - moveToLayer(m_layernum-1); + moveToLayer(m_state.layernum-1); } void FluxboxWindow::lowerLayer() { - moveToLayer(m_layernum+1); + moveToLayer(m_state.layernum+1); } @@ -1705,9 +1701,9 @@ void FluxboxWindow::moveToLayer(int layernum, bool force) { layernum = ::Layer::NUM_LAYERS - 1; if (!m_initialized) - m_layernum = layernum; + m_state.layernum = layernum; - if ((m_layernum == layernum && !force) || !m_client) + if ((m_state.layernum == layernum && !force) || !m_client) return; // get root window @@ -1741,13 +1737,13 @@ void FluxboxWindow::moveToLayer(int layernum, bool force) { } void FluxboxWindow::setFocusHidden(bool value) { - m_focus_hidden = value; + m_state.focus_hidden = value; if (m_initialized) m_statesig.notify(); } void FluxboxWindow::setIconHidden(bool value) { - m_icon_hidden= value; + m_state.icon_hidden = value; if (m_initialized) m_statesig.notify(); } @@ -2058,7 +2054,7 @@ void FluxboxWindow::mapNotifyEvent(XMapEvent &ne) { if (ne.override_redirect || !isVisible() || !client->validateClient()) return; - iconic = false; + m_state.iconic = false; // setting state will cause all tabs to be mapped, but we only want the // original tab to be focused @@ -3415,10 +3411,6 @@ std::string FluxboxWindow::getWMRole() const { return (m_client ? m_client->getWMRole() : "FluxboxWindow"); } -Focusable::WindowType FluxboxWindow::getWindowType() const { - return (m_client ? m_client->getWindowType() : Focusable::TYPE_NORMAL); -} - bool FluxboxWindow::isTransient() const { return (m_client && m_client->isTransient()); } @@ -3803,9 +3795,10 @@ void FluxboxWindow::placeWindow(int head) { move(new_x, new_y); } -void FluxboxWindow::setWindowType(Focusable::WindowType type) { +void FluxboxWindow::setWindowType(WindowState::WindowType type) { + m_state.type = type; switch (type) { - case Focusable::TYPE_DOCK: + case WindowState::TYPE_DOCK: /* From Extended Window Manager Hints, draft 1.3: * * _NET_WM_WINDOW_TYPE_DOCK indicates a dock or panel feature. @@ -3821,7 +3814,7 @@ void FluxboxWindow::setWindowType(Focusable::WindowType type) { setDecorationMask(WindowState::DECOR_NONE); moveToLayer(::Layer::DOCK); break; - case Focusable::TYPE_DESKTOP: + case WindowState::TYPE_DESKTOP: /* * _NET_WM_WINDOW_TYPE_DESKTOP indicates a "false desktop" window * We let it be the size it wants, but it gets no decoration, @@ -3837,9 +3830,9 @@ void FluxboxWindow::setWindowType(Focusable::WindowType type) { setTabable(false); setMovable(false); setResizable(false); - stick(); + setStuck(true); break; - case Focusable::TYPE_SPLASH: + case WindowState::TYPE_SPLASH: /* * _NET_WM_WINDOW_TYPE_SPLASH indicates that the * window is a splash screen displayed as an application @@ -3853,11 +3846,11 @@ void FluxboxWindow::setWindowType(Focusable::WindowType type) { setClickFocus(false); setMovable(false); break; - case Focusable::TYPE_DIALOG: + case WindowState::TYPE_DIALOG: setTabable(false); break; - case Focusable::TYPE_MENU: - case Focusable::TYPE_TOOLBAR: + case WindowState::TYPE_MENU: + case WindowState::TYPE_TOOLBAR: /* * _NET_WM_WINDOW_TYPE_TOOLBAR and _NET_WM_WINDOW_TYPE_MENU * indicate toolbar and pinnable menu windows, respectively @@ -3869,7 +3862,7 @@ void FluxboxWindow::setWindowType(Focusable::WindowType type) { setIconHidden(true); moveToLayer(::Layer::ABOVE_DOCK); break; - case Focusable::TYPE_NORMAL: + case WindowState::TYPE_NORMAL: default: break; } diff --git a/src/Window.hh b/src/Window.hh index b0b8248..220cedb 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -122,7 +122,7 @@ public: typedef std::list ClientList; /// create a window from a client - FluxboxWindow(WinClient &client, FbTk::XLayer &layer); + FluxboxWindow(WinClient &client); virtual ~FluxboxWindow(); @@ -366,11 +366,11 @@ public: void setMovable(bool movable) { functions.move = movable; } void setResizable(bool resizable) { functions.resize = resizable; } - bool isFocusHidden() const { return m_focus_hidden; } - bool isIconHidden() const { return m_icon_hidden; } + bool isFocusHidden() const { return m_state.focus_hidden; } + bool isIconHidden() const { return m_state.icon_hidden; } bool isManaged() const { return m_initialized; } bool isVisible() const; - bool isIconic() const { return iconic; } + bool isIconic() const { return m_state.iconic; } bool isShaded() const { return m_state.shaded; } bool isFullscreen() const { return m_state.fullscreen; } bool isMaximized() const { return m_state.isMaximized(); } @@ -382,7 +382,7 @@ public: bool isResizable() const { return functions.resize; } bool isClosable() const { return functions.close; } bool isMoveable() const { return functions.move; } - bool isStuck() const { return stuck; } + bool isStuck() const { return m_state.stuck; } bool hasTitlebar() const { return decorations.titlebar; } bool isMoving() const { return moving; } bool isResizing() const { return resizing; } @@ -416,8 +416,7 @@ public: const std::string &getWMClassName() const; const std::string &getWMClassClass() const; std::string getWMRole() const; - Focusable::WindowType getWindowType() const; - void setWindowType(Focusable::WindowType type); + void setWindowType(WindowState::WindowType type); bool isTransient() const; int x() const { return frame().x(); } @@ -437,7 +436,7 @@ public: unsigned int workspaceNumber() const { return m_workspace_number; } - int layerNum() const { return m_layernum; } + int layerNum() const { return m_state.layernum; } void setLayerNum(int layernum); unsigned int titlebarHeight() const; @@ -531,7 +530,7 @@ private: time_t m_creation_time; // Window states - bool moving, resizing, iconic, stuck, m_initialized; + bool moving, resizing, m_initialized; WinClient *m_attaching_tab; @@ -568,8 +567,6 @@ private: bool resize, move, iconify, maximize, close, tabable; } functions; - bool m_icon_hidden; ///< if the window is in the iconbar - bool m_focus_hidden; ///< if the window is in the NextWindow list typedef FbTk::ConstObjectAccessor BoolAcc; /// if the window is normally focused when mapped FbTk::DefaultValue m_focus_new; @@ -587,7 +584,6 @@ private: bool m_placed; ///< determine whether or not we should place the window - int m_layernum; int m_old_layernum; FbTk::FbWindow &m_parent; ///< window on which we draw move/resize rectangle (the "root window") diff --git a/src/WindowState.hh b/src/WindowState.hh index ea9b635..883443a 100644 --- a/src/WindowState.hh +++ b/src/WindowState.hh @@ -22,6 +22,8 @@ #ifndef WINDOWSTATE_HH #define WINDOWSTATE_HH +#include "Layer.hh" + #include #include @@ -93,11 +95,24 @@ public: DECOR_TAB = DECORM_BORDER|DECORM_MENU|DECORM_TAB }; + enum WindowType { + TYPE_NORMAL, + TYPE_DOCK, + TYPE_DESKTOP, + TYPE_SPLASH, + TYPE_DIALOG, + TYPE_MENU, + TYPE_TOOLBAR + }; + WindowState(): size_hints(), deco_mask(DECOR_NORMAL), + type(TYPE_NORMAL), focused(false), - shaded(false), fullscreen(false), maximized(0), + shaded(false), fullscreen(false), stuck(false), iconic(false), + focus_hidden(false), icon_hidden(false), + maximized(0), layernum(Layer::NORMAL), x(0), y(0), width(1), height(1) { } void saveGeometry(int x, int y, unsigned int width, unsigned int height, @@ -112,15 +127,16 @@ public: bool useTitlebar() const; bool isMaximized() const { return maximized == MAX_FULL; } - bool isMaximizedHorz() const { return (bool)(maximized & MAX_HORZ); } - bool isMaximizedVert() const { return (bool)(maximized & MAX_VERT); } + bool isMaximizedHorz() const { return maximized & MAX_HORZ; } + bool isMaximizedVert() const { return maximized & MAX_VERT; } static int getDecoMaskFromString(const std::string &str); SizeHints size_hints; unsigned int deco_mask; - bool focused, shaded, fullscreen; - int maximized; + WindowType type; + bool focused, shaded, fullscreen, stuck, iconic, focus_hidden, icon_hidden; + int maximized, layernum; int x, y; unsigned int width, height; }; -- cgit v0.11.2