all repos — fluxbox @ fe412dbeef7af324a376cba338bff8c24e032d2e

custom fork of the fluxbox windowmanager

move interpretation of normal hints to size hint class
Mark Tiefenbruck mark@fluxbox.org
commit

fe412dbeef7af324a376cba338bff8c24e032d2e

parent

1d8dfcdf9ad5405f4eef18dc009ce8cfe6d27f29

5 files changed, 71 insertions(+), 73 deletions(-)

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

@@ -85,7 +85,6 @@ m_use_handle(true),

m_visible(false), m_button_pm(0), m_tabmode(screen.getDefaultInternalTabs()?INTERNAL:EXTERNAL), - m_active_gravity(0), m_active_orig_client_bw(0), m_need_render(true), m_button_size(1),

@@ -846,7 +845,7 @@ return;

int grav_x=0, grav_y=0; // negate gravity - gravityTranslate(grav_x, grav_y, -m_active_gravity, m_active_orig_client_bw, false); + gravityTranslate(grav_x, grav_y, -sizeHints().win_gravity, m_active_orig_client_bw, false); m_bevel = theme()->bevelWidth(); setBorderWidth();

@@ -941,7 +940,7 @@ m_clientarea.moveResize(0, client_top,

m_window.width(), client_height); } - gravityTranslate(grav_x, grav_y, m_active_gravity, m_active_orig_client_bw, false); + gravityTranslate(grav_x, grav_y, sizeHints().win_gravity, m_active_orig_client_bw, false); // if the location changes, shift it if (grav_x != 0 || grav_y != 0) move(grav_x + x(), grav_y + y());

@@ -1456,7 +1455,7 @@

