~ubuntu-branches/debian/sid/openbox/sid

« back to all changes in this revision

Viewing changes to openbox/moveresize.c

  • Committer: Bazaar Package Importer
  • Author(s): Nico Golde, Nico Golde, Eugenio Paolantonio
  • Date: 2011-10-03 22:59:30 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20111003225930-tdvyax5tx63dyoez
Tags: 3.5.0-1
[Nico Golde]
* New upstream release (Closes: #638783).
  - Fix crashes in the menu code (Closes: #563891).
* Add Brazilian translation to openbox.desktop,
  thanks Sérgio Cipolla (Closes: #627912).
* Remove 06_fix_swap_byte_order.patch, applied upstream.
* Bump debhelper dependency to >= 7.0.50~ due to override.
* Remove CHANGELOG from openbox.docs to prevent double installation.
* Add 02_fix_freedesktop_compliance.dpatch desktop file to
  /usr/share/applications.

[Eugenio Paolantonio]
* debian/patches:
  - Disabled 03_place_windows_in_quadrants.patch
  - Updated 01_rc.xml.patch and 06_fix_swap_byte_order.patch
  - Removed 04_fix_ftbfs_no-add-needed.patch and 20_24bits_support.patch
* debian/control:
  - Added myself to the Uploaders.
  - Build-Depends: removed libxau-dev, libxft-dev and python-xdg;
    added libimlib2-dev
  - openbox Suggests: added python-xdg
  - libobrender21 renamed to libobrender27
  - libobparser21 renamed to libobt0
* debian/rules:
  - Rewrote using a simpler debhelper syntax
  - Moved the install pass to openbox.install
* debian/*.{install,links,dirs}:
  - Updated.
* debian/openbox.xsession:
  - Removed. Openbox now ships it by default.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include "grab.h"
21
21
#include "framerender.h"
22
22
#include "screen.h"
23
 
#include "prop.h"
24
23
#include "client.h"
 
24
#include "focus.h"
25
25
#include "frame.h"
26
26
#include "openbox.h"
27
27
#include "resist.h"
28
 
#include "mainloop.h"
29
 
#include "modkeys.h"
30
28
#include "popup.h"
31
29
#include "moveresize.h"
32
30
#include "config.h"
33
31
#include "event.h"
34
32
#include "debug.h"
35
 
#include "extensions.h"
36
 
#include "render/render.h"
37
 
#include "render/theme.h"
 
33
#include "obrender/render.h"
 
34
#include "obrender/theme.h"
 
35
#include "obt/display.h"
 
36
#include "obt/xqueue.h"
 
37
#include "obt/prop.h"
 
38
#include "obt/keyboard.h"
38
39
 
39
40
#include <X11/Xlib.h>
40
41
#include <glib.h>
41
42
 
42
43
/* how far windows move and resize with the keyboard arrows */
43
44
#define KEY_DIST 8
 
45
#define SYNC_TIMEOUTS 4
44
46
 
45
47
gboolean moveresize_in_progress = FALSE;
46
48
ObClient *moveresize_client = NULL;
50
52
 
51
53
static gboolean moving = FALSE; /* TRUE - moving, FALSE - resizing */
52
54
 
 
55
/* starting geometry for the window being moved/resized, so it can be
 
56
   restored */
53
57
static gint start_x, start_y, start_cx, start_cy, start_cw, start_ch;
 
58
static gboolean was_max_horz, was_max_vert;
 
59
static Rect pre_max_area;
54
60
static gint cur_x, cur_y, cur_w, cur_h;
55
61
static guint button;
56
62
static guint32 corner;
57
63
static ObDirection edge_warp_dir = -1;
58
64
static gboolean edge_warp_odd = FALSE;
 
65
static guint edge_warp_timer = 0;
59
66
static ObDirection key_resize_edge = -1;
 
67
static guint waiting_for_sync;
60
68
#ifdef SYNC
61
 
static gboolean waiting_for_sync;
 
69
static guint sync_timer = 0;
62
70
#endif
63
71
 
64
72
static ObPopup *popup = NULL;
113
121
                       c->frame->area.x + c->frame->area.width / 2,
114
122
                       c->frame->area.y + c->frame->area.height / 2);
115
123
    else /* Fixed */ {
116
 
        Rect *area = screen_physical_area_active();
 
124
        const Rect *area = screen_physical_area_active();
117
125
        gint gravity, x, y;
118
126
 
119
127
        x = config_resize_popup_fixed.x.pos;
158
166
        }
159
167
 
160
168
        popup_position(popup, gravity, x, y);
161
 
 
162
 
        g_free(area);
163
169
    }
164
170
    popup_show(popup, text);
165
171
    g_free(text);
168
174
void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr)
169
175
{
170
176
    ObCursor cur;
171
 
    gboolean mv = (cnr == prop_atoms.net_wm_moveresize_move ||
172
 
                   cnr == prop_atoms.net_wm_moveresize_move_keyboard);
 
177
    gboolean mv = (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE) ||
 
178
                   cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE_KEYBOARD));
