all repos — fluxbox @ 533c70cb570c56a586f8946700f57a832128a705

custom fork of the fluxbox windowmanager

some cleanup
Mark Tiefenbruck mark@fluxbox.org
commit

533c70cb570c56a586f8946700f57a832128a705

parent

0116a83aa6b5275cbe3cd2bd851dc6959cacf79b

5 files changed, 44 insertions(+), 193 deletions(-)

jump to
M src/FbWinFrame.ccsrc/FbWinFrame.cc

@@ -674,10 +674,7 @@ m_window.setEventMask(NoEventMask);

// we need to mask this so we don't get unmap event win.setEventMask(NoEventMask); - win.reparent(m_window, 0, clientArea().y()); - // remask window so we get events - win.setEventMask(PropertyChangeMask | StructureNotifyMask | - FocusChangeMask | KeyPressMask); + win.reparent(m_window, clientArea().x(), clientArea().y()); m_window.setEventMask(ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | EnterWindowMask |

@@ -685,14 +682,14 @@ LeaveWindowMask | SubstructureRedirectMask);

XFlush(win.display()); + // remask window so we get events XSetWindowAttributes attrib_set; - attrib_set.event_mask = PropertyChangeMask | StructureNotifyMask | FocusChangeMask; + attrib_set.event_mask = PropertyChangeMask | StructureNotifyMask | FocusChangeMask | KeyPressMask; attrib_set.do_not_propagate_mask = ButtonPressMask | ButtonReleaseMask | ButtonMotionMask; XChangeWindowAttributes(win.display(), win.window(), CWEventMask|CWDontPropagate, &attrib_set); - m_clientarea.raise(); if (isVisible()) win.show(); win.raise();

@@ -808,7 +805,6 @@ evm.add(evh, m_handle);