void FbWinFrame::applyDecorations() { int grav_x=0, grav_y=0; // negate gravity - gravityTranslate(grav_x, grav_y, -m_active_gravity, m_active_orig_client_bw, + gravityTranslate(grav_x, grav_y, -sizeHints().win_gravity, m_active_orig_client_bw, false); bool client_move = setBorderWidth(false);

@@ -1488,7 +1487,7 @@ else

client_move |= hideHandle(); // apply gravity once more - gravityTranslate(grav_x, grav_y, m_active_gravity, m_active_orig_client_bw, + gravityTranslate(grav_x, grav_y, sizeHints().win_gravity, m_active_orig_client_bw, false); // if the location changes, shift it

@@ -1523,7 +1522,7 @@

int grav_x=0, grav_y=0; // negate gravity if (do_move) - gravityTranslate(grav_x, grav_y, -m_active_gravity, + gravityTranslate(grav_x, grav_y, -sizeHints().win_gravity, m_active_orig_client_bw, false); int bw_changes = 0;

@@ -1551,7 +1550,7 @@ alignTabs();

if (do_move) { frameExtentSig().notify(); - gravityTranslate(grav_x, grav_y, m_active_gravity, + gravityTranslate(grav_x, grav_y, sizeHints().win_gravity, m_active_orig_client_bw, false); // if the location changes, shift it if (grav_x != 0 || grav_y != 0)

@@ -1723,6 +1722,60 @@ unsigned int i, j;

sizeHints().displaySize(i, j, width, height - titlebarHeight() - handleHeight()); m_screen.showGeometry(i, j); +} + +void FbWinFrame::SizeHints::reset(const XSizeHints &sizehint) { + if (sizehint.flags & PMinSize) { + min_width = sizehint.min_width; + min_height = sizehint.min_height; + } else + min_width = min_height = 1; + + if (sizehint.flags & PBaseSize) { + base_width = sizehint.base_width; + base_height = sizehint.base_height; + if (!(sizehint.flags & PMinSize)) { + min_width = base_width; + min_height = base_height; + } + } else + base_width = base_height = 0; + + if (sizehint.flags & PMaxSize) { + max_width = sizehint.max_width; + max_height = sizehint.max_height; + } else + max_width = max_height = 0; // unbounded + + if (sizehint.flags & PResizeInc) { + width_inc = sizehint.width_inc; + height_inc = sizehint.height_inc; + } else + width_inc = height_inc = 1; + + if (sizehint.flags & PAspect) { + min_aspect_x = sizehint.min_aspect.x; + min_aspect_y = sizehint.min_aspect.y; + max_aspect_x = sizehint.max_aspect.x; + max_aspect_y = sizehint.max_aspect.y; + } else + min_aspect_x = min_aspect_y = max_aspect_x = max_aspect_y = 0; + + if (sizehint.flags & PWinGravity) + win_gravity = sizehint.win_gravity; + else + win_gravity = NorthWestGravity; + + // some sanity checks + if (width_inc == 0) + width_inc = 1; + if (height_inc == 0) + height_inc = 1; + + if (base_width > min_width) + min_width = base_width; + if (base_height > min_height) + min_height = base_height; } /* For aspect ratios
M src/FbWinFrame.hhsrc/FbWinFrame.hh

@@ -33,6 +33,8 @@ #include "FbTk/DefaultValue.hh"

#include "FbTk/Container.hh" #include "FbTk/Shape.hh" +#include <X11/Xutil.h> + #include <vector> #include <memory>

@@ -101,7 +103,10 @@ SizeHints():

min_width(1), max_width(0), min_height(1), max_height(0), width_inc(1), height_inc(1), base_width(0), base_height(0), min_aspect_x(0), max_aspect_x(0), - min_aspect_y(0), max_aspect_y(0) { } + min_aspect_y(0), max_aspect_y(0), + win_gravity(0) { } + + void reset(const XSizeHints &sizehint); void apply(unsigned int &w, unsigned int &h, bool maximizing = false) const;

@@ -112,6 +117,7 @@

unsigned int min_width, max_width, min_height, max_height, width_inc, height_inc, base_width, base_height, min_aspect_x, max_aspect_x, min_aspect_y, max_aspect_y; + int win_gravity; }; class State {

@@ -241,7 +247,7 @@

// this function translates its arguments according to win_gravity // if win_gravity is negative, it does an inverse translation void gravityTranslate(int &x, int &y, int win_gravity, unsigned int client_bw, bool move_frame = false); - void setActiveGravity(int gravity, unsigned int orig_client_bw) { m_active_gravity = gravity; m_active_orig_client_bw = orig_client_bw; } + void setActiveGravity(int gravity, unsigned int orig_client_bw) { m_state.size_hints.win_gravity = gravity; m_active_orig_client_bw = orig_client_bw; } /** @name Event handlers

@@ -437,8 +443,6 @@ //@}

TabMode m_tabmode; - // last gravity that this window was *actively* placed with - int m_active_gravity; unsigned int m_active_orig_client_bw; State m_state;
M src/Keys.ccsrc/Keys.cc

@@ -170,7 +170,7 @@ }

-Keys::Keys(): next_key(0), m_reloader(new FbTk::AutoReloadHelper()) { +Keys::Keys(): m_reloader(new FbTk::AutoReloadHelper()), next_key(0) { m_reloader->setReloadCmd(FbTk::RefCount<FbTk::Command<void> >(new FbTk::SimpleCommand<Keys>(*this, &Keys::reload))); }
M src/WinClient.ccsrc/WinClient.cc

@@ -75,7 +75,6 @@ m_modal(false),

accepts_input(false), send_focus_message(false), send_close_message(false), - m_win_gravity(0), m_title_override(false), m_icon_override(false), m_window_type(Focusable::TYPE_NORMAL),

@@ -467,61 +466,7 @@ if (!XGetWMNormalHints(display(), window(), &sizehint, &icccm_mask))

sizehint.flags = 0; normal_hint_flags = sizehint.flags; - - if (sizehint.flags & PMinSize) { - m_size_hints.min_width = sizehint.min_width; - m_size_hints.min_height = sizehint.min_height; - } else - m_size_hints.min_width = m_size_hints.min_height = 1; - - if (sizehint.flags & PBaseSize) { - m_size_hints.base_width = sizehint.base_width; - m_size_hints.base_height = sizehint.base_height; - if (!(sizehint.flags & PMinSize)) { - m_size_hints.min_width = m_size_hints.base_width; - m_size_hints.min_height = m_size_hints.base_height; - } - } else - m_size_hints.base_width = m_size_hints.base_height = 0; - - if (sizehint.flags & PMaxSize) { - m_size_hints.max_width = sizehint.max_width; - m_size_hints.max_height = sizehint.max_height; - } else { - m_size_hints.max_width = 0; // unbounded - m_size_hints.max_height = 0; - } - - if (sizehint.flags & PResizeInc) { - m_size_hints.width_inc = sizehint.width_inc; - m_size_hints.height_inc = sizehint.height_inc; - } else - m_size_hints.width_inc = m_size_hints.height_inc = 1; - - if (sizehint.flags & PAspect) { - m_size_hints.min_aspect_x = sizehint.min_aspect.x; - m_size_hints.min_aspect_y = sizehint.min_aspect.y; - m_size_hints.max_aspect_x = sizehint.max_aspect.x; - m_size_hints.max_aspect_y = sizehint.max_aspect.y; - } else - m_size_hints.min_aspect_x = m_size_hints.min_aspect_y = - m_size_hints.max_aspect_x = m_size_hints.max_aspect_y = 0; - - if (sizehint.flags & PWinGravity) - m_win_gravity = sizehint.win_gravity; - else - m_win_gravity = NorthWestGravity; - - // some sanity checks - if (m_size_hints.width_inc == 0) - m_size_hints.width_inc = 1; - if (m_size_hints.height_inc == 0) - m_size_hints.height_inc = 1; - - if (m_size_hints.base_width > m_size_hints.min_width) - m_size_hints.min_width = m_size_hints.base_width; - if (m_size_hints.base_height > m_size_hints.min_height) - m_size_hints.min_height = m_size_hints.base_height; + m_size_hints.reset(sizehint); } Window WinClient::getGroupLeftWindow() const {
M src/WinClient.hhsrc/WinClient.hh

@@ -27,8 +27,6 @@ #include "Window.hh"

#include "FbTk/FbWindow.hh" #include "FbTk/FbString.hh" -#include <X11/Xutil.h> - class BScreen; class Strut;

@@ -110,7 +108,7 @@ bool isModal() const { return m_modal_count > 0; }

bool isStateModal() const { return m_modal; } void setStateModal(bool state); - int gravity() const { return m_win_gravity; } + int gravity() const { return m_size_hints.win_gravity; } bool hasGroupLeftWindow() const; // grouping is tracked by remembering the window to the left in the group

@@ -154,8 +152,6 @@ // number of transients which we are modal for

int m_modal_count; bool m_modal; bool accepts_input, send_focus_message, send_close_message; - - int m_win_gravity; bool m_title_override; bool m_icon_override;