diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2011-12-08 21:26:56 -0500 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2011-12-08 21:26:56 -0500 |
commit | 7a66f127e6c9bd9ad16045fe62e5214745961c7e (patch) | |
tree | 3475bc6b4706fb89f6c7c74243929d28af8c637c | |
parent | 9d89b0be7d5d997790cc89f5bb68527c8ff23932 (diff) |
Add button events
-rw-r--r-- | main.c | 4 | ||||
-rw-r--r-- | window.c | 25 | ||||
-rw-r--r-- | window.h | 13 |
3 files changed, 37 insertions, 5 deletions
@@ -36,9 +36,9 @@ main () pixman_point_fixed_t p2 = { 0, 0 }; pixman_gradient_stop_t stops[3] = { - { pixman_int_to_fixed (0), { 0x2222, 0xeeee, 0xeeee, 0xeeee } }, + { pixman_int_to_fixed (0), { 0x2222, 0x2222, 0xeeee, 0xeeee } }, { pixman_double_to_fixed (0.5), { 0xdddd, 0xdddd, 0x0000, 0xdddd } }, - { pixman_int_to_fixed (1), { 0xffff, 0x1111, 0x1111, 0x1111 } } + { pixman_int_to_fixed (1), { 0xffff, 0x1111, 0x1111, 0xdddd } } }; int fd = ws_get_fd (ws); struct timeval tv; @@ -516,6 +516,23 @@ process_motion (ws_t *ws, Window xwindow, uint32_t time, int x, int y) } } +static void +process_button_event (ws_t *ws, ws_event_type_t type, const XEvent *event) +{ + window_t *window; + ws_event_t wsevent; + + if (!(window = find_window (ws, event->xbutton.window))) + return; + + wsevent.button.common.type = type; + wsevent.button.window = window; + wsevent.button.x = event->xbutton.x; + wsevent.button.y = event->xbutton.y; + + window_queue_event (window, &wsevent); +} + void ws_process (ws_t *ws) { @@ -550,8 +567,11 @@ ws_process (ws_t *ws) event.xcrossing.x, event.xcrossing.y); break; case ButtonPress: + process_button_event (ws, WS_BUTTON_DOWN, &event); + break; case ButtonRelease: - ; + process_button_event (ws, WS_BUTTON_UP, &event); + break; } } @@ -646,7 +666,8 @@ ws_create_window (ws_t *ws, list_prepend (&ws->windows, &window->link); XSelectInput (ws->display, window->xid, ExposureMask | StructureNotifyMask | - PointerMotionMask | EnterWindowMask | LeaveWindowMask ); + PointerMotionMask | EnterWindowMask | LeaveWindowMask | + ButtonPressMask | ButtonReleaseMask); pixman_region32_init (&window->repaint); list_init (&window->event_queue); @@ -25,7 +25,9 @@ typedef union ws_event_t ws_event_t; typedef enum { WS_CONFIGURE, - WS_MOTION + WS_MOTION, + WS_BUTTON_DOWN, + WS_BUTTON_UP } ws_event_type_t; typedef struct @@ -52,6 +54,15 @@ union ws_event_t int x; int y; } motion; + + struct + { + ws_event_common_t common; + window_t * window; + int button; + int x; + int y; + } button, button_up, button_down; }; /* Window system */ |