diff options
-rw-r--r-- | src/ui/sidebarwidget.c | 16 | ||||
-rw-r--r-- | src/ui/window.c | 15 | ||||
-rw-r--r-- | src/ui/window.h | 1 |
3 files changed, 21 insertions, 11 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c index 73bd1646..e3d7d4a6 100644 --- a/src/ui/sidebarwidget.c +++ b/src/ui/sidebarwidget.c | |||
@@ -627,15 +627,13 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev) | |||
627 | else if (contains_Widget(constAs_Widget(d->scroll), mouse)) { | 627 | else if (contains_Widget(constAs_Widget(d->scroll), mouse)) { |
628 | setCursor_Window(get_Window(), SDL_SYSTEM_CURSOR_ARROW); | 628 | setCursor_Window(get_Window(), SDL_SYSTEM_CURSOR_ARROW); |
629 | } | 629 | } |
630 | else { | 630 | else if (contains_Widget(w, mouse)) { |
631 | if (contains_Widget(w, mouse)) { | 631 | hover = itemIndex_SidebarWidget_(d, mouse); |
632 | hover = itemIndex_SidebarWidget_(d, mouse); | 632 | if (hover != iInvalidPos && d->mode != identities_SidebarMode) { |
633 | if (hover != iInvalidPos && d->mode != identities_SidebarMode) { | 633 | setCursor_Window(get_Window(), SDL_SYSTEM_CURSOR_HAND); |
634 | setCursor_Window(get_Window(), SDL_SYSTEM_CURSOR_HAND); | 634 | } |
635 | } | 635 | else { |
636 | else { | 636 | setCursor_Window(get_Window(), SDL_SYSTEM_CURSOR_ARROW); |
637 | setCursor_Window(get_Window(), SDL_SYSTEM_CURSOR_ARROW); | ||
638 | } | ||
639 | } | 637 | } |
640 | } | 638 | } |
641 | if (hover != d->hoverItem) { | 639 | if (hover != d->hoverItem) { |
diff --git a/src/ui/window.c b/src/ui/window.c index 82109c07..ef8aea71 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -420,6 +420,7 @@ static void drawBlank_Window_(iWindow *d) { | |||
420 | void init_Window(iWindow *d, iRect rect) { | 420 | void init_Window(iWindow *d, iRect rect) { |
421 | theWindow_ = d; | 421 | theWindow_ = d; |
422 | iZap(d->cursors); | 422 | iZap(d->cursors); |
423 | d->pendingCursor = NULL; | ||
423 | d->isDrawFrozen = iTrue; | 424 | d->isDrawFrozen = iTrue; |
424 | uint32_t flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI; | 425 | uint32_t flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI; |
425 | #if defined (iPlatformApple) | 426 | #if defined (iPlatformApple) |
@@ -515,6 +516,13 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { | |||
515 | return iFalse; | 516 | return iFalse; |
516 | } | 517 | } |
517 | 518 | ||
519 | static void applyCursor_Window_(iWindow *d) { | ||
520 | if (d->pendingCursor) { | ||
521 | SDL_SetCursor(d->pendingCursor); | ||
522 | d->pendingCursor = NULL; | ||
523 | } | ||
524 | } | ||
525 | |||
518 | iBool processEvent_Window(iWindow *d, const SDL_Event *ev) { | 526 | iBool processEvent_Window(iWindow *d, const SDL_Event *ev) { |
519 | switch (ev->type) { | 527 | switch (ev->type) { |
520 | case SDL_WINDOWEVENT: { | 528 | case SDL_WINDOWEVENT: { |
@@ -552,6 +560,9 @@ iBool processEvent_Window(iWindow *d, const SDL_Event *ev) { | |||
552 | if (oldHover != hover_Widget()) { | 560 | if (oldHover != hover_Widget()) { |
553 | postRefresh_App(); | 561 | postRefresh_App(); |
554 | } | 562 | } |
563 | if (event.type == SDL_MOUSEMOTION) { | ||
564 | applyCursor_Window_(d); | ||
565 | } | ||
555 | return wasUsed; | 566 | return wasUsed; |
556 | } | 567 | } |
557 | } | 568 | } |
@@ -610,11 +621,11 @@ void setFreezeDraw_Window(iWindow *d, iBool freezeDraw) { | |||
610 | d->isDrawFrozen = freezeDraw; | 621 | d->isDrawFrozen = freezeDraw; |
611 | } | 622 | } |
612 | 623 | ||
613 | void setCursor_Window(iWindow *d, int cursor) { | 624 | void setCursor_Window(iWindow *d, int cursor) { |
614 | if (!d->cursors[cursor]) { | 625 | if (!d->cursors[cursor]) { |
615 | d->cursors[cursor] = SDL_CreateSystemCursor(cursor); | 626 | d->cursors[cursor] = SDL_CreateSystemCursor(cursor); |
616 | } | 627 | } |
617 | SDL_SetCursor(d->cursors[cursor]); | 628 | d->pendingCursor = d->cursors[cursor]; |
618 | } | 629 | } |
619 | 630 | ||
620 | iInt2 rootSize_Window(const iWindow *d) { | 631 | iInt2 rootSize_Window(const iWindow *d) { |
diff --git a/src/ui/window.h b/src/ui/window.h index e6f8cf30..4aec2fa7 100644 --- a/src/ui/window.h +++ b/src/ui/window.h | |||
@@ -42,6 +42,7 @@ struct Impl_Window { | |||
42 | uint32_t frameTime; | 42 | uint32_t frameTime; |
43 | double presentTime; | 43 | double presentTime; |
44 | SDL_Cursor * cursors[SDL_NUM_SYSTEM_CURSORS]; | 44 | SDL_Cursor * cursors[SDL_NUM_SYSTEM_CURSORS]; |
45 | SDL_Cursor * pendingCursor; | ||
45 | }; | 46 | }; |
46 | 47 | ||
47 | iBool processEvent_Window (iWindow *, const SDL_Event *); | 48 | iBool processEvent_Window (iWindow *, const SDL_Event *); |