173
179
    gint up = 1;
174
180
    gint left = 1;
175
181
 
179
185
          (c->functions & OB_CLIENT_FUNC_RESIZE)))
180
186
        return;
181
187
 
182
 
    if (cnr == prop_atoms.net_wm_moveresize_size_topleft) {
 
188
    if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPLEFT)) {
183
189
        cur = OB_CURSOR_NORTHWEST;
184
190
        up = left = -1;
185
 
    } else if (cnr == prop_atoms.net_wm_moveresize_size_top) {
 
191
    }
 
192
    else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOP)) {
186
193
        cur = OB_CURSOR_NORTH;
187
194
        up = -1;
188
 
    } else if (cnr == prop_atoms.net_wm_moveresize_size_topright) {
 
195
    }
 
196
    else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPRIGHT)) {
189
197
        cur = OB_CURSOR_NORTHEAST;
190
198
        up = -1;
191
 
    } else if (cnr == prop_atoms.net_wm_moveresize_size_right)
 
199
    }
 
200
    else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_RIGHT))
192
201
        cur = OB_CURSOR_EAST;
193
 
    else if (cnr == prop_atoms.net_wm_moveresize_size_bottomright)
 
202
    else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT))
194
203
        cur = OB_CURSOR_SOUTHEAST;
195
 
    else if (cnr == prop_atoms.net_wm_moveresize_size_bottom)
 
204
    else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOM))
196
205
        cur = OB_CURSOR_SOUTH;
197
 
    else if (cnr == prop_atoms.net_wm_moveresize_size_bottomleft) {
 
206
    else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT)) {
198
207
        cur = OB_CURSOR_SOUTHWEST;
199
208
        left = -1;
200
 
    } else if (cnr == prop_atoms.net_wm_moveresize_size_left) {
 
209
    }
 
210
    else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_LEFT)) {
201
211
        cur = OB_CURSOR_WEST;
202
212
        left = -1;
203
 
    } else if (cnr == prop_atoms.net_wm_moveresize_size_keyboard)
 
213
    }
 
214
    else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_KEYBOARD))
204
215
        cur = OB_CURSOR_SOUTHEAST;
205
 
    else if (cnr == prop_atoms.net_wm_moveresize_move)
 
216
    else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE))
206
217
        cur = OB_CURSOR_MOVE;
207
 
    else if (cnr == prop_atoms.net_wm_moveresize_move_keyboard)
 
218
    else if (cnr == OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE_KEYBOARD))
208
219
        cur = OB_CURSOR_MOVE;
209
220
    else
210
221
        g_assert_not_reached();
235
246
    button = b;
236
247
    key_resize_edge = -1;
237
248
 
 
249
    /* default to not putting max back on cancel */
 
250
    was_max_horz = was_max_vert = FALSE;
 
251
 
238
252
    /*
239
253
      have to change start_cx and start_cy if going to do this..
240
254
    if (corner == prop_atoms.net_wm_moveresize_move_keyboard ||
249
263
    cur_h = start_ch;
250
264
 
251
265
    moveresize_in_progress = TRUE;
 
266
    waiting_for_sync = 0;
252
267
 
253
268
#ifdef SYNC
254
 
    if (config_resize_redraw && !moving && extensions_sync &&
 
269
    if (config_resize_redraw && !moving && obt_display_extension_sync &&
255
270
        moveresize_client->sync_request && moveresize_client->sync_counter &&
256
271
        !moveresize_client->not_responding)
257
272
    {
263
278
 
264
279
        /* set the counter to an initial value */
265
280
        XSyncIntToValue(&val, 0);
266
 
        XSyncSetCounter(ob_display, moveresize_client->sync_counter, val);
 
281
        XSyncSetCounter(obt_display, moveresize_client->sync_counter, val);
267
282
 
268
283
        /* this will be incremented when we tell the client what we're
269
284
           looking for */
279
294
        aa.trigger.test_type = XSyncPositiveTransition;
280
295
        aa.events = True;
281
296
        XSyncIntToValue(&aa.delta, 1);
282
 
        moveresize_alarm = XSyncCreateAlarm(ob_display,
 
297
        moveresize_alarm = XSyncCreateAlarm(obt_display,
283
298
                                            XSyncCACounter |
284
299
                                            XSyncCAValue |
285
300
                                            XSyncCAValueType |
287
302
                                            XSyncCADelta |
288
303
                                            XSyncCAEvents,
289
304
                                            &aa);
290
 
 
291
 
        waiting_for_sync = FALSE;
292
305
    }
293
306
#endif
294
307
}
304
317
#ifdef SYNC
305
318
        /* turn off the alarm */
306
319
        if (moveresize_alarm != None) {
307
 
            XSyncDestroyAlarm(ob_display, moveresize_alarm);
 
320
            XSyncDestroyAlarm(obt_display, moveresize_alarm);
308
321
            moveresize_alarm = None;
309
322
        }
