X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fmoveresize.c;h=d89c31ca22ac416ebff735d2713b0dd2bcfedf5c;hb=fa0ae17adbc8f73b707c33836d37841e81b9303a;hp=29f82cf062f05da19d92e146aaff26420cf61b89;hpb=9eed441c42d21049cc0621ec1fd920423875ff44;p=chaz%2Fopenbox diff --git a/openbox/moveresize.c b/openbox/moveresize.c index 29f82cf0..d89c31ca 100644 --- a/openbox/moveresize.c +++ b/openbox/moveresize.c @@ -20,21 +20,20 @@ #include "grab.h" #include "framerender.h" #include "screen.h" -#include "prop.h" #include "client.h" #include "frame.h" #include "openbox.h" #include "resist.h" -#include "mainloop.h" -#include "modkeys.h" #include "popup.h" #include "moveresize.h" #include "config.h" #include "event.h" #include "debug.h" -#include "extensions.h" #include "render/render.h" #include "render/theme.h" +#include "obt/display.h" +#include "obt/prop.h" +#include "obt/keyboard.h" #include #include @@ -54,8 +53,8 @@ static gint start_x, start_y, start_cx, start_cy, start_cw, start_ch; 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; @@ -63,6 +62,8 @@ static gboolean waiting_for_sync; static ObPopup *popup = NULL; +static void do_move(gboolean keyboard, gint keydist); +static void do_resize(void); static void do_edge_warp(gint x, gint y); static void cancel_edge_warp(); #ifdef SYNC @@ -72,12 +73,12 @@ static gboolean sync_timeout_func(gpointer data); static void client_dest(ObClient *client, gpointer data) { if (moveresize_client == client) - moveresize_end(TRUE); + moveresize_end(TRUE); } void moveresize_startup(gboolean reconfig) { - popup = popup_new(FALSE); + popup = popup_new(); popup_set_text_align(popup, RR_JUSTIFY_CENTER); if (!reconfig) @@ -101,17 +102,64 @@ static void popup_coords(ObClient *c, const gchar *format, gint a, gint b) 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); + c->frame->area.x + c->frame->area.width / 2, + c->frame->area.y + c->frame->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); } @@ -119,8 +167,10 @@ static void popup_coords(ObClient *c, const gchar *format, gint a, gint b) void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr) { ObCursor cur; - gboolean mv = (cnr == prop_atoms.net_wm_moveresize_move || - cnr == prop_atoms.net_wm_moveresize_move_keyboard); + gboolean mv = (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE) || + cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE_KEYBOARD)); + gint up = 1; + gint left = 1; if (moveresize_in_progress || !c->frame->visible || !(mv ? @@ -128,27 +178,37 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr) (c->functions & OB_CLIENT_FUNC_RESIZE))) return; - if (cnr == prop_atoms.net_wm_moveresize_size_topleft) + if (cnr == OBT_PROP_ATOM(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 == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOP)) { cur = OB_CURSOR_NORTH; - else if (cnr == prop_atoms.net_wm_moveresize_size_topright) + up = -1; + } + else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPRIGHT)) { cur = OB_CURSOR_NORTHEAST; - else if (cnr == prop_atoms.net_wm_moveresize_size_right) + up = -1; + } + else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_RIGHT)) cur = OB_CURSOR_EAST; - else if (cnr == prop_atoms.net_wm_moveresize_size_bottomright) + else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT)) cur = OB_CURSOR_SOUTHEAST; - else if (cnr == prop_atoms.net_wm_moveresize_size_bottom) + else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOM)) cur = OB_CURSOR_SOUTH; - else if (cnr == prop_atoms.net_wm_moveresize_size_bottomleft) + else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT)) { cur = OB_CURSOR_SOUTHWEST; - else if (cnr == prop_atoms.net_wm_moveresize_size_left) + left = -1; + } + else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_LEFT)) { cur = OB_CURSOR_WEST; - else if (cnr == prop_atoms.net_wm_moveresize_size_keyboard) + left = -1; + } + else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_KEYBOARD)) cur = OB_CURSOR_SOUTHEAST; - else if (cnr == prop_atoms.net_wm_moveresize_move) + else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE)) cur = OB_CURSOR_MOVE; - else if (cnr == prop_atoms.net_wm_moveresize_move_keyboard) + else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE_KEYBOARD)) cur = OB_CURSOR_MOVE; else g_assert_not_reached(); @@ -167,14 +227,14 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr) moveresize_client = c; start_cx = c->area.x; start_cy = c->area.y; + start_cw = c->area.width; + start_ch = c->area.height; /* these adjustments for the size_inc make resizing a terminal more 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_cw = c->area.width + c->size_inc.width / 2; - start_ch = c->area.height + c->size_inc.height / 2; - start_x = x; - start_y = y; + 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; @@ -195,8 +255,9 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr) moveresize_in_progress = TRUE; #ifdef SYNC - if (config_resize_redraw && !moving && extensions_shape && - moveresize_client->sync_request && moveresize_client->sync_counter) + if (config_resize_redraw && !moving && obt_display_extension_sync && + 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 */ @@ -206,7 +267,7 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr) /* set the counter to an initial value */ XSyncIntToValue(&val, 0); - XSyncSetCounter(ob_display, moveresize_client->sync_counter, val); + XSyncSetCounter(obt_display, moveresize_client->sync_counter, val); /* this will be incremented when we tell the client what we're looking for */ @@ -222,7 +283,7 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr) aa.trigger.test_type = XSyncPositiveTransition; aa.events = True; XSyncIntToValue(&aa.delta, 1); - moveresize_alarm = XSyncCreateAlarm(ob_display, + moveresize_alarm = XSyncCreateAlarm(obt_display, XSyncCACounter | XSyncCAValue | XSyncCAValueType | @@ -251,11 +312,11 @@ void moveresize_end(gboolean cancel) #ifdef SYNC /* turn off the alarm */ if (moveresize_alarm != None) { - XSyncDestroyAlarm(ob_display, moveresize_alarm); + XSyncDestroyAlarm(obt_display, moveresize_alarm); moveresize_alarm = None; } - ob_main_loop_timeout_remove(ob_main_loop, sync_timeout_func); + obt_main_loop_timeout_remove(ob_main_loop, sync_timeout_func); #endif client_configure(moveresize_client, @@ -291,8 +352,7 @@ static void do_move(gboolean keyboard, gint keydist) moveresize_client->frame->area.y); } - -static void do_resize() +static void do_resize(void) { gint x, y, w, h, lw, lh; @@ -303,52 +363,52 @@ static void do_resize() h = cur_h; client_try_configure(moveresize_client, &x, &y, &w, &h, &lw, &lh, TRUE); - if (w == moveresize_client->area.width && - h == moveresize_client->area.height) + if (!(w == moveresize_client->area.width && + h == moveresize_client->area.height)) { - return; - } #ifdef SYNC - if (config_resize_redraw && extensions_sync && - moveresize_client->sync_request && moveresize_client->sync_counter) - { - XEvent ce; - XSyncValue val; - - /* are we already waiting for the sync counter to catch up? */ - if (waiting_for_sync) - return; - - /* increment the value we're waiting for */ - ++moveresize_client->sync_counter_value; - XSyncIntToValue(&val, moveresize_client->sync_counter_value); - - /* tell the client what we're waiting for */ - ce.xclient.type = ClientMessage; - ce.xclient.message_type = prop_atoms.wm_protocols; - ce.xclient.display = ob_display; - ce.xclient.window = moveresize_client->window; - ce.xclient.format = 32; - ce.xclient.data.l[0] = prop_atoms.net_wm_sync_request; - ce.xclient.data.l[1] = event_curtime; - ce.xclient.data.l[2] = XSyncValueLow32(val); - ce.xclient.data.l[3] = XSyncValueHigh32(val); - ce.xclient.data.l[4] = 0l; - XSendEvent(ob_display, moveresize_client->window, FALSE, - NoEventMask, &ce); - - waiting_for_sync = TRUE; - - ob_main_loop_timeout_remove(ob_main_loop, sync_timeout_func); - ob_main_loop_timeout_add(ob_main_loop, G_USEC_PER_SEC, - sync_timeout_func, - NULL, NULL, NULL); - } + if (config_resize_redraw && obt_display_extension_sync && + moveresize_client->sync_request && moveresize_client->sync_counter && + !moveresize_client->not_responding) + { + XEvent ce; + XSyncValue val; + + /* are we already waiting for the sync counter to catch up? */ + if (waiting_for_sync) + return; + + /* increment the value we're waiting for */ + ++moveresize_client->sync_counter_value; + XSyncIntToValue(&val, moveresize_client->sync_counter_value); + + /* tell the client what we're waiting for */ + ce.xclient.type = ClientMessage; + ce.xclient.message_type = OBT_PROP_ATOM(WM_PROTOCOLS); + ce.xclient.display = obt_display; + ce.xclient.window = moveresize_client->window; + ce.xclient.format = 32; + ce.xclient.data.l[0] = OBT_PROP_ATOM(NET_WM_SYNC_REQUEST); + ce.xclient.data.l[1] = event_curtime; + ce.xclient.data.l[2] = XSyncValueLow32(val); + ce.xclient.data.l[3] = XSyncValueHigh32(val); + ce.xclient.data.l[4] = 0l; + XSendEvent(obt_display, moveresize_client->window, FALSE, + NoEventMask, &ce); + + waiting_for_sync = TRUE; + + obt_main_loop_timeout_remove(ob_main_loop, sync_timeout_func); + obt_main_loop_timeout_add(ob_main_loop, G_USEC_PER_SEC * 2, + sync_timeout_func, + NULL, NULL, NULL); + } #endif - client_configure(moveresize_client, cur_x, cur_y, cur_w, cur_h, - TRUE, FALSE, FALSE); + client_configure(moveresize_client, cur_x, cur_y, cur_w, cur_h, + TRUE, FALSE, FALSE); + } /* this would be better with a fixed width font ... XXX can do it better if there are 2 text boxes */ @@ -356,9 +416,7 @@ static void do_resize() (config_resize_popup_show == 1 && /* == "Nonpixel" */ moveresize_client->size_inc.width > 1 && moveresize_client->size_inc.height > 1)) - popup_coords(moveresize_client, "%d x %d", - moveresize_client->logical_size.width, - moveresize_client->logical_size.height); + popup_coords(moveresize_client, "%d x %d", lw, lh); } #ifdef SYNC @@ -372,36 +430,102 @@ static gboolean sync_timeout_func(gpointer data) #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; @@ -411,12 +535,15 @@ static gboolean edge_warp_delay_func(gpointer data) { 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) @@ -450,20 +577,21 @@ static void do_edge_warp(gint x, gint y) } if (dir != edge_warp_dir) { - if (dir == (ObDirection)-1) - cancel_edge_warp(); - else - ob_main_loop_timeout_add(ob_main_loop, - config_mouse_screenedgetime * 1000, - edge_warp_delay_func, - NULL, NULL, NULL); + cancel_edge_warp(); + if (dir != (ObDirection)-1) { + edge_warp_odd = TRUE; /* switch on the first timeout */ + obt_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); + obt_main_loop_timeout_remove(ob_main_loop, edge_warp_delay_func); } static void move_with_keys(gint keycode, gint state) @@ -473,7 +601,7 @@ static void move_with_keys(gint keycode, gint state) gint dist = 0; /* shift means jump to edge */ - if (state & modkeys_key_to_mask(OB_MODKEY_KEY_SHIFT)) { + if (state & obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_SHIFT)) { gint x, y; ObDirection dir; @@ -491,8 +619,11 @@ static void move_with_keys(gint keycode, gint state) dy = y - moveresize_client->area.y; } else { /* control means fine grained */ - if (state & modkeys_key_to_mask(OB_MODKEY_KEY_CONTROL)) + if (state & + obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_CONTROL)) + { dist = 1; + } else dist = KEY_DIST; @@ -507,12 +638,12 @@ static void move_with_keys(gint keycode, gint state) } screen_pointer_pos(&opx, &opy); - XWarpPointer(ob_display, None, None, 0, 0, 0, 0, dx, dy); + XWarpPointer(obt_display, None, None, 0, 0, 0, 0, dx, dy); /* steal the motion events this causes */ - XSync(ob_display, FALSE); + XSync(obt_display, FALSE); { XEvent ce; - while (XCheckTypedEvent(ob_display, MotionNotify, &ce)); + while (XCheckTypedEvent(obt_display, MotionNotify, &ce)); } screen_pointer_pos(&px, &py); @@ -531,9 +662,8 @@ static void move_with_keys(gint keycode, gint state) static void resize_with_keys(gint keycode, gint state) { gint dw = 0, dh = 0, pdx = 0, pdy = 0, opx, opy, px, py; - gint dist = 0; + gint resist = 0; ObDirection dir; - ObCorner cor; /* pick the edge if it needs to move */ if (keycode == ob_keycode(OB_KEY_RIGHT)) { @@ -544,8 +674,7 @@ static void resize_with_keys(gint keycode, gint state) key_resize_edge = OB_DIRECTION_EAST; return; } - } - if (keycode == ob_keycode(OB_KEY_LEFT)) { + } else if (keycode == ob_keycode(OB_KEY_LEFT)) { dir = OB_DIRECTION_WEST; if (key_resize_edge != OB_DIRECTION_WEST && key_resize_edge != OB_DIRECTION_EAST) @@ -553,8 +682,7 @@ static void resize_with_keys(gint keycode, gint state) key_resize_edge = OB_DIRECTION_WEST; return; } - } - if (keycode == ob_keycode(OB_KEY_UP)) { + } else if (keycode == ob_keycode(OB_KEY_UP)) { dir = OB_DIRECTION_NORTH; if (key_resize_edge != OB_DIRECTION_NORTH && key_resize_edge != OB_DIRECTION_SOUTH) @@ -562,8 +690,7 @@ static void resize_with_keys(gint keycode, gint state) key_resize_edge = OB_DIRECTION_NORTH; return; } - } - if (keycode == ob_keycode(OB_KEY_DOWN)) { + } else /* if (keycode == ob_keycode(OB_KEY_DOWN)) */ { dir = OB_DIRECTION_SOUTH; if (key_resize_edge != OB_DIRECTION_NORTH && key_resize_edge != OB_DIRECTION_SOUTH) @@ -574,7 +701,7 @@ static void resize_with_keys(gint keycode, gint state) } /* shift means jump to edge */ - if (state & modkeys_key_to_mask(OB_MODKEY_KEY_SHIFT)) { + if (state & obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_SHIFT)) { gint x, y, w, h; if (keycode == ob_keycode(OB_KEY_RIGHT)) @@ -595,56 +722,62 @@ static void resize_with_keys(gint keycode, gint state) gint distw, disth; /* control means fine grained */ - if (moveresize_client->size_inc.width > 1) + if (moveresize_client->size_inc.width > 1) { distw = moveresize_client->size_inc.width; - else if (state & modkeys_key_to_mask(OB_MODKEY_KEY_CONTROL)) + resist = 1; + } + else if (state & + obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_CONTROL)) + { distw = 1; - else + resist = 1; + } + else { distw = KEY_DIST; - if (moveresize_client->size_inc.height > 1) + resist = KEY_DIST; + } + if (moveresize_client->size_inc.height > 1) { disth = moveresize_client->size_inc.height; - else if (state & modkeys_key_to_mask(OB_MODKEY_KEY_CONTROL)) + resist = 1; + } + else if (state & + obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_CONTROL)) + { disth = 1; - else + resist = 1; + } + else { disth = KEY_DIST; + resist = KEY_DIST; + } if (key_resize_edge == OB_DIRECTION_WEST) { if (dir == OB_DIRECTION_WEST) - dw = (dist = distw); + dw = distw; else - dw = -(dist = distw); + dw = -distw; } else if (key_resize_edge == OB_DIRECTION_EAST) { if (dir == OB_DIRECTION_EAST) - dw = (dist = distw); + dw = distw; else - dw = -(dist = distw); + dw = -distw; } else if (key_resize_edge == OB_DIRECTION_NORTH) { if (dir == OB_DIRECTION_NORTH) - dh = (dist = disth); + dh = disth; else - dh = -(dist = disth); + dh = -disth; } else /*if (key_resize_edge == OB_DIRECTION_SOUTH)*/ { if (dir == OB_DIRECTION_SOUTH) - dh = (dist = disth); + dh = disth; else - dh = -(dist = disth); + dh = -disth; } } - /* 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, dist, &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) @@ -661,14 +794,14 @@ static void resize_with_keys(gint keycode, gint state) pdy = -dh; else if (key_resize_edge == OB_DIRECTION_SOUTH) pdy = dh; - + screen_pointer_pos(&opx, &opy); - XWarpPointer(ob_display, None, None, 0, 0, 0, 0, pdx, pdy); + XWarpPointer(obt_display, None, None, 0, 0, 0, 0, pdx, pdy); /* steal the motion events this causes */ - XSync(ob_display, FALSE); + XSync(obt_display, FALSE); { XEvent ce; - while (XCheckTypedEvent(ob_display, MotionNotify, &ce)); + while (XCheckTypedEvent(obt_display, MotionNotify, &ce)); } screen_pointer_pos(&px, &py); @@ -709,65 +842,68 @@ gboolean moveresize_event(XEvent *e) 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) { + if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPLEFT)) { dw = -(e->xmotion.x_root - start_x); dh = -(e->xmotion.y_root - start_y); - lockcorner = OB_CORNER_BOTTOMRIGHT; - } else if (corner == prop_atoms.net_wm_moveresize_size_top) { + dir = OB_DIRECTION_NORTHWEST; + } else if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOP)) { dw = 0; - dh = (e->xmotion.y_root - start_y); - lockcorner = OB_CORNER_BOTTOMRIGHT; - } else if (corner == prop_atoms.net_wm_moveresize_size_topright) { + dh = -(e->xmotion.y_root - start_y); + dir = OB_DIRECTION_NORTH; + } else if (corner == + OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPRIGHT)) { dw = (e->xmotion.x_root - start_x); dh = -(e->xmotion.y_root - start_y); - lockcorner = OB_CORNER_BOTTOMLEFT; - } else if (corner == prop_atoms.net_wm_moveresize_size_right) { + dir = OB_DIRECTION_NORTHEAST; + } else if (corner == OBT_PROP_ATOM(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) { + OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT)) { dw = (e->xmotion.x_root - start_x); dh = (e->xmotion.y_root - start_y); - lockcorner = OB_CORNER_TOPLEFT; - } else if (corner == prop_atoms.net_wm_moveresize_size_bottom) { + dir = OB_DIRECTION_SOUTHEAST; + } else if (corner == OBT_PROP_ATOM(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) { + OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT)) { dw = -(e->xmotion.x_root - start_x); dh = (e->xmotion.y_root - start_y); - lockcorner = OB_CORNER_TOPRIGHT; - } else if (corner == prop_atoms.net_wm_moveresize_size_left) { + dir = OB_DIRECTION_SOUTHWEST; + } else if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_LEFT)) { dw = -(e->xmotion.x_root - start_x); dh = 0; - lockcorner = OB_CORNER_TOPRIGHT; - } else if (corner == prop_atoms.net_wm_moveresize_size_keyboard) { + dir = OB_DIRECTION_WEST; + } else if (corner == + OBT_PROP_ATOM(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; - ob_debug("dw %d\n", dw); - calc_resize(FALSE, 0, &dw, &dh, lockcorner); + calc_resize(FALSE, 0, &dw, &dh, dir); cur_w += dw; cur_h += dh; - if (corner == prop_atoms.net_wm_moveresize_size_topleft || - corner == prop_atoms.net_wm_moveresize_size_left || - corner == prop_atoms.net_wm_moveresize_size_bottomleft) + if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPLEFT) || + corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_LEFT) || + corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT)) { cur_x -= dw; } - if (corner == prop_atoms.net_wm_moveresize_size_topleft || - corner == prop_atoms.net_wm_moveresize_size_top || - corner == prop_atoms.net_wm_moveresize_size_topright) + if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPLEFT) || + corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOP) || + corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPRIGHT)) { cur_y -= dh; } @@ -787,17 +923,19 @@ gboolean moveresize_event(XEvent *e) e->xkey.keycode == ob_keycode(OB_KEY_DOWN) || e->xkey.keycode == ob_keycode(OB_KEY_UP)) { - if (corner == prop_atoms.net_wm_moveresize_size_keyboard) { + if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_KEYBOARD)) { resize_with_keys(e->xkey.keycode, e->xkey.state); used = TRUE; - } else if (corner == prop_atoms.net_wm_moveresize_move_keyboard) { + } else if (corner == + OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE_KEYBOARD)) + { move_with_keys(e->xkey.keycode, e->xkey.state); used = TRUE; } } } #ifdef SYNC - else if (e->type == extensions_sync_event_basep + XSyncAlarmNotify) + else if (e->type == obt_display_extension_sync_basep + XSyncAlarmNotify) { waiting_for_sync = FALSE; /* we got our sync... */ do_resize(); /* ...so try resize if there is more change pending */