move interpretation of normal hints to size hint class
This commit is contained in:
parent
1d8dfcdf9a
commit
fe412dbeef
5 changed files with 71 additions and 73 deletions
|
@ -85,7 +85,6 @@ FbWinFrame::FbWinFrame(BScreen &screen,
|
|||
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 @@ void FbWinFrame::reconfigure() {
|
|||
|
||||
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 @@ void FbWinFrame::reconfigure() {
|
|||
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 @@ bool FbWinFrame::useHandle() const {
|
|||
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 @@ void FbWinFrame::applyDecorations() {
|
|||
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 @@ bool FbWinFrame::setBorderWidth(bool do_move) {
|
|||
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 @@ bool FbWinFrame::setBorderWidth(bool do_move) {
|
|||
|
||||
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)
|
||||
|
@ -1725,6 +1724,60 @@ void FbWinFrame::displaySize(unsigned int width, unsigned int height) const {
|
|||
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
|
||||
Note that its slightly simplified in that only the
|
||||
line gradient is given - this is because for aspect
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include "FbTk/Container.hh"
|
||||
#include "FbTk/Shape.hh"
|
||||
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
|
@ -101,7 +103,10 @@ public:
|
|||
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 @@ public:
|
|||
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 @@ public:
|
|||
// 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 @@ private:
|
|||
|
||||
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;
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ Keys::t_key::~t_key() {
|
|||
|
||||
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,6 @@ WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin):
|
|||
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 @@ void WinClient::updateWMNormalHints() {
|
|||
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 {
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
#include "FbTk/FbWindow.hh"
|
||||
#include "FbTk/FbString.hh"
|
||||
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
class BScreen;
|
||||
class Strut;
|
||||
|
||||
|
@ -110,7 +108,7 @@ public:
|
|||
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
|
||||
|
@ -155,8 +153,6 @@ private:
|
|||
bool m_modal;
|
||||
bool accepts_input, send_focus_message, send_close_message;
|
||||
|
||||
int m_win_gravity;
|
||||
|
||||
bool m_title_override;
|
||||
bool m_icon_override;
|
||||
|
||||
|
|
Loading…
Reference in a new issue