310
323
 
311
 
        ob_main_loop_timeout_remove(ob_main_loop, sync_timeout_func);
 
324
        if (sync_timer) g_source_remove(sync_timer);
 
325
        sync_timer = 0;
312
326
#endif
313
327
    }
314
328
 
323
337
                     (cancel ? start_ch : cur_h),
324
338
                     TRUE, TRUE, FALSE);
325
339
 
 
340
    /* restore the client's maximized state. do this after putting the window
 
341
       back in its original spot to minimize visible flicker */
 
342
    if (cancel && (was_max_horz || was_max_vert)) {
 
343
        const gboolean h = moveresize_client->max_horz;
 
344
        const gboolean v = moveresize_client->max_vert;
 
345
 
 
346
        client_maximize(moveresize_client, TRUE,
 
347
                        was_max_horz && was_max_vert ? 0 :
 
348
                        (was_max_horz ? 1 : 2));
 
349
 
 
350
        /* replace the premax values with the ones we had saved if
 
351
           the client doesn't have any already set */
 
352
        if (was_max_horz && !h) {
 
353
            moveresize_client->pre_max_area.x = pre_max_area.x;
 
354
            moveresize_client->pre_max_area.width = pre_max_area.width;
 
355
        }
 
356
        if (was_max_vert && !v) {
 
357
            moveresize_client->pre_max_area.y = pre_max_area.y;
 
358
            moveresize_client->pre_max_area.height = pre_max_area.height;
 
359
        }
 
360
    }
 
361
 
326
362
    /* dont edge warp after its ended */
327
363
    cancel_edge_warp();
328
364
 
352
388
{
353
389
    gint x, y, w, h, lw, lh;
354
390
 
355
 
    /* see if it is actually going to resize */
356
 
    x = 0;
357
 
    y = 0;
 
391
    /* see if it is actually going to resize
 
392
       USE cur_x AND cur_y HERE !  Otherwise the try_configure won't know
 
393
       what struts to use !!
 
394
     */
 
395
    x = cur_x;
 
396
    y = cur_y;
358
397
    w = cur_w;
359
398
    h = cur_h;
360
399
    client_try_configure(moveresize_client, &x, &y, &w, &h,
361
400
                         &lw, &lh, TRUE);
362
401
    if (!(w == moveresize_client->area.width &&
363
 
          h == moveresize_client->area.height))
 
402
          h == moveresize_client->area.height) &&
 
403
        /* if waiting_for_sync == 0, then we aren't waiting.
 
404
           if it is > SYNC_TIMEOUTS, then we have timed out
 
405
           that many times already, so forget about waiting more */
 
406
        (waiting_for_sync == 0 || waiting_for_sync > SYNC_TIMEOUTS))
364
407
    {
365
 
 
366
408
#ifdef SYNC
367
 
        if (config_resize_redraw && extensions_sync &&
 
409
        if (config_resize_redraw && obt_display_extension_sync &&
 
410
            /* don't send another sync when one is pending */
 
411
            waiting_for_sync == 0 &&
368
412
            moveresize_client->sync_request &&
369
413
            moveresize_client->sync_counter &&
370
414
            !moveresize_client->not_responding)
372
416
            XEvent ce;
373
417
            XSyncValue val;
374
418
 
375
 
            /* are we already waiting for the sync counter to catch up? */
376
 
            if (waiting_for_sync)
377
 
                return;
378
 
 
379
419
            /* increment the value we're waiting for */
380
420
            ++moveresize_client->sync_counter_value;
381
421
            XSyncIntToValue(&val, moveresize_client->sync_counter_value);
382
422
 
383
423
            /* tell the client what we're waiting for */
384
424
            ce.xclient.type = ClientMessage;
385
 
            ce.xclient.message_type = prop_atoms.wm_protocols;
386
 
            ce.xclient.display = ob_display;
 
425
            ce.xclient.message_type = OBT_PROP_ATOM(WM_PROTOCOLS);
 
426
            ce.xclient.display = obt_display;
387
427
            ce.xclient.window = moveresize_client->window;
388
428
            ce.xclient.format = 32;
389
 
            ce.xclient.data.l[0] = prop_atoms.net_wm_sync_request;
390
 
            ce.xclient.data.l[1] = event_curtime;
 
429
            ce.xclient.data.l[0] = OBT_PROP_ATOM(NET_WM_SYNC_REQUEST);
 
430
            ce.xclient.data.l[1] = event_time();
391
431
            ce.xclient.data.l[2] = XSyncValueLow32(val);
392
432
            ce.xclient.data.l[3] = XSyncValueHigh32(val);
393
433
            ce.xclient.data.l[4] = 0l;
394
 
            XSendEvent(ob_display, moveresize_client->window, FALSE,
 
434
            XSendEvent(obt_display, moveresize_client->window, FALSE,
395
435
                       NoEventMask, &ce);
396
436
 
397
 
            waiting_for_sync = TRUE;
 
437
            waiting_for_sync = 1;
398
438
 
399
 
            ob_main_loop_timeout_remove(ob_main_loop, sync_timeout_func);
400
 
            ob_main_loop_timeout_add(ob_main_loop, G_USEC_PER_SEC * 2,
401
 
                                     sync_timeout_func, NULL, NULL, NULL);
 
439
            if (sync_timer) g_source_remove(sync_timer);
 
440
            sync_timer = g_timeout_add(2000, sync_timeout_func, NULL);
402
441
        }
403
442
#endif
404
443
 
 
444
        /* force a ConfigureNotify, it is part of the spec for SYNC resizing
 
445
           and MUST follow the sync counter notification */
405
446
        client_configure(moveresize_client, cur_x, cur_y, cur_w, cur_h,
406
 
                TRUE, FALSE, FALSE);
 
447
                         TRUE, FALSE, TRUE);
407
448
    }
