static gint cur_x, cur_y, cur_w, cur_h;
static guint button;
static guint32 corner;
-static ObCorner lockcorner;
static ObDirection edge_warp_dir = -1;
+static gboolean edge_warp_odd = FALSE;
static ObDirection key_resize_edge = -1;
#ifdef SYNC
static gboolean waiting_for_sync;
void moveresize_startup(gboolean reconfig)
{
- popup = popup_new(FALSE);
+ popup = popup_new();
popup_set_text_align(popup, RR_JUSTIFY_CENTER);
if (!reconfig)
gchar *text;
text = g_strdup_printf(format, a, b);
- if (config_resize_popup_pos == 1) /* == "Top" */
+ if (config_resize_popup_pos == OB_RESIZE_POS_TOP)
popup_position(popup, SouthGravity,
c->frame->area.x
+ c->frame->area.width/2,
c->frame->area.y - ob_rr_theme->fbwidth);
- else /* == "Center" */
+ else if (config_resize_popup_pos == OB_RESIZE_POS_CENTER)
popup_position(popup, CenterGravity,
c->frame->area.x + c->frame->size.left +
c->area.width / 2,
c->frame->area.y + c->frame->size.top +
c->area.height / 2);
+ else /* Fixed */ {
+ Rect *area = screen_physical_area_active();
+ gint gravity, x, y;
+
+ x = config_resize_popup_fixed.x.pos;
+ if (config_resize_popup_fixed.x.center)
+ x = area->x + area->width/2;
+ else if (config_resize_popup_fixed.x.opposite)
+ x = RECT_RIGHT(*area) - x;
+ else
+ x = area->x + x;
+
+ y = config_resize_popup_fixed.y.pos;
+ if (config_resize_popup_fixed.y.center)
+ y = area->y + area->height/2;
+ else if (config_resize_popup_fixed.y.opposite)
+ y = RECT_RIGHT(*area) - y;
+ else
+ y = area->y + y;
+
+ if (config_resize_popup_fixed.x.center) {
+ if (config_resize_popup_fixed.y.center)
+ gravity = CenterGravity;
+ else if (config_resize_popup_fixed.y.opposite)
+ gravity = SouthGravity;
+ else
+ gravity = NorthGravity;
+ }
+ else if (config_resize_popup_fixed.x.opposite) {
+ if (config_resize_popup_fixed.y.center)
+ gravity = EastGravity;
+ else if (config_resize_popup_fixed.y.opposite)
+ gravity = SouthEastGravity;
+ else
+ gravity = NorthEastGravity;
+ }
+ else {
+ if (config_resize_popup_fixed.y.center)
+ gravity = WestGravity;
+ else if (config_resize_popup_fixed.y.opposite)
+ gravity = SouthWestGravity;
+ else
+ gravity = NorthWestGravity;
+ }
+
+ popup_position(popup, gravity, x, y);
+
+ g_free(area);
+ }
popup_show(popup, text);
g_free(text);
}
ObCursor cur;
gboolean mv = (cnr == prop_atoms.net_wm_moveresize_move ||
cnr == prop_atoms.net_wm_moveresize_move_keyboard);
+ gint up = 1;
+ gint left = 1;
if (moveresize_in_progress || !c->frame->visible ||
!(mv ?
(c->functions & OB_CLIENT_FUNC_RESIZE)))
return;
- if (cnr == prop_atoms.net_wm_moveresize_size_topleft)
+ if (cnr == prop_atoms.net_wm_moveresize_size_topleft) {
cur = OB_CURSOR_NORTHWEST;
- else if (cnr == prop_atoms.net_wm_moveresize_size_top)
+ up = left = -1;
+ } else if (cnr == prop_atoms.net_wm_moveresize_size_top) {
cur = OB_CURSOR_NORTH;
- else if (cnr == prop_atoms.net_wm_moveresize_size_topright)
+ up = -1;
+ } else if (cnr == prop_atoms.net_wm_moveresize_size_topright) {
cur = OB_CURSOR_NORTHEAST;
- else if (cnr == prop_atoms.net_wm_moveresize_size_right)
+ up = -1;
+ } else if (cnr == prop_atoms.net_wm_moveresize_size_right)
cur = OB_CURSOR_EAST;
else if (cnr == prop_atoms.net_wm_moveresize_size_bottomright)
cur = OB_CURSOR_SOUTHEAST;
else if (cnr == prop_atoms.net_wm_moveresize_size_bottom)
cur = OB_CURSOR_SOUTH;
- else if (cnr == prop_atoms.net_wm_moveresize_size_bottomleft)
+ else if (cnr == prop_atoms.net_wm_moveresize_size_bottomleft) {
cur = OB_CURSOR_SOUTHWEST;
- else if (cnr == prop_atoms.net_wm_moveresize_size_left)
+ left = -1;
+ } else if (cnr == prop_atoms.net_wm_moveresize_size_left) {
cur = OB_CURSOR_WEST;
- else if (cnr == prop_atoms.net_wm_moveresize_size_keyboard)
+ left = -1;
+ } else if (cnr == prop_atoms.net_wm_moveresize_size_keyboard)
cur = OB_CURSOR_SOUTHEAST;
else if (cnr == prop_atoms.net_wm_moveresize_move)
cur = OB_CURSOR_MOVE;
friendly. you essentially start the resize in the middle of the
increment instead of at 0, so you have to move half an increment
either way instead of a full increment one and 1 px the other. */
- start_x = x - (mv ? 0 : c->size_inc.width / 2);
- start_y = y - (mv ? 0 : c->size_inc.height / 2);
+ start_x = x - (mv ? 0 : left * c->size_inc.width / 2);
+ start_y = y - (mv ? 0 : up * c->size_inc.height / 2);
corner = cnr;
button = b;
key_resize_edge = -1;
#ifdef SYNC
if (config_resize_redraw && !moving && extensions_sync &&
- moveresize_client->sync_request && moveresize_client->sync_counter)
+ moveresize_client->sync_request && moveresize_client->sync_counter &&
+ !moveresize_client->not_responding)
{
/* Initialize values for the resize syncing, and create an alarm for
the client's xsync counter */
}
-static void do_resize()
+static void do_resize(void)
{
gint x, y, w, h, lw, lh;
#ifdef SYNC
if (config_resize_redraw && extensions_sync &&
- moveresize_client->sync_request && moveresize_client->sync_counter)
+ moveresize_client->sync_request && moveresize_client->sync_counter &&
+ !moveresize_client->not_responding)
{
XEvent ce;
XSyncValue val;
#endif
static void calc_resize(gboolean keyboard, gint keydist, gint *dw, gint *dh,
- ObCorner cor)
+ ObDirection dir)
{
- gint resist, x, y, lw, lh, ow, oh, nw, nh;
+ gint resist, x = 0, y = 0, lw, lh, ow, oh, nw, nh;
+ gint trydw, trydh;
ow = cur_w;
oh = cur_h;
+ nw = ow + *dw;
+ nh = oh + *dh;
+
+ if (!keyboard &&
+ (moveresize_client->max_ratio || moveresize_client->min_ratio))
+ {
+ switch (dir) {
+ case OB_DIRECTION_NORTH:
+ case OB_DIRECTION_SOUTH:
+ /* resize the width based on the height */
+ if (moveresize_client->min_ratio) {
+ if (nh * moveresize_client->min_ratio > nw)
+ nw = (gint)(nh * moveresize_client->min_ratio);
+ }
+ if (moveresize_client->max_ratio) {
+ if (nh * moveresize_client->max_ratio < nw)
+ nw = (gint)(nh * moveresize_client->max_ratio);
+ }
+ break;
+ default:
+ /* resize the height based on the width */
+ if (moveresize_client->min_ratio) {
+ if (nh * moveresize_client->min_ratio > nw)
+ nh = (gint)(nw / moveresize_client->min_ratio);
+ }
+ if (moveresize_client->max_ratio) {
+ if (nh * moveresize_client->max_ratio < nw)
+ nh = (gint)(nw / moveresize_client->max_ratio);
+ }
+ break;
+ }
+
+ /* see its actual size (apply aspect ratios) */
+ client_try_configure(moveresize_client, &x, &y, &nw, &nh, &lw, &lh,
+ TRUE);
+ trydw = nw - ow;
+ trydh = nh - oh;
+ }
+
/* resist_size_* needs the frame size */
- nw = ow + *dw +
- moveresize_client->frame->size.left +
+ nw += moveresize_client->frame->size.left +
moveresize_client->frame->size.right;
- nh = oh + *dh +
- moveresize_client->frame->size.top +
+ nh += moveresize_client->frame->size.top +
moveresize_client->frame->size.bottom;
if (keyboard) resist = keydist - 1; /* resist for one key press */
else resist = config_resist_win;
- resist_size_windows(moveresize_client, resist, &nw, &nh, cor);
+ resist_size_windows(moveresize_client, resist, &nw, &nh, dir);
if (!keyboard) resist = config_resist_edge;
- resist_size_monitors(moveresize_client, resist, &nw, &nh, cor);
+ resist_size_monitors(moveresize_client, resist, &nw, &nh, dir);
nw -= moveresize_client->frame->size.left +
moveresize_client->frame->size.right;
nh -= moveresize_client->frame->size.top +
moveresize_client->frame->size.bottom;
- /* see its actual size */
- x = 0;
- y = 0;
- client_try_configure(moveresize_client, &x, &y, &nw, &nh, &lw, &lh, TRUE);
+ *dw = nw - ow;
+ *dh = nh - oh;
+
+ /* take aspect ratios into account for resistance */
+ if (!keyboard &&
+ (moveresize_client->max_ratio || moveresize_client->min_ratio))
+ {
+ if (*dh != trydh) { /* got resisted */
+ /* resize the width based on the height */
+ if (moveresize_client->min_ratio) {
+ if (nh * moveresize_client->min_ratio > nw)
+ nw = (gint)(nh * moveresize_client->min_ratio);
+ }
+ if (moveresize_client->max_ratio) {
+ if (nh * moveresize_client->max_ratio < nw)
+ nw = (gint)(nh * moveresize_client->max_ratio);
+ }
+ }
+ if (*dw != trydw) { /* got resisted */
+ /* resize the height based on the width */
+ if (moveresize_client->min_ratio) {
+ if (nh * moveresize_client->min_ratio > nw)
+ nh = (gint)(nw / moveresize_client->min_ratio);
+ }
+ if (moveresize_client->max_ratio) {
+ if (nh * moveresize_client->max_ratio < nw)
+ nh = (gint)(nw / moveresize_client->max_ratio);
+ }
+ }
+ }
+ /* make sure it's all valid */
+ client_try_configure(moveresize_client, &x, &y, &nw, &nh, &lw, &lh, TRUE);
*dw = nw - ow;
*dh = nh - oh;
{
guint d;
- d = screen_find_desktop(screen_desktop, edge_warp_dir, TRUE, FALSE);
- if (d != screen_desktop) screen_set_desktop(d, TRUE);
-
- edge_warp_dir = -1;
+ /* only fire every second time. so it's fast the first time, but slower
+ after that */
+ if (edge_warp_odd) {
+ d = screen_find_desktop(screen_desktop, edge_warp_dir, TRUE, FALSE);
+ if (d != screen_desktop) screen_set_desktop(d, TRUE);
+ }
+ edge_warp_odd = !edge_warp_odd;
- return FALSE; /* don't repeat */
+ return TRUE; /* do repeat ! */
}
static void do_edge_warp(gint x, gint y)
}
if (dir != edge_warp_dir) {
- if (dir == (ObDirection)-1)
- cancel_edge_warp();
- else
+ cancel_edge_warp();
+ if (dir != (ObDirection)-1) {
+ edge_warp_odd = TRUE; /* switch on the first timeout */
ob_main_loop_timeout_add(ob_main_loop,
config_mouse_screenedgetime * 1000,
edge_warp_delay_func,
NULL, NULL, NULL);
+ }
edge_warp_dir = dir;
}
}
-static void cancel_edge_warp()
+static void cancel_edge_warp(void)
{
ob_main_loop_timeout_remove(ob_main_loop, edge_warp_delay_func);
}
gint dw = 0, dh = 0, pdx = 0, pdy = 0, opx, opy, px, py;
gint dist = 0, resist = 0;
ObDirection dir;
- ObCorner cor;
/* pick the edge if it needs to move */
if (keycode == ob_keycode(OB_KEY_RIGHT)) {
}
}
- /* which corner is locked, for resistance */
- if (key_resize_edge == OB_DIRECTION_WEST)
- cor = OB_CORNER_TOPRIGHT;
- else if (key_resize_edge == OB_DIRECTION_EAST)
- cor = OB_CORNER_TOPLEFT;
- else if (key_resize_edge == OB_DIRECTION_NORTH)
- cor = OB_CORNER_BOTTOMLEFT;
- else if (key_resize_edge == OB_DIRECTION_SOUTH)
- cor = OB_CORNER_TOPLEFT;
-
- calc_resize(TRUE, resist, &dw, &dh, cor);
+ calc_resize(TRUE, resist, &dw, &dh, dir);
if (key_resize_edge == OB_DIRECTION_WEST)
cur_x -= dw;
else if (key_resize_edge == OB_DIRECTION_NORTH)
do_edge_warp(e->xmotion.x_root, e->xmotion.y_root);
} else {
gint dw, dh;
+ ObDirection dir;
if (corner == prop_atoms.net_wm_moveresize_size_topleft) {
dw = -(e->xmotion.x_root - start_x);
dh = -(e->xmotion.y_root - start_y);
- lockcorner = OB_CORNER_BOTTOMRIGHT;
+ dir = OB_DIRECTION_NORTHWEST;
} else if (corner == prop_atoms.net_wm_moveresize_size_top) {
dw = 0;
dh = -(e->xmotion.y_root - start_y);
- lockcorner = OB_CORNER_BOTTOMRIGHT;
+ dir = OB_DIRECTION_NORTH;
} else if (corner == prop_atoms.net_wm_moveresize_size_topright) {
dw = (e->xmotion.x_root - start_x);
dh = -(e->xmotion.y_root - start_y);
- lockcorner = OB_CORNER_BOTTOMLEFT;
+ dir = OB_DIRECTION_NORTHEAST;
} else if (corner == prop_atoms.net_wm_moveresize_size_right) {
dw = (e->xmotion.x_root - start_x);
dh = 0;
- lockcorner = OB_CORNER_BOTTOMLEFT;
+ dir = OB_DIRECTION_EAST;
} else if (corner ==
prop_atoms.net_wm_moveresize_size_bottomright) {
dw = (e->xmotion.x_root - start_x);
dh = (e->xmotion.y_root - start_y);
- lockcorner = OB_CORNER_TOPLEFT;
+ dir = OB_DIRECTION_SOUTHEAST;
} else if (corner == prop_atoms.net_wm_moveresize_size_bottom) {
dw = 0;
dh = (e->xmotion.y_root - start_y);
- lockcorner = OB_CORNER_TOPLEFT;
+ dir = OB_DIRECTION_SOUTH;
} else if (corner ==
prop_atoms.net_wm_moveresize_size_bottomleft) {
dw = -(e->xmotion.x_root - start_x);
dh = (e->xmotion.y_root - start_y);
- lockcorner = OB_CORNER_TOPRIGHT;
+ dir = OB_DIRECTION_SOUTHWEST;
} else if (corner == prop_atoms.net_wm_moveresize_size_left) {
dw = -(e->xmotion.x_root - start_x);
dh = 0;
- lockcorner = OB_CORNER_TOPRIGHT;
+ dir = OB_DIRECTION_WEST;
} else if (corner == prop_atoms.net_wm_moveresize_size_keyboard) {
dw = (e->xmotion.x_root - start_x);
dh = (e->xmotion.y_root - start_y);
- lockcorner = OB_CORNER_TOPLEFT;
+ dir = OB_DIRECTION_SOUTHEAST;
} else
g_assert_not_reached();
dw -= cur_w - start_cw;
dh -= cur_h - start_ch;
- calc_resize(FALSE, 0, &dw, &dh, lockcorner);
+ calc_resize(FALSE, 0, &dw, &dh, dir);
cur_w += dw;
cur_h += dh;