evm.add(evh, m_grip_right); evm.add(evh, m_grip_left); evm.add(evh, m_window); - evm.add(evh, m_clientarea); } /**

@@ -823,7 +819,6 @@ evm.remove(m_handle);

evm.remove(m_grip_right); evm.remove(m_grip_left); evm.remove(m_window); - evm.remove(m_clientarea); } void FbWinFrame::exposeEvent(XExposeEvent &event) {

@@ -1344,7 +1339,6 @@ m_grip_unfocused_pm = m_grip_focused_pm = 0;

m_button_size = 26; - m_clientarea.setBorderWidth(0); m_label.setBorderWidth(0); m_state.shaded = false;

@@ -1360,6 +1354,10 @@

// Note: we don't show clientarea yet setEventHandler(*this); + + // setup cursors for resize grips + gripLeft().setCursor(theme()->lowerLeftAngleCursor()); + gripRight().setCursor(theme()->lowerRightAngleCursor()); } /**
M src/WinClient.ccsrc/WinClient.cc

@@ -66,7 +66,7 @@ WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin):

Focusable(screen, fbwin), FbTk::FbWindow(win), transient_for(0), window_group(0), - x(0), y(0), old_bw(0), + old_bw(0), initial_state(0), normal_hint_flags(0), wm_hint_flags(0),

@@ -81,6 +81,7 @@ m_window_type(Focusable::TYPE_NORMAL),

m_mwm_hint(0), m_strut(0) { + old_bw = borderWidth(); updateWMProtocols(); updateMWMHints(); updateWMHints();

@@ -365,13 +366,6 @@ m_icon.pixmap().copy(pm.pixmap());

m_icon.mask().copy(pm.mask()); m_icon_override = true; titleSig().notify(); -} - -void WinClient::saveBlackboxAttribs(FluxboxWindow::BlackboxAttributes &blackbox_attribs, int nelements) { - changeProperty(FbAtoms::instance()->getFluxboxAttributesAtom(), - XA_CARDINAL, 32, PropModeReplace, - (unsigned char *)&blackbox_attribs, - nelements); } void WinClient::setFluxboxWindow(FluxboxWindow *win) {
M src/WinClient.hhsrc/WinClient.hh

@@ -81,7 +81,6 @@ const std::string &title() const { return m_title; }

void setGroupLeftWindow(Window win); - void saveBlackboxAttribs(FluxboxWindow::BlackboxAttributes &blackbox_attribs, int nelements); void setFluxboxWindow(FluxboxWindow *win); // does this client have a pending unmap or destroy event?

@@ -136,7 +135,7 @@ std::list<WinClient *> transients; // which windows are our transients?

Window window_group; - int x, y, old_bw; + int old_bw; unsigned long initial_state, normal_hint_flags, wm_hint_flags; private:
M src/Window.ccsrc/Window.cc

@@ -388,13 +388,19 @@

void FluxboxWindow::init() { m_attaching_tab = 0; - assert(m_client); + // fetch client size and placement + XWindowAttributes wattrib; + if (! m_client->getAttrib(wattrib) || + !wattrib.screen || // no screen? ?? + wattrib.override_redirect || // override redirect + m_client->initial_state == WithdrawnState) // Slit client + return; + m_client->setFluxboxWindow(this); m_client->setGroupLeftWindow(None); // nothing to the left. - if (Fluxbox::instance()->haveShape()) { + if (Fluxbox::instance()->haveShape()) Shape::setShapeNotify(winClient()); - } //!! TODO init of client should be better // we don't want to duplicate code here and in attachClient

@@ -407,24 +413,18 @@ #endif // DEBUG

Fluxbox &fluxbox = *Fluxbox::instance(); - // setup cursors for resize grips - frame().gripLeft().setCursor(frame().theme()->lowerLeftAngleCursor()); - frame().gripRight().setCursor(frame().theme()->lowerRightAngleCursor()); - associateClient(*m_client); frame().setLabelButtonFocus(*m_labelbuttons[m_client]); // redirect events from frame to us frame().setEventHandler(*this); + fluxbox.saveWindowSearchGroup(frame().window().window(), this); + fluxbox.saveWindowSearchGroup(frame().tabcontainer().window(), this); frame().resize(m_client->width(), m_client->height()); - m_blackbox_attrib.workspace = m_workspace_number = m_screen.currentWorkspaceID(); - - m_blackbox_attrib.flags = m_blackbox_attrib.attrib = m_blackbox_attrib.stack = 0; - m_blackbox_attrib.premax_x = m_blackbox_attrib.premax_y = 0; - m_blackbox_attrib.premax_w = m_blackbox_attrib.premax_h = 0; + m_workspace_number = m_screen.currentWorkspaceID(); // set default decorations but don't apply them setDecorationMask(FbWinFrame::getDecoMaskFromString(screen().defaultDeco()),

@@ -435,45 +435,27 @@ = functions.close = functions.tabable = true;

updateMWMHintsFromClient(*m_client); - //!! - // fetch client size and placement - XWindowAttributes wattrib; - if (! m_client->getAttrib(wattrib) || - !wattrib.screen || // no screen? ?? - wattrib.override_redirect || // override redirect - m_client->initial_state == WithdrawnState) // Slit client - return; - - // save old border width so we can restore it later - m_client->old_bw = wattrib.border_width; - m_client->x = wattrib.x; m_client->y = wattrib.y; - m_timer.setTimeout(fluxbox.getAutoRaiseDelay()); FbTk::RefCount<FbTk::Command<void> > raise_cmd(new FbTk::SimpleCommand<FluxboxWindow>(*this, &FluxboxWindow::raise)); m_timer.setCommand(raise_cmd); m_timer.fireOnce(true); - - Fluxbox::instance()->saveWindowSearchGroup(frame().window().window(), this); - Fluxbox::instance()->saveWindowSearchGroup(frame().tabcontainer().window(), this); /**************************************************/ /* Read state above here, apply state below here. */ /**************************************************/ - if (m_client->transientFor() && m_client->transientFor()->fbwindow() && - m_client->transientFor()->fbwindow()->isStuck()) - stick(); + if (m_client->isTransient()) { + if (m_client->transientFor()->fbwindow()) + stuck = m_client->transientFor()->fbwindow()->isStuck(); - // adjust the window decorations based on transience and window sizes - if (m_client->isTransient() && !screen().decorateTransient()) { - decorations.maximize = functions.maximize = false; - decorations.handle = false; + if (!screen().decorateTransient()) { + decorations.maximize = functions.maximize = false; + decorations.handle = false; + } } - if ((m_client->normal_hint_flags & PMinSize) && - (m_client->normal_hint_flags & PMaxSize) && - m_client->maxWidth() != 0 && m_client->maxHeight() != 0 && + if (m_client->maxWidth() != 0 && m_client->maxHeight() != 0 && m_client->maxWidth() <= m_client->minWidth() && m_client->maxHeight() <= m_client->minHeight()) { decorations.maximize = decorations.handle =

@@ -481,10 +463,7 @@ functions.resize = functions.maximize = false;

decorations.tab = false; //no tab for this window } - associateClientWindow(true, - wattrib.x, wattrib.y, - wattrib.width, wattrib.height, - m_client->gravity(), m_client->old_bw); + associateClientWindow(); setWindowType(m_client->getWindowType());

@@ -513,18 +492,9 @@

// this window is managed, we are now allowed to modify actual state m_initialized = true; - restoreAttributes(); - if (m_workspace_number >= screen().numberOfWorkspaces()) m_workspace_number = screen().currentWorkspaceID(); -/* - if (wattrib.width <= 0) - wattrib.width = 1; - if (wattrib.height <= 0) - wattrib.height = 1; -*/ - // if we're a transient then we should be on the same layer as our parent if (m_client->isTransient() && m_client->transientFor()->fbwindow() &&

@@ -535,13 +505,12 @@ moveToLayer(m_layernum, m_layernum != ::Layer::NORMAL);

// transients should be on the same workspace as parent if (m_client->isTransient() && - m_client->transientFor()->fbwindow() && - m_client->transientFor()->fbwindow() != this) { + m_client->transientFor()->fbwindow()) { m_workspace_number = m_client->transientFor()->fbwindow()->workspaceNumber(); } - - + + #ifdef DEBUG cerr<<"FluxboxWindow::init("<<title()<<") transientFor: "<< m_client->transientFor()<<endl;

@@ -551,10 +520,8 @@ m_client->transientFor()->fbwindow()->title()<<endl;

} #endif // DEBUG - unsigned int real_width = frame().width(); - unsigned int real_height = frame().height() - frame().titlebarHeight() - frame().handleHeight(); - frame().sizeHints().apply(real_width, real_height); - real_height += frame().titlebarHeight() + frame().handleHeight(); + unsigned int real_width = frame().width(), real_height = frame().height() + frame().applySizeHints(real_width, real_height); if (m_placed) moveResize(frame().x(), frame().y(), real_width, real_height);