408
449
 
409
450
    /* this would be better with a fixed width font ... XXX can do it better
418
459
#ifdef SYNC
419
460
static gboolean sync_timeout_func(gpointer data)
420
461
{
421
 
    waiting_for_sync = FALSE; /* we timed out waiting for our sync... */
 
462
    ++waiting_for_sync; /* we timed out waiting for our sync... */
422
463
    do_resize(); /* ...so let any pending resizes through */
423
464
 
424
 
    return FALSE; /* don't repeat */
 
465
    if (waiting_for_sync > SYNC_TIMEOUTS) {
 
466
        sync_timer = 0;
 
467
        return FALSE; /* don't repeat */
 
468
    }
 
469
    else
 
470
        return TRUE; /* keep waiting */
425
471
}
426
472
#endif
427
473
 
527
573
    *dh = nh - oh;
528
574
}
529
575
 
 
576
static void edge_warp_move_ptr(void)
 
577
{
 
578
    gint x, y;
 
579
    const Rect* a;
 
580
 
 
581
    screen_pointer_pos(&x, &y);
 
582
    a = screen_physical_area_all_monitors();
 
583
 
 
584
    switch (edge_warp_dir) {
 
585
        case OB_DIRECTION_NORTH:
 
586
            y = a->height - 1;
 
587
            break;
 
588
        case OB_DIRECTION_EAST:
 
589
            x = a->x;
 
590
            break;
 
591
        case OB_DIRECTION_SOUTH:
 
592
            y = a->y;
 
593
            break;
 
594
        case OB_DIRECTION_WEST:
 
595
            x = a->width - 1;
 
596
            break;
 
597
        default:
 
598
        g_assert_not_reached();
 
599
    }
 
600
 
 
601
    XWarpPointer(obt_display, 0, obt_root(ob_screen), 0, 0, 0, 0, x, y);
 
602
}
 
603
 
