X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fopenbox;a=blobdiff_plain;f=openbox%2Fmoveresize.c;h=5db79f9f3a32003c6c7b8b139aa33016cefc05b3;hp=95d6473471d219bd4217459a39bbc80a952d3f6b;hb=50d662681160c309ea86268c0d05794b87b75593;hpb=8ada991d829671ab5e6dd4c5526b6a0238ba6a16 diff --git a/openbox/moveresize.c b/openbox/moveresize.c index 95d64734..5db79f9f 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 @@ -168,8 +167,8 @@ 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; @@ -179,32 +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; up = left = -1; - } else if (cnr == prop_atoms.net_wm_moveresize_size_top) { + } + else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOP)) { cur = OB_CURSOR_NORTH; up = -1; - } else if (cnr == prop_atoms.net_wm_moveresize_size_topright) { + } + else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPRIGHT)) { cur = OB_CURSOR_NORTHEAST; up = -1; - } else if (cnr == prop_atoms.net_wm_moveresize_size_right) + } + 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; left = -1; - } else if (cnr == prop_atoms.net_wm_moveresize_size_left) { + } + else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_LEFT)) { cur = OB_CURSOR_WEST; left = -1; - } else if (cnr == prop_atoms.net_wm_moveresize_size_keyboard) + } + 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(); @@ -251,7 +255,7 @@ 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_sync && + if (config_resize_redraw && !moving && obt_display_extension_sync && moveresize_client->sync_request && moveresize_client->sync_counter && !moveresize_client->not_responding) { @@ -263,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 */ @@ -279,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 | @@ -308,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, @@ -364,9 +368,8 @@ static void do_resize(void) { #ifdef SYNC - if (config_resize_redraw && extensions_sync && - moveresize_client->sync_request && - moveresize_client->sync_counter && + if (config_resize_redraw && obt_display_extension_sync && + moveresize_client->sync_request && moveresize_client->sync_counter && !moveresize_client->not_responding) { XEvent ce; @@ -382,28 +385,29 @@ static void do_resize(void) /* 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.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] = prop_atoms.net_wm_sync_request; + 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(ob_display, moveresize_client->window, FALSE, + XSendEvent(obt_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 * 2, - sync_timeout_func, NULL, NULL, NULL); + 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); + TRUE, FALSE, FALSE); } /* this would be better with a fixed width font ... XXX can do it better @@ -576,10 +580,10 @@ static void do_edge_warp(gint x, gint y) 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); + obt_main_loop_timeout_add(ob_main_loop, + config_mouse_screenedgetime * 1000, + edge_warp_delay_func, + NULL, NULL, NULL); } edge_warp_dir = dir; } @@ -587,7 +591,7 @@ static void do_edge_warp(gint x, gint y) 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) @@ -597,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; @@ -615,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; @@ -631,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); @@ -655,7 +662,7 @@ 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, resist = 0; + gint resist = 0; ObDirection dir; /* pick the edge if it needs to move */ @@ -667,8 +674,7 @@ static void resize_with_keys(gint keycode, gint state) key_resize_edge = OB_DIRECTION_EAST; return; } - } - if (ob_keycode_match(keycode, OB_KEY_LEFT)) { + } else if (ob_keycode_match(keycode, OB_KEY_LEFT)) { dir = OB_DIRECTION_WEST; if (key_resize_edge != OB_DIRECTION_WEST && key_resize_edge != OB_DIRECTION_EAST) @@ -676,8 +682,7 @@ static void resize_with_keys(gint keycode, gint state) key_resize_edge = OB_DIRECTION_WEST; return; } - } - if (ob_keycode_match(keycode, OB_KEY_UP)) { + } else if (ob_keycode_match(keycode, OB_KEY_UP)) { dir = OB_DIRECTION_NORTH; if (key_resize_edge != OB_DIRECTION_NORTH && key_resize_edge != OB_DIRECTION_SOUTH) @@ -685,8 +690,7 @@ static void resize_with_keys(gint keycode, gint state) key_resize_edge = OB_DIRECTION_NORTH; return; } - } - if (ob_keycode_match(keycode, OB_KEY_DOWN)) { + } else /* if (ob_keycode_match(keycode, OB_KEY_DOWN)) */ { dir = OB_DIRECTION_SOUTH; if (key_resize_edge != OB_DIRECTION_NORTH && key_resize_edge != OB_DIRECTION_SOUTH) @@ -697,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 (ob_keycode_match(keycode, OB_KEY_RIGHT)) @@ -722,7 +726,9 @@ static void resize_with_keys(gint keycode, gint state) distw = moveresize_client->size_inc.width; resist = 1; } - else if (state & modkeys_key_to_mask(OB_MODKEY_KEY_CONTROL)) { + else if (state & + obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_CONTROL)) + { distw = 1; resist = 1; } @@ -734,7 +740,9 @@ static void resize_with_keys(gint keycode, gint state) disth = moveresize_client->size_inc.height; resist = 1; } - else if (state & modkeys_key_to_mask(OB_MODKEY_KEY_CONTROL)) { + else if (state & + obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_CONTROL)) + { disth = 1; resist = 1; } @@ -745,27 +753,27 @@ static void resize_with_keys(gint keycode, gint state) 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; } } @@ -788,12 +796,12 @@ static void resize_with_keys(gint keycode, gint state) 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); @@ -836,41 +844,44 @@ gboolean moveresize_event(XEvent *e) 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); dir = OB_DIRECTION_NORTHWEST; - } else if (corner == prop_atoms.net_wm_moveresize_size_top) { + } else if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOP)) { dw = 0; dh = -(e->xmotion.y_root - start_y); dir = OB_DIRECTION_NORTH; - } else if (corner == prop_atoms.net_wm_moveresize_size_topright) { + } 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); dir = OB_DIRECTION_NORTHEAST; - } else if (corner == prop_atoms.net_wm_moveresize_size_right) { + } else if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_RIGHT)) { dw = (e->xmotion.x_root - start_x); dh = 0; 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); dir = OB_DIRECTION_SOUTHEAST; - } else if (corner == prop_atoms.net_wm_moveresize_size_bottom) { + } else if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOM)) + { dw = 0; dh = (e->xmotion.y_root - start_y); 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); dir = OB_DIRECTION_SOUTHWEST; - } else if (corner == prop_atoms.net_wm_moveresize_size_left) { + } else if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_LEFT)) { dw = -(e->xmotion.x_root - start_x); dh = 0; dir = OB_DIRECTION_WEST; - } else if (corner == prop_atoms.net_wm_moveresize_size_keyboard) { + } 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); dir = OB_DIRECTION_SOUTHEAST; @@ -884,15 +895,15 @@ gboolean moveresize_event(XEvent *e) 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; } @@ -912,17 +923,19 @@ gboolean moveresize_event(XEvent *e) ob_keycode_match(e->xkey.keycode, OB_KEY_DOWN) || ob_keycode_match(e->xkey.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 */