diff options
author | Chris Michael <devilhorns@comcast.net> | 2013-03-24 20:24:55 +0000 |
---|---|---|
committer | Chris Michael <devilhorns@comcast.net> | 2013-03-24 20:24:55 +0000 |
commit | 23fa6fabd1e4b7971edef2a954d0db3add92288d (patch) | |
tree | 57f621d871398a54eaf5478d5a776793680ec902 | |
parent | d4710b731e54679cd46385fefc3ee325f3e7b24d (diff) | |
download | enlightenment-23fa6fabd1e4b7971edef2a954d0db3add92288d.tar.gz |
Reduce duplicated code
Since we try to get the current timestamp in several places, lets make
a singular function for it and reduce duplicated code.
Signed-off-by: Chris Michael <devilhorns@comcast.net>
-rw-r--r-- | src/bin/e_comp_wl.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c index d8b7f541cf..d9c362b332 100644 --- a/src/bin/e_comp_wl.c +++ b/src/bin/e_comp_wl.c @@ -14,6 +14,7 @@ #endif /* local function prototypes */ +static inline unsigned int _e_comp_wl_time_get(void); static void _e_comp_wl_repick(void); static void _e_comp_wl_cb_bind(struct wl_client *client, void *data EINA_UNUSED, unsigned int version EINA_UNUSED, unsigned int id); static Eina_Bool _e_comp_wl_cb_fd_handle(void *data EINA_UNUSED, Ecore_Fd_Handler *hdl); @@ -264,6 +265,15 @@ e_comp_wl_shutdown(void) } /* local functions */ +static inline unsigned int +_e_comp_wl_time_get(void) +{ + struct timeval tm; + + gettimeofday(&tm, NULL); + return (tm.tv_sec * 1000 + tm.tv_usec / 1000); +} + static void _e_comp_wl_repick(void) { @@ -1126,15 +1136,13 @@ _e_comp_wl_surface_cb_draw_done(void *data, Evas *evas EINA_UNUSED, void *event { E_Wayland_Surface *ews = NULL; E_Wayland_Frame_Cb *cb = NULL, *ncb; - struct timeval tm; unsigned int secs = 0; LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!(ews = data)) return; - gettimeofday(&tm, NULL); - secs = (tm.tv_sec * 1000 + tm.tv_usec / 1000); + secs = _e_comp_wl_time_get(); /* NB: Hmmm, do we need an event_loop_dispatch here ?? */ @@ -1544,7 +1552,6 @@ _e_comp_wl_cb_mouse_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *eve struct wl_pointer *ptr; unsigned int serial = 0; int btn = 0; - struct timeval tm; unsigned int timestamp = 0; LOGFN(__FILE__, __LINE__, __FUNCTION__); @@ -1568,8 +1575,7 @@ _e_comp_wl_cb_mouse_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *eve else if (ev->buttons == 3) btn = BTN_RIGHT; - gettimeofday(&tm, NULL); - timestamp = (tm.tv_sec * 1000 + tm.tv_usec / 1000); + timestamp = _e_comp_wl_time_get(); if ((_e_wl_comp->ping_cb) && (focus)) _e_wl_comp->ping_cb(focus, serial); @@ -1599,7 +1605,6 @@ _e_comp_wl_cb_mouse_up(void *data EINA_UNUSED, int type EINA_UNUSED, void *event Ecore_Event_Mouse_Button *ev; struct wl_pointer *ptr; int btn = 0; - struct timeval tm; unsigned int timestamp = 0; LOGFN(__FILE__, __LINE__, __FUNCTION__); @@ -1622,8 +1627,7 @@ _e_comp_wl_cb_mouse_up(void *data EINA_UNUSED, int type EINA_UNUSED, void *event ptr->button_count--; - gettimeofday(&tm, NULL); - timestamp = (tm.tv_sec * 1000 + tm.tv_usec / 1000); + timestamp = _e_comp_wl_time_get(); ptr->grab->interface->button(ptr->grab, timestamp, btn, WL_POINTER_BUTTON_STATE_RELEASED); @@ -1640,7 +1644,6 @@ _e_comp_wl_cb_mouse_move(void *data EINA_UNUSED, int type EINA_UNUSED, void *eve const struct wl_pointer_grab_interface *grab; Ecore_Event_Mouse_Move *ev; struct wl_pointer *ptr; - struct timeval tm; unsigned int timestamp = 0; ev = event; @@ -1659,8 +1662,7 @@ _e_comp_wl_cb_mouse_move(void *data EINA_UNUSED, int type EINA_UNUSED, void *eve _e_comp_wl_input_repick(_e_wl_comp->input); - gettimeofday(&tm, NULL); - timestamp = (tm.tv_sec * 1000 + tm.tv_usec / 1000); + timestamp = _e_comp_wl_time_get(); grab = ptr->grab->interface; grab->motion(ptr->grab, timestamp, ptr->grab->x, ptr->grab->y); @@ -1676,7 +1678,6 @@ _e_comp_wl_cb_key_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *event struct wl_keyboard_grab *grab; E_Wayland_Surface *focus = NULL; unsigned int serial = 0, timestamp = 0, key = 0; - struct timeval tm; unsigned int *end, *k; ev = event; @@ -1696,8 +1697,7 @@ _e_comp_wl_cb_key_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *event if ((_e_wl_comp->ping_cb) && (focus)) _e_wl_comp->ping_cb(focus, serial); - gettimeofday(&tm, NULL); - timestamp = (tm.tv_sec * 1000 + tm.tv_usec / 1000); + timestamp = _e_comp_wl_time_get(); key = ecore_x_keysym_keycode_get(ev->key) - 8; @@ -1739,7 +1739,6 @@ _e_comp_wl_cb_key_up(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) struct wl_keyboard *kbd; struct wl_keyboard_grab *grab; unsigned int timestamp = 0, key = 0; - struct timeval tm; unsigned int *end, *k; ev = event; @@ -1753,8 +1752,7 @@ _e_comp_wl_cb_key_up(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) kbd = _e_wl_comp->input->wl.seat.keyboard; if (!kbd) return ECORE_CALLBACK_PASS_ON; - gettimeofday(&tm, NULL); - timestamp = (tm.tv_sec * 1000 + tm.tv_usec / 1000); + timestamp = _e_comp_wl_time_get(); key = ecore_x_keysym_keycode_get(ev->key) - 8; |