diff options
author | Harry Jeffery <harry@exec64.co.uk> | 2019-07-13 00:25:25 +0100 |
---|---|---|
committer | Harry Jeffery <harry@exec64.co.uk> | 2019-07-13 00:25:25 +0100 |
commit | 5a1571d00dd1e73f906b1c83b7abe13aa0908e9a (patch) | |
tree | 77ff8548599ee1a1acf899795e5fba5162b73dca /src/imv.c | |
parent | 96514247228548f2bf512e42fb072f965bd270f1 (diff) | |
download | imv-5a1571d00dd1e73f906b1c83b7abe13aa0908e9a.tar.gz |
Handle mouse input
Diffstat (limited to 'src/imv.c')
-rw-r--r-- | src/imv.c | 25 |
1 files changed, 6 insertions, 19 deletions
@@ -141,11 +141,6 @@ struct imv { struct imv_image *current_image; - struct { - double x; - double y; - } last_cursor_position; - /* overlay font */ struct { char *name; @@ -454,6 +449,12 @@ static void event_handler(void *data, const struct imv_event *e) case IMV_EVENT_KEYBOARD: key_handler(imv, e->data.keyboard.scancode, e->data.keyboard. pressed); break; + case IMV_EVENT_MOUSE_MOTION: + if (imv_window_get_mouse_button(imv->window, 1)) { + imv_viewport_move(imv->view, e->data.mouse_motion.dx, + e->data.mouse_motion.dy, imv->current_image); + } + break; case IMV_EVENT_CUSTOM: consume_internal_event(imv, e->data.custom); break; @@ -472,20 +473,6 @@ static void event_handler(void *data, const struct imv_event *e) /* imv->last_cursor_position.y, -y);*/ /* }*/ -/* static void cursor_callback(GLFWwindow *window, double x, double y)*/ -/* {*/ -/* struct imv *imv = glfwGetWindowUserPointer(window);*/ - -/* if (glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_1) == GLFW_PRESS) {*/ -/* const double dx = x - imv->last_cursor_position.x;*/ -/* const double dy = y - imv->last_cursor_position.y;*/ -/* imv_viewport_move(imv->view, dx, dy, imv->current_image);*/ -/* }*/ -/* imv->last_cursor_position.x = x;*/ -/* imv->last_cursor_position.y = y;*/ -/* }*/ - - static void log_to_stderr(enum imv_log_level level, const char *text, void *data) { (void)data; |