530
604
static gboolean edge_warp_delay_func(gpointer data)
531
605
{
532
606
    guint d;
535
609
       after that */
536
610
    if (edge_warp_odd) {
537
611
        d = screen_find_desktop(screen_desktop, edge_warp_dir, TRUE, FALSE);
538
 
        if (d != screen_desktop) screen_set_desktop(d, TRUE);
 
612
        if (d != screen_desktop) {
 
613
            if (config_mouse_screenedgewarp) edge_warp_move_ptr();
 
614
            screen_set_desktop(d, TRUE);
 
615
        }
539
616
    }
540
617
    edge_warp_odd = !edge_warp_odd;
541
618
 
552
629
    dir = -1;
553
630
 
554
631
    for (i = 0; i < screen_num_monitors; ++i) {
555
 
        Rect *a = screen_physical_area_monitor(i);
 
632
        const Rect *a = screen_physical_area_monitor(i);
556
633
        if (x == RECT_LEFT(*a)) dir = OB_DIRECTION_WEST;
557
634
        if (x == RECT_RIGHT(*a)) dir = OB_DIRECTION_EAST;
558
635
        if (y == RECT_TOP(*a)) dir = OB_DIRECTION_NORTH;
569
646
        {
570
647
            dir = -1;
571
648
        }
572
 
        g_free(a);
573
649
    }
574
650
 
575
651
    if (dir != edge_warp_dir) {
576
652
        cancel_edge_warp();
577
653
        if (dir != (ObDirection)-1) {
578
654
            edge_warp_odd = TRUE; /* switch on the first timeout */
579
 
            ob_main_loop_timeout_add(ob_main_loop,
580
 
                                     config_mouse_screenedgetime * 1000,
581
 
                                     edge_warp_delay_func,
582
 
                                     NULL, NULL, NULL);
 
655
            edge_warp_timer = g_timeout_add(config_mouse_screenedgetime,
 
656
                                            edge_warp_delay_func, NULL);
583
657
        }
584
658
        edge_warp_dir = dir;
585
659
    }
587
661
 
588
662
static void cancel_edge_warp(void)
589
663
{
590
 
    ob_main_loop_timeout_remove(ob_main_loop, edge_warp_delay_func);
 
664
    if (edge_warp_timer) g_source_remove(edge_warp_timer);
 
665
    edge_warp_timer = 0;
591
666
}
592
667
 
593
 
static void move_with_keys(gint keycode, gint state)
 
668
static void move_with_keys(KeySym sym, guint state)
594
669
{
595
670
    gint dx = 0, dy = 0, ox = cur_x, oy = cur_y;
596
671
    gint opx, px, opy, py;
597
672
    gint dist = 0;
598
673
 
599
674
    /* shift means jump to edge */
600
 
    if (state & modkeys_key_to_mask(OB_MODKEY_KEY_SHIFT)) {
 
675
    if (state & obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_SHIFT))
 
676
    {
601
677
        gint x, y;
602
678
        ObDirection dir;
603
679
 
604
 
        if (ob_keycode_match(keycode, OB_KEY_RIGHT))
 
680
        if (sym == XK_Right)
605
681
            dir = OB_DIRECTION_EAST;
606
 
        else if (ob_keycode_match(keycode, OB_KEY_LEFT))
 
682
        else if (sym == XK_Left)
607
683
            dir = OB_DIRECTION_WEST;
608
 
        else if (ob_keycode_match(keycode, OB_KEY_DOWN))
 
684
        else if (sym == XK_Down)
609
685
            dir = OB_DIRECTION_SOUTH;
610
 
        else /* if (ob_keycode_match(keycode, OB_KEY_UP)) */
 
686
        else /* sym == XK_Up */
611
687
            dir = OB_DIRECTION_NORTH;
612
688
 
613
689
        client_find_move_directional(moveresize_client, dir, &x, &y);
615
691
        dy = y - moveresize_client->area.y;
616
692
    } else {
617
693
        /* control means fine grained */
618
 
        if (state & modkeys_key_to_mask(OB_MODKEY_KEY_CONTROL))
 
694
        if (state &
 
695
            obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_CONTROL))
 
696
        {
619
697
            dist = 1;
 
698
        }
620
699
        else
621
700
            dist = KEY_DIST;
622
701
 
623
 
        if (ob_keycode_match(keycode, OB_KEY_RIGHT))
 
702
        if (sym == XK_Right)
624
703
            dx = dist;
625
 
        else if (ob_keycode_match(keycode, OB_KEY_LEFT))
 
704
        else if (sym == XK_Left)
626
705
            dx = -dist;
627
 
        else if (ob_keycode_match(keycode, OB_KEY_DOWN))
 
706
        else if (sym == XK_Down)
628
707
            dy = dist;
629
 
        else /* if (ob_keycode_match(keycode, OB_KEY_UP)) */
 
708
        else /* if (sym == XK_Up) */
630
709
            dy = -dist;
631
710
    }
632
711
 
633
712
    screen_pointer_pos(&opx, &opy);
634
 
    XWarpPointer(ob_display, None, None, 0, 0, 0, 0, dx, dy);
 
713
    XWarpPointer(obt_display, None, None, 0, 0, 0, 0, dx, dy);
635
714
    /* steal the motion events this causes */
636
 
    XSync(ob_display, FALSE);
 
715
    XSync(obt_display, FALSE);
637
716
    {
638
717
        XEvent ce;
639
 
        while (XCheckTypedEvent(ob_display, MotionNotify, &ce));
 
718
        while (xqueue_remove_local(&ce, xqueue_match_type,
 
719
                                   GINT_TO_POINTER(MotionNotify)));
640
720
    }
641
721
    screen_pointer_pos(&px, &py);
642
722
 
652
732
    start_y += (py - opy) - (cur_y - oy);
653
733
}
654
734
 
655
 
static void resize_with_keys(gint keycode, gint state)
 
735
static void resize_with_keys(KeySym sym, guint state)
656
736
{
657
737
    gint dw = 0, dh = 0, pdx = 0, pdy = 0, opx, opy, px, py;
658
738
    gint resist = 0;
659
739
    ObDirection dir;
660
740
 
661
741
    /* pick the edge if it needs to move */
662
 
    if (ob_keycode_match(keycode, OB_KEY_RIGHT)) {
 
742
    if (sym == XK_Right) {
663
743
        dir = OB_DIRECTION_EAST;
664
744
        if (key_resize_edge != OB_DIRECTION_WEST &&
665
745
            key_resize_edge != OB_DIRECTION_EAST)
667
747
            key_resize_edge = OB_DIRECTION_EAST;
668
748
            return;
669
749
        }
670
 
    }
671
 
    if (ob_keycode_match(keycode, OB_KEY_LEFT)) {
 
750
    } else if (sym == XK_Left) {
672
751
        dir = OB_DIRECTION_WEST;
673
752
        if (key_resize_edge != OB_DIRECTION_WEST &&
674
753
            key_resize_edge != OB_DIRECTION_EAST)
676
755
            key_resize_edge = OB_DIRECTION_WEST;
677
756
            return;
678
757
        }
679
 
    }
