summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ios.m14
-rw-r--r--src/ui/documentwidget.c5
-rw-r--r--src/ui/touch.c6
-rw-r--r--src/ui/touch.h1
4 files changed, 23 insertions, 3 deletions
diff --git a/src/ios.m b/src/ios.m
index 69e09419..82596ffd 100644
--- a/src/ios.m
+++ b/src/ios.m
@@ -25,6 +25,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
25#include "audio/player.h" 25#include "audio/player.h"
26#include "ui/command.h" 26#include "ui/command.h"
27#include "ui/window.h" 27#include "ui/window.h"
28#include "ui/touch.h"
28 29
29#include <the_Foundation/file.h> 30#include <the_Foundation/file.h>
30#include <the_Foundation/fileinfo.h> 31#include <the_Foundation/fileinfo.h>
@@ -541,7 +542,18 @@ static void openActivityView_(NSArray *activityItems) {
541 [[UIActivityViewController alloc] 542 [[UIActivityViewController alloc]
542 initWithActivityItems:activityItems 543 initWithActivityItems:activityItems
543 applicationActivities:nil]; 544 applicationActivities:nil];
544 [viewController_(get_Window()) presentViewController:actView animated:YES completion:nil]; 545 iWindow *win = get_Window();
546 UIViewController *viewCtl = viewController_(win);
547 UIPopoverPresentationController *popover = [actView popoverPresentationController];
548 if (popover) {
549 [popover setSourceView:[viewCtl view]];
550 iInt2 tapPos = latestTapPosition_Touch();
551 tapPos.x /= win->pixelRatio;
552 tapPos.y /= win->pixelRatio;
553 [popover setSourceRect:(CGRect){{tapPos.x - 10, tapPos.y - 10}, {20, 20}}];
554 [popover setCanOverlapSourceViewRect:YES];
555 }
556 [viewCtl presentViewController:actView animated:YES completion:nil];
545} 557}
546 558
547void openTextActivityView_iOS(const iString *text) { 559void openTextActivityView_iOS(const iString *text) {
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index e63e4636..2bce16e8 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -5267,14 +5267,15 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
5267 destroy_Widget(d->copyMenu); 5267 destroy_Widget(d->copyMenu);
5268 d->copyMenu = NULL; 5268 d->copyMenu = NULL;
5269 } 5269 }
5270 d->copyMenu = makeMenu_Widget(w, (iMenuItem[]){ 5270 const iMenuItem items[] = {
5271 { clipCopy_Icon " ${menu.copy}", 0, 0, "copy" }, 5271 { clipCopy_Icon " ${menu.copy}", 0, 0, "copy" },
5272#if defined (iPlatformAppleMobile) 5272#if defined (iPlatformAppleMobile)
5273 { export_Icon " ${menu.share}", 0, 0, "copy share:1" }, 5273 { export_Icon " ${menu.share}", 0, 0, "copy share:1" },
5274#endif 5274#endif
5275 { "---" }, 5275 { "---" },
5276 { close_Icon " ${menu.select.clear}", 0, 0, "document.select arg:0" }, 5276 { close_Icon " ${menu.select.clear}", 0, 0, "document.select arg:0" },
5277 }, 3); 5277 };
5278 d->copyMenu = makeMenu_Widget(w, items, iElemCount(items));
5278 setFlags_Widget(d->copyMenu, noFadeBackground_WidgetFlag, iTrue); 5279 setFlags_Widget(d->copyMenu, noFadeBackground_WidgetFlag, iTrue);
5279 openMenu_Widget(d->copyMenu, pos_Click(&d->click)); 5280 openMenu_Widget(d->copyMenu, pos_Click(&d->click));
5280 return iTrue; 5281 return iTrue;
diff --git a/src/ui/touch.c b/src/ui/touch.c
index 3d318dfb..20ccf7b8 100644
--- a/src/ui/touch.c
+++ b/src/ui/touch.c
@@ -111,6 +111,7 @@ struct Impl_TouchState {
111 double momFrictionPerStep; 111 double momFrictionPerStep;
112 double lastMomTime; 112 double lastMomTime;
113 iInt2 currentTouchPos; /* for emulating SDL_GetMouseState() */ 113 iInt2 currentTouchPos; /* for emulating SDL_GetMouseState() */
114 iInt2 latestLongPressStartPos;
114}; 115};
115 116
116static iTouchState *touchState_(void) { 117static iTouchState *touchState_(void) {
@@ -313,6 +314,7 @@ static void update_TouchState_(void *ptr) {
313 } 314 }
314 if (!touch->isTapAndHold && nowTime - touch->startTime >= longPressSpanMs_ && 315 if (!touch->isTapAndHold && nowTime - touch->startTime >= longPressSpanMs_ &&
315 touch->affinity) { 316 touch->affinity) {
317 touchState_()->latestLongPressStartPos = initF3_I2(touch->pos[0]);
316 dispatchClick_Touch_(touch, SDL_BUTTON_RIGHT); 318 dispatchClick_Touch_(touch, SDL_BUTTON_RIGHT);
317 touch->isTapAndHold = iTrue; 319 touch->isTapAndHold = iTrue;
318 touch->hasMoved = iFalse; 320 touch->hasMoved = iFalse;
@@ -838,6 +840,10 @@ iInt2 latestPosition_Touch(void) {
838 return touchState_()->currentTouchPos; 840 return touchState_()->currentTouchPos;
839} 841}
840 842
843iInt2 latestTapPosition_Touch(void) {
844 return touchState_()->latestLongPressStartPos;
845}
846
841iBool isHovering_Touch(void) { 847iBool isHovering_Touch(void) {
842 iTouchState *d = touchState_(); 848 iTouchState *d = touchState_();
843 if (numFingers_Touch() == 1) { 849 if (numFingers_Touch() == 1) {
diff --git a/src/ui/touch.h b/src/ui/touch.h
index 9c45fcb1..15c6da1f 100644
--- a/src/ui/touch.h
+++ b/src/ui/touch.h
@@ -42,5 +42,6 @@ void widgetDestroyed_Touch (iWidget *widget);
42void transferAffinity_Touch (iWidget *src, iWidget *dst); 42void transferAffinity_Touch (iWidget *src, iWidget *dst);
43 43
44iInt2 latestPosition_Touch (void); /* valid during processing of current event */ 44iInt2 latestPosition_Touch (void); /* valid during processing of current event */
45iInt2 latestTapPosition_Touch (void);
45iBool isHovering_Touch (void); /* stationary touch or a long-press drag ongoing */ 46iBool isHovering_Touch (void); /* stationary touch or a long-press drag ongoing */
46size_t numFingers_Touch (void); 47size_t numFingers_Touch (void);