diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ui/touch.c | 13 | ||||
-rw-r--r-- | src/ui/window.c | 28 | ||||
-rw-r--r-- | src/ui/window.h | 1 |
3 files changed, 27 insertions, 15 deletions
diff --git a/src/ui/touch.c b/src/ui/touch.c index 416819a0..968e3011 100644 --- a/src/ui/touch.c +++ b/src/ui/touch.c | |||
@@ -134,6 +134,7 @@ static void dispatchMotion_Touch_(iFloat3 pos, int buttonState) { | |||
134 | 134 | ||
135 | static iBool dispatchClick_Touch_(const iTouch *d, int button) { | 135 | static iBool dispatchClick_Touch_(const iTouch *d, int button) { |
136 | const iFloat3 tapPos = d->pos[0]; | 136 | const iFloat3 tapPos = d->pos[0]; |
137 | iWindow *window = get_Window(); | ||
137 | SDL_MouseButtonEvent btn = { | 138 | SDL_MouseButtonEvent btn = { |
138 | .type = SDL_MOUSEBUTTONDOWN, | 139 | .type = SDL_MOUSEBUTTONDOWN, |
139 | .button = button, | 140 | .button = button, |
@@ -144,14 +145,16 @@ static iBool dispatchClick_Touch_(const iTouch *d, int button) { | |||
144 | .x = x_F3(tapPos), | 145 | .x = x_F3(tapPos), |
145 | .y = y_F3(tapPos) | 146 | .y = y_F3(tapPos) |
146 | }; | 147 | }; |
147 | iBool wasUsed = dispatchEvent_Widget(get_Window()->root, (SDL_Event *) &btn); | 148 | iBool wasUsed = dispatchEvent_Widget(window->root, (SDL_Event *) &btn); |
148 | /* Immediately released, too. */ | 149 | /* Immediately released, too. */ |
149 | btn.type = SDL_MOUSEBUTTONUP; | 150 | btn.type = SDL_MOUSEBUTTONUP; |
150 | btn.state = SDL_RELEASED; | 151 | btn.state = SDL_RELEASED; |
151 | btn.timestamp = SDL_GetTicks(); | 152 | btn.timestamp = SDL_GetTicks(); |
152 | dispatchEvent_Widget(get_Window()->root, (SDL_Event *) &btn); | 153 | dispatchEvent_Widget(window->root, (SDL_Event *) &btn); |
153 | //dispatchMotion_Touch_(zero_F3(), 0); | ||
154 | setHover_Widget(NULL); /* FIXME: this doesn't seem to do anything? */ | 154 | setHover_Widget(NULL); /* FIXME: this doesn't seem to do anything? */ |
155 | if (!wasUsed && button == SDL_BUTTON_RIGHT) { | ||
156 | postContextClick_Window(window, &btn); | ||
157 | } | ||
155 | return wasUsed; | 158 | return wasUsed; |
156 | } | 159 | } |
157 | 160 | ||
@@ -181,7 +184,8 @@ static void update_TouchState_(void *ptr) { | |||
181 | /* Looks like a possible tap. */ | 184 | /* Looks like a possible tap. */ |
182 | dispatchMotion_Touch_(touch->pos[0], 0); | 185 | dispatchMotion_Touch_(touch->pos[0], 0); |
183 | } | 186 | } |
184 | if (!touch->isTapAndHold && nowTime - touch->startTime >= longPressSpanMs_ && | 187 | if (~flags_Widget(touch->affinity) & touchDrag_WidgetFlag && |
188 | !touch->isTapAndHold && nowTime - touch->startTime >= longPressSpanMs_ && | ||
185 | touch->affinity) { | 189 | touch->affinity) { |
186 | dispatchClick_Touch_(touch, SDL_BUTTON_RIGHT); | 190 | dispatchClick_Touch_(touch, SDL_BUTTON_RIGHT); |
187 | touch->isTapAndHold = iTrue; | 191 | touch->isTapAndHold = iTrue; |
@@ -381,6 +385,7 @@ iBool processEvent_Touch(const SDL_Event *ev) { | |||
381 | touch->isTouchDrag = iTrue; | 385 | touch->isTouchDrag = iTrue; |
382 | touch->edge = none_TouchEdge; | 386 | touch->edge = none_TouchEdge; |
383 | pushPos_Touch_(touch, pos, fing->timestamp); | 387 | pushPos_Touch_(touch, pos, fing->timestamp); |
388 | dispatchMotion_Touch_(touch->startPos, 0); | ||
384 | dispatchEvent_Widget(window->root, (SDL_Event *) &(SDL_MouseButtonEvent){ | 389 | dispatchEvent_Widget(window->root, (SDL_Event *) &(SDL_MouseButtonEvent){ |
385 | .type = SDL_MOUSEBUTTONDOWN, | 390 | .type = SDL_MOUSEBUTTONDOWN, |
386 | .timestamp = fing->timestamp, | 391 | .timestamp = fing->timestamp, |
diff --git a/src/ui/window.c b/src/ui/window.c index dc056887..d896ac21 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -1159,7 +1159,7 @@ static void setupUserInterface_Window(iWindow *d) { | |||
1159 | (iMenuItem[]) { | 1159 | (iMenuItem[]) { |
1160 | { leftHalf_Icon " Toggle Left Sidebar", 0, 0, "sidebar.toggle" }, | 1160 | { leftHalf_Icon " Toggle Left Sidebar", 0, 0, "sidebar.toggle" }, |
1161 | { rightHalf_Icon " Toggle Right Sidebar", 0, 0, "sidebar2.toggle" }, | 1161 | { rightHalf_Icon " Toggle Right Sidebar", 0, 0, "sidebar2.toggle" }, |
1162 | }, 2); | 1162 | }, deviceType_App() == phone_AppDeviceType ? 1 : 2); |
1163 | iWidget *clipMenu = makeMenu_Widget(d->root, | 1163 | iWidget *clipMenu = makeMenu_Widget(d->root, |
1164 | (iMenuItem[]){ | 1164 | (iMenuItem[]){ |
1165 | { scissor_Icon " Cut", 0, 0, "input.copy cut:1" }, | 1165 | { scissor_Icon " Cut", 0, 0, "input.copy cut:1" }, |
@@ -1765,16 +1765,7 @@ iBool processEvent_Window(iWindow *d, const SDL_Event *ev) { | |||
1765 | wasUsed = dispatchEvent_Widget(widget, &paste); | 1765 | wasUsed = dispatchEvent_Widget(widget, &paste); |
1766 | } | 1766 | } |
1767 | if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_RIGHT) { | 1767 | if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_RIGHT) { |
1768 | /* A context menu may still get triggered here. */ | 1768 | postContextClick_Window(d, &event.button); |
1769 | const iWidget *hit = hitChild_Widget(d->root, init_I2(event.button.x, event.button.y)); | ||
1770 | while (hit && isEmpty_String(id_Widget(hit))) { | ||
1771 | hit = parent_Widget(hit); | ||
1772 | } | ||
1773 | if (hit) { | ||
1774 | postCommandf_App("contextclick id:%s ptr:%p coord:%d %d", | ||
1775 | cstr_String(id_Widget(hit)), hit, | ||
1776 | event.button.x, event.button.y); | ||
1777 | } | ||
1778 | } | 1769 | } |
1779 | } | 1770 | } |
1780 | if (isMetricsChange_UserEvent(&event)) { | 1771 | if (isMetricsChange_UserEvent(&event)) { |
@@ -1792,6 +1783,21 @@ iBool processEvent_Window(iWindow *d, const SDL_Event *ev) { | |||
1792 | return iFalse; | 1783 | return iFalse; |
1793 | } | 1784 | } |
1794 | 1785 | ||
1786 | iBool postContextClick_Window(iWindow *d, const SDL_MouseButtonEvent *ev) { | ||
1787 | /* A context menu may still get triggered here. */ | ||
1788 | const iWidget *hit = hitChild_Widget(d->root, init_I2(ev->x, ev->y)); | ||
1789 | while (hit && isEmpty_String(id_Widget(hit))) { | ||
1790 | hit = parent_Widget(hit); | ||
1791 | } | ||
1792 | if (hit) { | ||
1793 | postCommandf_App("contextclick id:%s ptr:%p coord:%d %d", | ||
1794 | cstr_String(id_Widget(hit)), hit, | ||
1795 | ev->x, ev->y); | ||
1796 | return iTrue; | ||
1797 | } | ||
1798 | return iFalse; | ||
1799 | } | ||
1800 | |||
1795 | void draw_Window(iWindow *d) { | 1801 | void draw_Window(iWindow *d) { |
1796 | if (d->isDrawFrozen) { | 1802 | if (d->isDrawFrozen) { |
1797 | return; | 1803 | return; |
diff --git a/src/ui/window.h b/src/ui/window.h index 2ab5d990..98c63957 100644 --- a/src/ui/window.h +++ b/src/ui/window.h | |||
@@ -90,6 +90,7 @@ void setCursor_Window (iWindow *, int cursor); | |||
90 | void setSnap_Window (iWindow *, int snapMode); | 90 | void setSnap_Window (iWindow *, int snapMode); |
91 | void setKeyboardHeight_Window(iWindow *, int height); | 91 | void setKeyboardHeight_Window(iWindow *, int height); |
92 | void dismissPortraitPhoneSidebars_Window (iWindow *); | 92 | void dismissPortraitPhoneSidebars_Window (iWindow *); |
93 | iBool postContextClick_Window (iWindow *, const SDL_MouseButtonEvent *); | ||
93 | 94 | ||
94 | uint32_t id_Window (const iWindow *); | 95 | uint32_t id_Window (const iWindow *); |
95 | iInt2 rootSize_Window (const iWindow *); | 96 | iInt2 rootSize_Window (const iWindow *); |