diff --git a/caca/caca.c b/caca/caca.c index 08400c7..04b6bfa 100644 --- a/caca/caca.c +++ b/caca/caca.c @@ -79,8 +79,8 @@ caca_t * caca_attach(cucul_t * qq) kk->timer.last_usec = 0; kk->lastticks = 0; - kk->mouse_x = kk->qq->width / 2; - kk->mouse_y = kk->qq->height / 2; + kk->mouse.x = kk->qq->width / 2; + kk->mouse.y = kk->qq->height / 2; kk->resize = 0; kk->resize_event = 0; diff --git a/caca/caca_internals.h b/caca/caca_internals.h index b288b4d..f634e87 100644 --- a/caca/caca_internals.h +++ b/caca/caca_internals.h @@ -86,8 +86,10 @@ struct caca_timer /* Internal caca context */ struct caca_context { + /* A link to our cucul canvas */ cucul_t *qq; + /* Device-specific functions */ struct drv { enum caca_driver driver; @@ -103,12 +105,17 @@ struct caca_context unsigned int (* get_event) (caca_t *); } drv; - //unsigned int width, height; - unsigned int mouse_x, mouse_y; + /* Mouse position */ + struct mouse + { + unsigned int x, y; + } mouse; + /* Window resize handling */ int resize; int resize_event; + /* Framerate handling */ unsigned int delay, rendertime; struct caca_timer timer; int lastticks; diff --git a/caca/driver_gl.c b/caca/driver_gl.c index c556261..492792c 100644 --- a/caca/driver_gl.c +++ b/caca/driver_gl.c @@ -331,9 +331,9 @@ static unsigned int gl_get_event(caca_t *kk) event |= CACA_EVENT_MOUSE_PRESS | kk->drv.p->mouse_button; kk->drv.p->mouse_clicked = 0; } - kk->mouse_x = kk->drv.p->mouse_x; - kk->mouse_y = kk->drv.p->mouse_y; - event |= CACA_EVENT_MOUSE_MOTION | (kk->mouse_x << 12) | kk->mouse_y; + kk->mouse.x = kk->drv.p->mouse_x; + kk->mouse.y = kk->drv.p->mouse_y; + event |= CACA_EVENT_MOUSE_MOTION | (kk->mouse.x << 12) | kk->mouse.y; kk->drv.p->mouse_changed = 0; } diff --git a/caca/driver_ncurses.c b/caca/driver_ncurses.c index 7c83c79..727f146 100644 --- a/caca/driver_ncurses.c +++ b/caca/driver_ncurses.c @@ -360,14 +360,14 @@ static unsigned int ncurses_get_event(caca_t *kk) break; } - if(kk->mouse_x == (unsigned int)mevent.x && - kk->mouse_y == (unsigned int)mevent.y) + if(kk->mouse.x == (unsigned int)mevent.x && + kk->mouse.y == (unsigned int)mevent.y) return _pop_event(kk); - kk->mouse_x = mevent.x; - kk->mouse_y = mevent.y; + kk->mouse.x = mevent.x; + kk->mouse.y = mevent.y; - return CACA_EVENT_MOUSE_MOTION | (kk->mouse_x << 12) | kk->mouse_y; + return CACA_EVENT_MOUSE_MOTION | (kk->mouse.x << 12) | kk->mouse.y; } event = CACA_EVENT_KEY_PRESS; diff --git a/caca/driver_slang.c b/caca/driver_slang.c index 8453cc1..8380e76 100644 --- a/caca/driver_slang.c +++ b/caca/driver_slang.c @@ -287,13 +287,13 @@ static unsigned int slang_get_event(caca_t *kk) _push_event(kk, CACA_EVENT_MOUSE_PRESS | button); _push_event(kk, CACA_EVENT_MOUSE_RELEASE | button); - if(kk->mouse_x == x && kk->mouse_y == y) + if(kk->mouse.x == x && kk->mouse.y == y) return _pop_event(kk); - kk->mouse_x = x; - kk->mouse_y = y; + kk->mouse.x = x; + kk->mouse.y = y; - return CACA_EVENT_MOUSE_MOTION | (kk->mouse_x << 12) | kk->mouse_y; + return CACA_EVENT_MOUSE_MOTION | (kk->mouse.x << 12) | kk->mouse.y; } event = CACA_EVENT_KEY_PRESS; diff --git a/caca/driver_win32.c b/caca/driver_win32.c index e12599d..38ace35 100644 --- a/caca/driver_win32.c +++ b/caca/driver_win32.c @@ -261,14 +261,15 @@ static unsigned int win32_get_event(caca_t *kk) { COORD pos = rec.Event.MouseEvent.dwMousePosition; - if(kk->mouse_x == (unsigned int)pos.X && - kk->mouse_y == (unsigned int)pos.Y) + if(kk->mouse.x == (unsigned int)pos.X && + kk->mouse.y == (unsigned int)pos.Y) continue; - kk->mouse_x = pos.X; - kk->mouse_y = pos.Y; + kk->mouse.x = pos.X; + kk->mouse.y = pos.Y; - return CACA_EVENT_MOUSE_MOTION | (kk->mouse_x << 12) | kk->mouse_y; + return CACA_EVENT_MOUSE_MOTION + | (kk->mouse.x << 12) | kk->mouse.y; } #if 0 else if(rec.Event.MouseEvent.dwEventFlags == DOUBLE_CLICK) diff --git a/caca/driver_x11.c b/caca/driver_x11.c index bc46333..ed00eb8 100644 --- a/caca/driver_x11.c +++ b/caca/driver_x11.c @@ -387,13 +387,13 @@ static unsigned int x11_get_event(caca_t *kk) if(newy >= kk->qq->height) newy = kk->qq->height - 1; - if(kk->mouse_x == newx && kk->mouse_y == newy) + if(kk->mouse.x == newx && kk->mouse.y == newy) continue; - kk->mouse_x = newx; - kk->mouse_y = newy; + kk->mouse.x = newx; + kk->mouse.y = newy; - return CACA_EVENT_MOUSE_MOTION | (kk->mouse_x << 12) | kk->mouse_y; + return CACA_EVENT_MOUSE_MOTION | (kk->mouse.x << 12) | kk->mouse.y; } /* Check for mouse press and release events */ diff --git a/caca/event.c b/caca/event.c index 5fe655b..3c5afc2 100644 --- a/caca/event.c +++ b/caca/event.c @@ -103,10 +103,10 @@ unsigned int caca_wait_event(caca_t *kk, unsigned int event_mask) */ unsigned int caca_get_mouse_x(caca_t *kk) { - if(kk->mouse_x >= kk->qq->width) - kk->mouse_x = kk->qq->width - 1; + if(kk->mouse.x >= kk->qq->width) + kk->mouse.x = kk->qq->width - 1; - return kk->mouse_x; + return kk->mouse.x; } /** \brief Return the Y mouse coordinate. @@ -120,10 +120,10 @@ unsigned int caca_get_mouse_x(caca_t *kk) */ unsigned int caca_get_mouse_y(caca_t *kk) { - if(kk->mouse_y >= kk->qq->height) - kk->mouse_y = kk->qq->height - 1; + if(kk->mouse.y >= kk->qq->height) + kk->mouse.y = kk->qq->height - 1; - return kk->mouse_y; + return kk->mouse.y; } /*