680
 
    if (ob_keycode_match(keycode, OB_KEY_UP)) {
 
758
    } else if (sym == XK_Up) {
681
759
        dir = OB_DIRECTION_NORTH;
682
760
        if (key_resize_edge != OB_DIRECTION_NORTH &&
683
761
            key_resize_edge != OB_DIRECTION_SOUTH)
685
763
            key_resize_edge = OB_DIRECTION_NORTH;
686
764
            return;
687
765
        }
688
 
    }
689
 
    if (ob_keycode_match(keycode, OB_KEY_DOWN)) {
 
766
    } else /* if (sym == XK_Down) */ {
690
767
        dir = OB_DIRECTION_SOUTH;
691
768
        if (key_resize_edge != OB_DIRECTION_NORTH &&
692
769
            key_resize_edge != OB_DIRECTION_SOUTH)
697
774
    }
698
775
 
699
776
    /* shift means jump to edge */
700
 
    if (state & modkeys_key_to_mask(OB_MODKEY_KEY_SHIFT)) {
 
777
    if (state & obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_SHIFT))
 
778
    {
701
779
        gint x, y, w, h;
702
780
 
703
 
        if (ob_keycode_match(keycode, OB_KEY_RIGHT))
 
781
        if (sym == XK_Right)
704
782
            dir = OB_DIRECTION_EAST;
705
 
        else if (ob_keycode_match(keycode, OB_KEY_LEFT))
 
783
        else if (sym == XK_Left)
706
784
            dir = OB_DIRECTION_WEST;
707
 
        else if (ob_keycode_match(keycode, OB_KEY_DOWN))
 
785
        else if (sym == XK_Down)
708
786
            dir = OB_DIRECTION_SOUTH;
709
 
        else /* if (ob_keycode_match(keycode, OB_KEY_UP)) */
 
787
        else /* if (sym == XK_Up)) */
710
788
            dir = OB_DIRECTION_NORTH;
711
789
 
712
790
        client_find_resize_directional(moveresize_client, key_resize_edge,
722
800
            distw = moveresize_client->size_inc.width;
723
801
            resist = 1;
724
802
        }
725
 
        else if (state & modkeys_key_to_mask(OB_MODKEY_KEY_CONTROL)) {
 
803
        else if (state &
 
804
                 obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_CONTROL))
 
805
        {
726
806
            distw = 1;
727
807
            resist = 1;
728
808
        }
734
814
            disth = moveresize_client->size_inc.height;
735
815
            resist = 1;
736
816
        }
737
 
        else if (state & modkeys_key_to_mask(OB_MODKEY_KEY_CONTROL)) {
 
817
        else if (state &
 
818
                 obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_CONTROL))
 
819
        {
738
820
            disth = 1;
739
821
            resist = 1;
740
822
        }
769
851
        }
770
852
    }
771
853
 
 
854
    if (moveresize_client->max_horz &&
 
855
        (key_resize_edge == OB_DIRECTION_WEST ||
 
856
         key_resize_edge == OB_DIRECTION_EAST))
 
857
    {
 
858
        /* unmax horz */
 
859
        was_max_horz = TRUE;
 
860
        pre_max_area.x = moveresize_client->pre_max_area.x;
 
861
        pre_max_area.width = moveresize_client->pre_max_area.width;
 
862
 
 
863
        moveresize_client->pre_max_area.x = cur_x;
 
864
        moveresize_client->pre_max_area.width = cur_w;
 
865
        client_maximize(moveresize_client, FALSE, 1);
 
866
    }
 
867
    else if (moveresize_client->max_vert &&
 
868
             (key_resize_edge == OB_DIRECTION_NORTH ||
 
869
              key_resize_edge == OB_DIRECTION_SOUTH))
 
870
    {
 
871
        /* unmax vert */
 
872
        was_max_vert = TRUE;
 
873
        pre_max_area.y = moveresize_client->pre_max_area.y;
 
874
        pre_max_area.height = moveresize_client->pre_max_area.height;
 
875
 
 
876
        moveresize_client->pre_max_area.y = cur_y;
 
877
        moveresize_client->pre_max_area.height = cur_h;
 
878
        client_maximize(moveresize_client, FALSE, 2);
 
879
    }
 
880
 
772
881
    calc_resize(TRUE, resist, &dw, &dh, dir);
773
882
    if (key_resize_edge == OB_DIRECTION_WEST)
774
883
        cur_x -= dw;
788
897
        pdy = dh;
789
898
 
790
899
    screen_pointer_pos(&opx, &opy);
791
 
    XWarpPointer(ob_display, None, None, 0, 0, 0, 0, pdx, pdy);
 
