summaryrefslogtreecommitdiff
path: root/src/ui/window.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-03-13 14:00:37 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-03-13 14:00:37 +0200
commit5720b8abe62a917d52357d0ec8665a431f55c27e (patch)
tree9025a3531ddbd0e7c22713124690d9951aed438d /src/ui/window.c
parent77bda777c4dbac7bc6be07e6478aae6ba6c5fdef (diff)
Touch: Long-press context click on any widget
Diffstat (limited to 'src/ui/window.c')
-rw-r--r--src/ui/window.c28
1 files changed, 17 insertions, 11 deletions
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
1786iBool 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
1795void draw_Window(iWindow *d) { 1801void draw_Window(iWindow *d) {
1796 if (d->isDrawFrozen) { 1802 if (d->isDrawFrozen) {
1797 return; 1803 return;