@@ -665,9 +632,6 @@

//null if we want the new button at the end of the list if (x >= 0 && button_insert_pos) frame().moveLabelButtonLeftOf(*m_labelbuttons[*client_it], *button_insert_pos); - - (*client_it)->saveBlackboxAttribs(m_blackbox_attrib, - PropBlackboxAttributesElements); } // add client and move over all attached clients

@@ -695,8 +659,6 @@ if (m_focus_new && !is_startup)

m_focused = focusRequestFromClient(client); focused_win = (m_focus_new || is_startup) ? &client : m_client; - client.saveBlackboxAttribs(m_blackbox_attrib, - PropBlackboxAttributesElements); m_clientlist.push_back(&client); }

@@ -1076,21 +1038,13 @@ return true;

return false; } -void FluxboxWindow::associateClientWindow(bool use_attrs, - int x, int y, - unsigned int width, unsigned int height, - int gravity, unsigned int client_bw) { - m_client->updateTitle(); - +void FluxboxWindow::associateClientWindow() { frame().setShapingClient(m_client, false); - if (use_attrs) - frame().moveResizeForClient(x, y, - width, height, gravity, client_bw); - else - frame().resizeForClient(m_client->width(), m_client->height()); + frame().moveResizeForClient(m_client->x(), m_client->y(), + m_client->width(), m_client->height(), + m_client->gravity(), m_client->old_bw); - frame().setActiveGravity(m_client->gravity(), m_client->old_bw); frame().setSizeHints(m_client->sizeHints()); frame().setClientWindow(*m_client); }

@@ -1719,12 +1673,7 @@

void FluxboxWindow::setLayerNum(int layernum) { m_layernum = layernum; - m_blackbox_attrib.flags |= ATTRIB_STACK; - m_blackbox_attrib.stack = layernum; - if (m_initialized) { - saveBlackboxAttribs(); - #ifdef DEBUG cerr<<this<<" notify layer signal"<<endl; #endif // DEBUG

@@ -1779,8 +1728,8 @@

WinClient::TransientList::const_iterator it = (*client_it)->transientList().begin(); WinClient::TransientList::const_iterator it_end = (*client_it)->transientList().end(); for (; it != it_end; ++it) { - if ((*it)->fbwindow() && (*it)->fbwindow()->isStuck() != stuck) - (*it)->fbwindow()->stick(); + if ((*it)->fbwindow()) + (*it)->fbwindow()->setStuck(stuck); } }

@@ -2009,20 +1958,6 @@ fluxbox->ungrab();

} /** - Saves blackbox attributes for every client in our list - */ -void FluxboxWindow::saveBlackboxAttribs() { - for_each(m_clientlist.begin(), m_clientlist.end(), - ChangeProperty( - display, - FbAtoms::instance()->getFluxboxAttributesAtom(), - PropModeReplace, - (unsigned char *)&m_blackbox_attrib, - PropBlackboxAttributesElements - )); -} - -/** Sets state on each client in our list Use setting_up for setting startup state - it may not be committed yet That'll happen when its mapped

@@ -2077,53 +2012,6 @@ return ret;

} /** - * Sets the attributes to what they should be - * but doesn't change the actual state - * (so the caller can set defaults etc as well) - */ -void FluxboxWindow::restoreAttributes() { - if (!getState()) { - m_current_state = m_client->initial_state; - if (m_current_state == IconicState) - iconic = true; - } - - Atom atom_return; - int foo; - unsigned long ulfoo, nitems; - FbAtoms *fbatoms = FbAtoms::instance(); - - BlackboxAttributes *net; - if (m_client->property(fbatoms->getFluxboxAttributesAtom(), 0l, - PropBlackboxAttributesElements, false, - fbatoms->getFluxboxAttributesAtom(), &atom_return, &foo, - &nitems, &ulfoo, (unsigned char **) &net) && - net) { - if (nitems != (unsigned)PropBlackboxAttributesElements) { - XFree(net); - return; - } - m_blackbox_attrib.flags = net->flags; - m_blackbox_attrib.attrib = net->attrib; - m_blackbox_attrib.workspace = net->workspace; - m_blackbox_attrib.stack = net->stack; - m_blackbox_attrib.premax_x = net->premax_x; - m_blackbox_attrib.premax_y = net->premax_y; - m_blackbox_attrib.premax_w = net->premax_w; - m_blackbox_attrib.premax_h = net->premax_h; - - XFree(static_cast<void *>(net)); - } else - return; - - if (m_blackbox_attrib.flags & ATTRIB_STACK) { - //!! TODO check value? - m_layernum = m_blackbox_attrib.stack; - } - -} - -/** Show the window menu at pos mx, my */ void FluxboxWindow::showMenu(int menu_x, int menu_y) {

@@ -2243,7 +2131,7 @@ return;

} // Note: this function never gets called from WithdrawnState - // initial state is handled in restoreAttributes() and init() + // initial state is handled in init() setCurrentClient(*client, false); // focus handled on MapNotify deiconify();

@@ -2610,7 +2498,6 @@

bool onTitlebar = frame().gripLeft().window() != be.window && frame().gripRight().window() != be.window && frame().handle().window() != be.window && - frame().clientArea().window() != be.window && frame().window() != be.window; if (onTitlebar && be.button == 1)

@@ -2670,7 +2557,6 @@ }

bool inside_titlebar = frame().gripLeft().window() != me.window && frame().gripRight().window() != me.window && - frame().clientArea().window() != me.window && frame().window() != me.window; if (Fluxbox::instance()->getIgnoreBorder() && m_attaching_tab == 0

@@ -3733,8 +3619,6 @@ Send event telling where the root position

of the client window is. (ie frame pos + client pos inside the frame = send pos) */ //!! - client.x = frame().x(); - client.y = frame().y(); moveResizeClient(client, frame().clientArea().x(), frame().clientArea().y(),
M src/Window.hhsrc/Window.hh

@@ -87,18 +87,6 @@ MwmDecorIconify = (1l << 5), /// iconify

MwmDecorMaximize = (1l << 6) /// maximize }; - /// attributes for BlackboxHints - enum Attrib { - ATTRIB_SHADED = 0x01, ///< shaded - ATTRIB_MAXHORIZ = 0x02, ///< maximized horizontal - ATTRIB_MAXVERT = 0x04, ///< maximized vertical - ATTRIB_OMNIPRESENT = 0x08, ///< omnipresent (sticky) - ATTRIB_WORKSPACE = 0x10, ///< workspace - ATTRIB_STACK = 0x20, ///< stack - ATTRIB_DECORATION = 0x40, ///< decorations - ATTRIB_HIDDEN = 0x80 ///< hidden - }; - /** * Types of maximization */

@@ -141,13 +129,6 @@ LEFT = 7,

CENTER = 8 }; - /// holds old blackbox attributes - typedef struct _blackbox_attributes { - unsigned long flags, attrib, workspace, stack; - long premax_x, premax_y; - unsigned long premax_w, premax_h; - } BlackboxAttributes; - typedef std::list<WinClient *> ClientList; /// create a window from a client

@@ -308,7 +289,6 @@ */

void getMaxSize(unsigned int* width, unsigned int* height) const; void setWorkspace(int n); void updateFunctions(); - void restoreAttributes(); /** * Show window meny at at given position * @param mx position

@@ -507,8 +487,6 @@

bool oplock; ///< Used to help stop transient loops occurring by locking a window during certain operations private: - static const int PropBlackboxAttributesElements = 8; - void setupWindow(); void updateButtons();

@@ -530,8 +508,7 @@ void attachTo(int x, int y, bool interrupted = false);

bool getState(); void updateMWMHintsFromClient(WinClient &client); - void saveBlackboxAttribs(); - void associateClientWindow(bool use_attrs = false, int x = 0, int y = 0, unsigned int width = 1, unsigned int height = 1, int gravity = ForgetGravity, unsigned int client_bw = 0); + void associateClientWindow(); void setState(unsigned long stateval, bool setting_up); /// set the layer of a fullscreen window

@@ -574,7 +551,6 @@ WinClient *m_attaching_tab;

FbTk::Timer m_timer; Display *display; /// display connection - BlackboxAttributes m_blackbox_attrib; int m_button_grab_x, m_button_grab_y; // handles last button press event for move int m_last_resize_x, m_last_resize_y; // handles last button press event for resize