900
    XWarpPointer(obt_display, None, None, 0, 0, 0, 0, pdx, pdy);
792
901
    /* steal the motion events this causes */
793
 
    XSync(ob_display, FALSE);
 
902
    XSync(obt_display, FALSE);
794
903
    {
795
904
        XEvent ce;
796
 
        while (XCheckTypedEvent(ob_display, MotionNotify, &ce));
 
905
        while (xqueue_remove_local(&ce, xqueue_match_type,
 
906
                                   GINT_TO_POINTER(MotionNotify)));
797
907
    }
798
908
    screen_pointer_pos(&px, &py);
799
909
 
836
946
            gint dw, dh;
837
947
            ObDirection dir;
838
948
 
839
 
            if (corner == prop_atoms.net_wm_moveresize_size_topleft) {
 
949
            if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPLEFT)) {
840
950
                dw = -(e->xmotion.x_root - start_x);
841
951
                dh = -(e->xmotion.y_root - start_y);
842
952
                dir = OB_DIRECTION_NORTHWEST;
843
 
            } else if (corner == prop_atoms.net_wm_moveresize_size_top) {
 
953
            } else if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOP)) {
844
954
                dw = 0;
845
955
                dh = -(e->xmotion.y_root - start_y);
846
956
                dir = OB_DIRECTION_NORTH;
847
 
            } else if (corner == prop_atoms.net_wm_moveresize_size_topright) {
 
957
            } else if (corner ==
 
958
                       OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPRIGHT)) {
848
959
                dw = (e->xmotion.x_root - start_x);
849
960
                dh = -(e->xmotion.y_root - start_y);
850
961
                dir = OB_DIRECTION_NORTHEAST;
851
 
            } else if (corner == prop_atoms.net_wm_moveresize_size_right) {
 
962
            } else if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_RIGHT)) {
852
963
                dw = (e->xmotion.x_root - start_x);
853
964
                dh = 0;
854
965
                dir = OB_DIRECTION_EAST;
855
966
            } else if (corner ==
856
 
                       prop_atoms.net_wm_moveresize_size_bottomright) {
 
967
                       OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT)) {
857
968
                dw = (e->xmotion.x_root - start_x);
858
969
                dh = (e->xmotion.y_root - start_y);
859
970
                dir = OB_DIRECTION_SOUTHEAST;
860
 
            } else if (corner == prop_atoms.net_wm_moveresize_size_bottom) {
 
971
            } else if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOM))
 
972
            {
861
973
                dw = 0;
862
974
                dh = (e->xmotion.y_root - start_y);
863
975
                dir = OB_DIRECTION_SOUTH;
864
976
            } else if (corner ==
865
 
                       prop_atoms.net_wm_moveresize_size_bottomleft) {
 
977
                       OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT)) {
866
978
                dw = -(e->xmotion.x_root - start_x);
867
979
                dh = (e->xmotion.y_root - start_y);
868
980
                dir = OB_DIRECTION_SOUTHWEST;
869
 
            } else if (corner == prop_atoms.net_wm_moveresize_size_left) {
 
981
            } else if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_LEFT)) {
870
982
                dw = -(e->xmotion.x_root - start_x);
871
983
                dh = 0;
872
984
                dir = OB_DIRECTION_WEST;
873
 
            } else if (corner == prop_atoms.net_wm_moveresize_size_keyboard) {
 
985
            } else if (corner ==
 
986
                       OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_KEYBOARD)) {
874
987
                dw = (e->xmotion.x_root - start_x);
875
988
                dh = (e->xmotion.y_root - start_y);
876
989
                dir = OB_DIRECTION_SOUTHEAST;
877
990
            } else
878
991
                g_assert_not_reached();
879
992
 
 
993
            /* override the client's max state if desired */
 
994
            if (ABS(dw) >= config_resist_edge) {
 
995
                if (moveresize_client->max_horz) {
 
996
                    /* unmax horz */
 
997
                    was_max_horz = TRUE;
 
998
                    pre_max_area.x = moveresize_client->pre_max_area.x;
 
999
                    pre_max_area.width = moveresize_client->pre_max_area.width;
 
1000
 
 
1001
                    moveresize_client->pre_max_area.x = cur_x;
 
1002
                    moveresize_client->pre_max_area.width = cur_w;
 
1003
                    client_maximize(moveresize_client, FALSE, 1);
 
1004
                }
 
1005
            }
 
1006
            else if (was_max_horz && !moveresize_client->max_horz) {
 
1007
                /* remax horz and put the premax back */
 
1008
                client_maximize(moveresize_client, TRUE, 1);
 
1009
                moveresize_client->pre_max_area.x = pre_max_area.x;
 
1010
                moveresize_client->pre_max_area.width = pre_max_area.width;
 
1011
            }
 
