quadrant-resizing (Thanks Mathias Gumz)

This commit is contained in:
rathnor 2003-09-29 12:53:58 +00:00
parent 48cc8772e3
commit 10ce5372d9
7 changed files with 88 additions and 89 deletions

View file

@ -1,6 +1,8 @@
(Format: Year/Month/Day) (Format: Year/Month/Day)
Changes for 0.9.6: Changes for 0.9.6:
*03/09/29: *03/09/29:
* Nearest-quadrant resizing (Thanks Mathias Gumz)
Window.hh/cc Screen.hh/cc FbWinFrameTheme.hh/cc
* Update from Han * Update from Han
- make startup executable to save one process - make startup executable to save one process
- make pixmaps-dir - make pixmaps-dir

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: FbWinFrameTheme.cc,v 1.12 2003/09/12 23:37:12 fluxgen Exp $ // $Id: FbWinFrameTheme.cc,v 1.13 2003/09/29 12:53:58 rathnor Exp $
#include "FbWinFrameTheme.hh" #include "FbWinFrameTheme.hh"
#include "App.hh" #include "App.hh"
@ -78,7 +78,8 @@ FbWinFrameTheme::FbWinFrameTheme(int screen_num):
m_cursor_move = XCreateFontCursor(disp, XC_fleur); m_cursor_move = XCreateFontCursor(disp, XC_fleur);
m_cursor_lower_left_angle = XCreateFontCursor(disp, XC_ll_angle); m_cursor_lower_left_angle = XCreateFontCursor(disp, XC_ll_angle);
m_cursor_lower_right_angle = XCreateFontCursor(disp, XC_lr_angle); m_cursor_lower_right_angle = XCreateFontCursor(disp, XC_lr_angle);
m_cursor_upper_right_angle = XCreateFontCursor(disp, XC_ur_angle);
m_cursor_upper_left_angle = XCreateFontCursor(disp, XC_ul_angle);
} }
FbWinFrameTheme::~FbWinFrameTheme() { FbWinFrameTheme::~FbWinFrameTheme() {

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: FbWinFrameTheme.hh,v 1.11 2003/09/12 23:37:12 fluxgen Exp $ // $Id: FbWinFrameTheme.hh,v 1.12 2003/09/29 12:53:58 rathnor Exp $
#ifndef FBWINFRAMETHEME_HH #ifndef FBWINFRAMETHEME_HH
#define FBWINFRAMETHEME_HH #define FBWINFRAMETHEME_HH
@ -90,6 +90,8 @@ public:
inline Cursor moveCursor() const { return m_cursor_move; } inline Cursor moveCursor() const { return m_cursor_move; }
inline Cursor lowerLeftAngleCursor() const { return m_cursor_lower_left_angle; } inline Cursor lowerLeftAngleCursor() const { return m_cursor_lower_left_angle; }
inline Cursor lowerRightAngleCursor() const { return m_cursor_lower_right_angle; } inline Cursor lowerRightAngleCursor() const { return m_cursor_lower_right_angle; }
inline Cursor upperLeftAngleCursor() const { return m_cursor_upper_left_angle; }
inline Cursor upperRightAngleCursor() const { return m_cursor_upper_right_angle; }
inline Shape::ShapePlace shapePlace() const { return *m_shape_place; } inline Shape::ShapePlace shapePlace() const { return *m_shape_place; }
inline const BorderTheme &border() const { return m_border; } inline const BorderTheme &border() const { return m_border; }
@ -122,7 +124,11 @@ private:
FbTk::Subject m_theme_change; FbTk::Subject m_theme_change;
Cursor m_cursor_move, m_cursor_lower_left_angle, m_cursor_lower_right_angle; Cursor m_cursor_move;
Cursor m_cursor_lower_left_angle;
Cursor m_cursor_lower_right_angle;
Cursor m_cursor_upper_left_angle;
Cursor m_cursor_upper_right_angle;
}; };
#endif // FBWINFRAMETHEME_HH #endif // FBWINFRAMETHEME_HH

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: Screen.cc,v 1.234 2003/09/24 14:26:01 rathnor Exp $ // $Id: Screen.cc,v 1.235 2003/09/29 12:53:58 rathnor Exp $
#include "Screen.hh" #include "Screen.hh"
@ -254,6 +254,7 @@ BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm,
auto_raise(rm, false, scrname+".autoRaise", altscrname+".AutoRaise"), auto_raise(rm, false, scrname+".autoRaise", altscrname+".AutoRaise"),
click_raises(rm, true, scrname+".clickRaises", altscrname+".ClickRaises"), click_raises(rm, true, scrname+".clickRaises", altscrname+".ClickRaises"),
rootcommand(rm, "", scrname+".rootCommand", altscrname+".RootCommand"), rootcommand(rm, "", scrname+".rootCommand", altscrname+".RootCommand"),
resizemode(rm, "", scrname+".resizeMode", altscrname+".ResizeMode"),
focus_model(rm, Fluxbox::CLICKTOFOCUS, scrname+".focusModel", altscrname+".FocusModel"), focus_model(rm, Fluxbox::CLICKTOFOCUS, scrname+".focusModel", altscrname+".FocusModel"),
workspaces(rm, 1, scrname+".workspaces", altscrname+".Workspaces"), workspaces(rm, 1, scrname+".workspaces", altscrname+".Workspaces"),
edge_snap_threshold(rm, 0, scrname+".edgeSnapThreshold", altscrname+".EdgeSnapThreshold"), edge_snap_threshold(rm, 0, scrname+".edgeSnapThreshold", altscrname+".EdgeSnapThreshold"),

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: Screen.hh,v 1.124 2003/09/08 16:37:27 fluxgen Exp $ // $Id: Screen.hh,v 1.125 2003/09/29 12:53:58 rathnor Exp $
#ifndef SCREEN_HH #ifndef SCREEN_HH
#define SCREEN_HH #define SCREEN_HH
@ -92,13 +92,14 @@ public:
inline bool doFocusNew() const { return *resource.focus_new; } inline bool doFocusNew() const { return *resource.focus_new; }
inline bool doFocusLast() const { return *resource.focus_last; } inline bool doFocusLast() const { return *resource.focus_last; }
inline bool doShowWindowPos() const { return *resource.show_window_pos; } inline bool doShowWindowPos() const { return *resource.show_window_pos; }
bool antialias() const { return *resource.antialias; } inline bool antialias() const { return *resource.antialias; }
inline FbTk::ImageControl &imageControl() { return *m_image_control.get(); } inline FbTk::ImageControl &imageControl() { return *m_image_control.get(); }
const FbTk::Menu * const getRootmenu() const { return m_rootmenu.get(); } const FbTk::Menu * const getRootmenu() const { return m_rootmenu.get(); }
FbTk::Menu * const getRootmenu() { return m_rootmenu.get(); } FbTk::Menu * const getRootmenu() { return m_rootmenu.get(); }
inline const std::string &getRootCommand() const { return *resource.rootcommand; } inline const std::string &getRootCommand() const { return *resource.rootcommand; }
inline const std::string &getResizeMode() const { return *resource.resizemode; }
inline Fluxbox::FocusModel getFocusModel() const { return *resource.focus_model; } inline Fluxbox::FocusModel getFocusModel() const { return *resource.focus_model; }
inline Slit *slit() { return m_slit.get(); } inline Slit *slit() { return m_slit.get(); }
@ -170,6 +171,7 @@ public:
inline void setRootColormapInstalled(bool r) { root_colormap_installed = r; } inline void setRootColormapInstalled(bool r) { root_colormap_installed = r; }
inline void saveRootCommand(std::string rootcmd) { *resource.rootcommand = rootcmd; } inline void saveRootCommand(std::string rootcmd) { *resource.rootcommand = rootcmd; }
inline void saveResizeMode(std::string resizem) { *resource.resizemode = resizem; }
inline void saveFocusModel(Fluxbox::FocusModel model) { resource.focus_model = model; } inline void saveFocusModel(Fluxbox::FocusModel model) { resource.focus_model = model; }
inline void saveWorkspaces(int w) { *resource.workspaces = w; } inline void saveWorkspaces(int w) { *resource.workspaces = w; }
@ -421,6 +423,7 @@ private:
focus_last, focus_new, focus_last, focus_new,
antialias, auto_raise, click_raises; antialias, auto_raise, click_raises;
FbTk::Resource<std::string> rootcommand; FbTk::Resource<std::string> rootcommand;
FbTk::Resource<std::string> resizemode;
FbTk::Resource<Fluxbox::FocusModel> focus_model; FbTk::Resource<Fluxbox::FocusModel> focus_model;
bool ordered_dither; bool ordered_dither;
FbTk::Resource<int> workspaces, edge_snap_threshold, menu_alpha; FbTk::Resource<int> workspaces, edge_snap_threshold, menu_alpha;

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: Window.cc,v 1.234 2003/09/24 14:02:25 rathnor Exp $ // $Id: Window.cc,v 1.235 2003/09/29 12:53:58 rathnor Exp $
#include "Window.hh" #include "Window.hh"
@ -266,7 +266,8 @@ FluxboxWindow::FluxboxWindow(WinClient &client, BScreen &scr, FbWinFrameTheme &t
m_frame(new FbWinFrame(tm, scr.imageControl(), scr.screenNumber(), 0, 0, 100, 100)), m_frame(new FbWinFrame(tm, scr.imageControl(), scr.screenNumber(), 0, 0, 100, 100)),
m_layeritem(m_frame->window(), layer), m_layeritem(m_frame->window(), layer),
m_layernum(layer.getLayerNum()), m_layernum(layer.getLayerNum()),
m_parent(scr.rootWindow()) { m_parent(scr.rootWindow()),
m_resize_corner(RIGHTBOTTOM) {
init(); init();
} }
@ -934,10 +935,10 @@ void FluxboxWindow::grabButtons() {
XGrabButton(display, Button3, Mod1Mask, frame().window().window(), True, XGrabButton(display, Button3, Mod1Mask, frame().window().window(), True,
ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
GrabModeAsync, None, frame().theme().lowerRightAngleCursor()); GrabModeAsync, None, None);
//---grab with "all" modifiers //---grab with "all" modifiers
grabButton(display, Button3, frame().window().window(), frame().theme().lowerRightAngleCursor()); grabButton(display, Button3, frame().window().window(), None);
} }
@ -2389,10 +2390,23 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
me.window == frame().gripLeft())) || me.window == frame().gripLeft())) ||
me.window == frame().window())) { me.window == frame().window())) {
bool left = (me.window == frame().gripLeft());
if (! resizing) { if (! resizing) {
startResizing(me.window, me.x, me.y, left);
int cx = frame().width() / 2;
int cy = frame().height() / 2;
if (me.window == frame().gripRight())
m_resize_corner = RIGHTBOTTOM;
else if (me.window == frame().gripLeft())
m_resize_corner = LEFTBOTTOM;
else if (screen().getResizeMode() != "quadrant")
m_resize_corner = RIGHTBOTTOM;
else if (me.x < cx)
m_resize_corner = (me.y < cy) ? LEFTTOP : LEFTBOTTOM;
else
m_resize_corner = (me.y < cy) ? RIGHTTOP : RIGHTBOTTOM;
startResizing(me.window, me.x, me.y);
} else if (resizing) { } else if (resizing) {
// draw over old rect // draw over old rect
parent().drawRectangle(screen().rootTheme().opGC(), parent().drawRectangle(screen().rootTheme().opGC(),
@ -2404,24 +2418,25 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
// move rectangle // move rectangle
int gx = 0, gy = 0; int gx = 0, gy = 0;
m_last_resize_h = frame().height() + (me.y - m_button_grab_y); int dx = me.x - m_button_grab_x;
if (m_last_resize_h < 1) int dy = me.y - m_button_grab_y;
m_last_resize_h = 1;
if (left) { if (m_resize_corner == LEFTTOP || m_resize_corner == RIGHTTOP) {
m_last_resize_x = me.x_root - m_button_grab_x; m_last_resize_h = frame().height() - dy;
if (m_last_resize_x > (signed) (frame().x() + frame().width())) m_last_resize_y = frame().y() + dy;
m_last_resize_x = m_last_resize_x + frame().width() - 1;
left_fixsize(&gx, &gy);
} else { } else {
m_last_resize_w = frame().width() + (me.x - m_button_grab_x); m_last_resize_h = frame().height() + dy;
if (m_last_resize_w < 1) // clamp to 1
m_last_resize_w = 1;
right_fixsize(&gx, &gy);
} }
if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM) {
m_last_resize_w = frame().width() - dx;
m_last_resize_x = frame().x() + dx;
} else {
m_last_resize_w = frame().width() + dx;
}
fixsize(&gx, &gy);
// draw resize rectangle // draw resize rectangle
parent().drawRectangle(screen().rootTheme().opGC(), parent().drawRectangle(screen().rootTheme().opGC(),
m_last_resize_x, m_last_resize_y, m_last_resize_x, m_last_resize_y,
@ -2877,13 +2892,16 @@ void FluxboxWindow::doSnapping(int &orig_left, int &orig_top) {
} }
void FluxboxWindow::startResizing(Window win, int x, int y, bool left) { void FluxboxWindow::startResizing(Window win, int x, int y) {
resizing = true; resizing = true;
const Cursor& cursor = (m_resize_corner == LEFTTOP) ? frame().theme().upperLeftAngleCursor() :
(m_resize_corner == RIGHTTOP) ? frame().theme().upperRightAngleCursor() :
(m_resize_corner == RIGHTBOTTOM) ? frame().theme().lowerRightAngleCursor() :
frame().theme().lowerLeftAngleCursor();
XGrabPointer(display, win, false, ButtonMotionMask | ButtonReleaseMask, XGrabPointer(display, win, false, ButtonMotionMask | ButtonReleaseMask,
GrabModeAsync, GrabModeAsync, None, GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime);
(left ? frame().theme().lowerLeftAngleCursor() : frame().theme().lowerRightAngleCursor()),
CurrentTime);
int gx = 0, gy = 0; int gx = 0, gy = 0;
m_button_grab_x = x; m_button_grab_x = x;
@ -2893,10 +2911,7 @@ void FluxboxWindow::startResizing(Window win, int x, int y, bool left) {
m_last_resize_w = frame().width(); m_last_resize_w = frame().width();
m_last_resize_h = frame().height(); m_last_resize_h = frame().height();
if (left) fixsize(&gx, &gy);
left_fixsize(&gx, &gy);
else
right_fixsize(&gx, &gy);
if (screen().doShowWindowPos()) if (screen().doShowWindowPos())
screen().showGeometry(gx, gy); screen().showGeometry(gx, gy);
@ -2917,11 +2932,7 @@ void FluxboxWindow::stopResizing(Window win) {
screen().hideGeometry(); screen().hideGeometry();
if (win && win == frame().gripLeft()) fixsize();
left_fixsize();
else
right_fixsize();
moveResize(m_last_resize_x, m_last_resize_y, moveResize(m_last_resize_x, m_last_resize_y,
m_last_resize_w, m_last_resize_h); m_last_resize_w, m_last_resize_h);
@ -3155,49 +3166,7 @@ void FluxboxWindow::downsize() {
} }
void FluxboxWindow::right_fixsize(int *gx, int *gy) { void FluxboxWindow::fixsize(int *gx, int *gy) {
// calculate the size of the client window and conform it to the
// size specified by the size hints of the client window...
int dx = m_last_resize_w - m_client->base_width;
int titlebar_height = (decorations.titlebar ?
frame().titlebar().height() +
frame().titlebar().borderWidth() : 0);
int handle_height = (decorations.handle ?
frame().handle().height() +
frame().handle().borderWidth() : 0);
int dy = m_last_resize_h - m_client->base_height - titlebar_height - handle_height;
if (dx < (signed) m_client->min_width)
dx = m_client->min_width;
if (dy < (signed) m_client->min_height)
dy = m_client->min_height;
if (m_client->max_width > 0 && (unsigned) dx > m_client->max_width)
dx = m_client->max_width;
if (m_client->max_height > 0 && (unsigned) dy > m_client->max_height)
dy = m_client->max_height;
// make it snap
if (m_client->width_inc == 0)
m_client->width_inc = 1;
if (m_client->height_inc == 0)
m_client->height_inc = 1;
dx /= m_client->width_inc;
dy /= m_client->height_inc;
if (gx) *gx = dx;
if (gy) *gy = dy;
dx = (dx * m_client->width_inc) + m_client->base_width;
dy = (dy * m_client->height_inc) + m_client->base_height +
titlebar_height + handle_height;
m_last_resize_w = dx;
m_last_resize_h = dy;
}
void FluxboxWindow::left_fixsize(int *gx, int *gy) {
int titlebar_height = (decorations.titlebar ? int titlebar_height = (decorations.titlebar ?
frame().titlebar().height() + frame().titlebar().height() +
frame().titlebar().borderWidth() : 0); frame().titlebar().borderWidth() : 0);
@ -3207,7 +3176,8 @@ void FluxboxWindow::left_fixsize(int *gx, int *gy) {
int decoration_height = titlebar_height + handle_height; int decoration_height = titlebar_height + handle_height;
// dx is new width = current width + difference between new and old x values // dx is new width = current width + difference between new and old x values
int dx = frame().width() + frame().x() - m_last_resize_x; //int dx = frame().width() + frame().x() - m_last_resize_x;
int dx = m_last_resize_w - m_client->base_width;
// dy = new height (w/o decorations), similarly // dy = new height (w/o decorations), similarly
int dy = m_last_resize_h - m_client->base_height - decoration_height; int dy = m_last_resize_h - m_client->base_height - decoration_height;
@ -3247,7 +3217,15 @@ void FluxboxWindow::left_fixsize(int *gx, int *gy) {
// update last resize // update last resize
m_last_resize_w = dx; m_last_resize_w = dx;
m_last_resize_h = dy; m_last_resize_h = dy;
if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM) {
m_last_resize_x = frame().x() + frame().width() - m_last_resize_w; m_last_resize_x = frame().x() + frame().width() - m_last_resize_w;
}
if (m_resize_corner == LEFTTOP || m_resize_corner == RIGHTTOP) {
m_last_resize_y = frame().y() + frame().height() - m_last_resize_h;
}
} }
void FluxboxWindow::resizeClient(WinClient &client, void FluxboxWindow::resizeClient(WinClient &client,

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: Window.hh,v 1.95 2003/09/24 14:02:25 rathnor Exp $ // $Id: Window.hh,v 1.96 2003/09/29 12:53:58 rathnor Exp $
#ifndef WINDOW_HH #ifndef WINDOW_HH
#define WINDOW_HH #define WINDOW_HH
@ -131,6 +131,13 @@ public:
DECORM_LAST = (1<<11) // useful for getting "All" DECORM_LAST = (1<<11) // useful for getting "All"
}; };
enum ResizeCorner {
LEFTTOP,
LEFTBOTTOM,
RIGHTBOTTOM,
RIGHTTOP
};
typedef struct _blackbox_hints { typedef struct _blackbox_hints {
unsigned long flags, attrib, workspace, stack; unsigned long flags, attrib, workspace, stack;
int decoration; int decoration;
@ -366,7 +373,7 @@ private:
void startMoving(Window win); void startMoving(Window win);
void stopMoving(); void stopMoving();
void startResizing(Window win, int x, int y, bool left); void startResizing(Window win, int x, int y);
void stopResizing(Window win=0); void stopResizing(Window win=0);
void updateIcon(); void updateIcon();
/// try to attach current attaching client to a window at pos x, y /// try to attach current attaching client to a window at pos x, y
@ -391,8 +398,7 @@ private:
// modifies left and top if snap is necessary // modifies left and top if snap is necessary
void doSnapping(int &left, int &top); void doSnapping(int &left, int &top);
void right_fixsize(int *x = 0, int *y = 0); void fixsize(int *x = 0, int *y = 0);
void left_fixsize(int *x = 0, int *y = 0);
void resizeClient(WinClient &client, unsigned int width, unsigned int height); void resizeClient(WinClient &client, unsigned int width, unsigned int height);
/// sends configurenotify to all clients /// sends configurenotify to all clients
void sendConfigureNotify(bool send_to_netizens = true); void sendConfigureNotify(bool send_to_netizens = true);
@ -456,6 +462,8 @@ private:
FbTk::FbWindow &m_parent; ///< window on which we draw move/resize rectangle (the "root window") FbTk::FbWindow &m_parent; ///< window on which we draw move/resize rectangle (the "root window")
ResizeCorner m_resize_corner;
ExtraMenus m_extramenus; ExtraMenus m_extramenus;
}; };