1012
 
 
1013
            if (ABS(dh) >= config_resist_edge) {
 
1014
                if (moveresize_client->max_vert) {
 
1015
                    /* unmax vert */
 
1016
                    was_max_vert = TRUE;
 
1017
                    pre_max_area.y = moveresize_client->pre_max_area.y;
 
1018
                    pre_max_area.height =
 
1019
                        moveresize_client->pre_max_area.height;
 
1020
 
 
1021
                    moveresize_client->pre_max_area.y = cur_y;
 
1022
                    moveresize_client->pre_max_area.height = cur_h;
 
1023
                    client_maximize(moveresize_client, FALSE, 2);
 
1024
                }
 
1025
            }
 
1026
            else if (was_max_vert && !moveresize_client->max_vert) {
 
1027
                /* remax vert and put the premax back */
 
1028
                client_maximize(moveresize_client, TRUE, 2);
 
1029
                moveresize_client->pre_max_area.y = pre_max_area.y;
 
1030
                moveresize_client->pre_max_area.height = pre_max_area.height;
 
1031
            }
 
1032
 
880
1033
            dw -= cur_w - start_cw;
881
1034
            dh -= cur_h - start_ch;
882
1035
 
884
1037
            cur_w += dw;
885
1038
            cur_h += dh;
886
1039
 
887
 
            if (corner == prop_atoms.net_wm_moveresize_size_topleft ||
888
 
                corner == prop_atoms.net_wm_moveresize_size_left ||
889
 
                corner == prop_atoms.net_wm_moveresize_size_bottomleft)
 
1040
            if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPLEFT) ||
 
1041
                corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_LEFT) ||
 
1042
                corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT))
890
1043
            {
891
1044
                cur_x -= dw;
892
1045
            }
893
 
            if (corner == prop_atoms.net_wm_moveresize_size_topleft ||
894
 
                corner == prop_atoms.net_wm_moveresize_size_top ||
895
 
                corner == prop_atoms.net_wm_moveresize_size_topright)
 
1046
            if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPLEFT) ||
 
1047
                corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOP) ||
 
1048
                corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPRIGHT))
896
1049
            {
897
1050
                cur_y -= dh;
898
1051
            }
901
1054
        }
902
1055
        used = TRUE;
903
1056
    } else if (e->type == KeyPress) {
904
 
        if (ob_keycode_match(e->xkey.keycode, OB_KEY_ESCAPE)) {
 
1057
        KeySym sym = obt_keyboard_keypress_to_keysym(e);
 
1058
 
 
1059
        if (sym == XK_Escape) {
905
1060
            moveresize_end(TRUE);
906
1061
            used = TRUE;
907
 
        } else if (ob_keycode_match(e->xkey.keycode, OB_KEY_RETURN)) {
 
1062
        } else if (sym == XK_Return || sym == XK_KP_Enter) {
908
1063
            moveresize_end(FALSE);
909
1064
            used = TRUE;
910
 
        } else if (ob_keycode_match(e->xkey.keycode, OB_KEY_RIGHT) ||
911
 
                   ob_keycode_match(e->xkey.keycode, OB_KEY_LEFT) ||
912
 
                   ob_keycode_match(e->xkey.keycode, OB_KEY_DOWN) ||
913
 
                   ob_keycode_match(e->xkey.keycode, OB_KEY_UP))
 
1065
        } else if (sym == XK_Right || sym == XK_Left ||
 
1066
                   sym == XK_Up || sym == XK_Down)
914
1067
        {
915
 
            if (corner == prop_atoms.net_wm_moveresize_size_keyboard) {
916
 
                resize_with_keys(e->xkey.keycode, e->xkey.state);
 
1068
            if (corner == OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_KEYBOARD)) {
 
1069
                resize_with_keys(sym, e->xkey.state);
917
1070
                used = TRUE;
918
 
            } else if (corner == prop_atoms.net_wm_moveresize_move_keyboard) {
919
 
                move_with_keys(e->xkey.keycode, e->xkey.state);
 
1071
            } else if (corner ==
 
1072
                       OBT_PROP_ATOM(NET_WM_MOVERESIZE_MOVE_KEYBOARD))
 
1073
            {
 
1074
                move_with_keys(sym, e->xkey.state);
920
1075
                used = TRUE;
921
1076
            }
922
1077
        }
923
1078
    }
924
1079
#ifdef SYNC
925
 
    else if (e->type == extensions_sync_event_basep + XSyncAlarmNotify)
 
1080
    else if (e->type == obt_display_extension_sync_basep + XSyncAlarmNotify)
926
1081
    {
927
 
        waiting_for_sync = FALSE; /* we got our sync... */
 
1082
        waiting_for_sync = 0; /* we got our sync... */
928
1083
        do_resize(); /* ...so try resize if there is more change pending */
929
1084
        used = TRUE;
930
1085
    }
931
1086
#endif
 
1087
 
 
1088
    if (used && moveresize_client == focus_client)
 
1089
        event_update_user_time();
 
1090
 
932
1091
    return used;
933
1092
}