=> afd4e60c6a13a417964945396ebf252a4ba9b8ae
[1mdiff --git a/src/app.c b/src/app.c[m [1mindex 50fd0db2..15c26736 100644[m [1m--- a/src/app.c[m [1m+++ b/src/app.c[m [36m@@ -140,6 +140,7 @@[m [mstruct Impl_App {[m iBool isSuspended;[m #if defined (LAGRANGE_ENABLE_IDLE_SLEEP)[m iBool isIdling;[m [32m+[m[32m unsigned int idleSleepDelayMs;[m uint32_t lastEventTime;[m int sleepTimer;[m #endif[m [36m@@ -1098,9 +1099,20 @@[m [mstatic void init_App_(iApp *d, int argc, char **argv) {[m d->autoReloadTimer = SDL_AddTimer(60 * 1000, postAutoReloadCommand_App_, NULL);[m postCommand_Root(NULL, "document.autoreload");[m #if defined (LAGRANGE_ENABLE_IDLE_SLEEP)[m [31m- d->isIdling = iFalse;[m [31m- d->lastEventTime = 0;[m [31m- d->sleepTimer = SDL_AddTimer(1000, checkAsleep_App_, d);[m [32m+[m[32m /* Initialize idle sleep. */ {[m [32m+[m[32m d->isIdling = iFalse;[m [32m+[m[32m d->lastEventTime = 0;[m [32m+[m[32m d->sleepTimer = SDL_AddTimer(1000, checkAsleep_App_, d);[m [32m+[m[32m SDL_DisplayMode dispMode;[m [32m+[m[32m SDL_GetWindowDisplayMode(d->window->base.win, &dispMode);[m [32m+[m[32m if (dispMode.refresh_rate) {[m [32m+[m[32m d->idleSleepDelayMs = 1000 / dispMode.refresh_rate;[m [32m+[m[32m }[m [32m+[m[32m else {[m [32m+[m[32m d->idleSleepDelayMs = 1000 / 60;[m [32m+[m[32m }[m [32m+[m[32m d->idleSleepDelayMs *= 0.9f;[m [32m+[m[32m }[m #endif[m d->isFinishedLaunching = iTrue;[m /* Run any commands that were pending completion of launch. */ {[m [36m@@ -1686,10 +1698,10 @@[m [mvoid processEvents_App(enum iAppEventMode eventMode) {[m deinit_PtrArray(&windows);[m #if defined (LAGRANGE_ENABLE_IDLE_SLEEP)[m if (d->isIdling && !gotEvents) {[m [31m- /* This is where we spend most of our time when idle. 30 Hz still quite a lot but we[m [31m- can't wait too long after the user tries to interact again with the app. In any[m [31m- case, on iOS SDL_WaitEvent() seems to use 10x more CPU time than sleeping (2.0.18). */[m [31m- SDL_Delay(1000 / 30);[m [32m+[m[32m /* This is where we spend most of our time when idle. The sleep delay depends on the[m [32m+[m[32m display refresh rate. iOS SDL_WaitEvent() seems to use 10x more CPU time compared to[m [32m+[m[32m just sleeping (2.0.18). */[m [32m+[m[32m SDL_Delay(d->idleSleepDelayMs);[m }[m #endif[m backToMainLoop:;[m [1mdiff --git a/src/ios.m b/src/ios.m[m [1mindex eff970ef..6c64a854 100644[m [1m--- a/src/ios.m[m [1m+++ b/src/ios.m[m [36m@@ -168,6 +168,7 @@[m [mAPI_AVAILABLE(ios(13.0))[m iString *fileBeingSaved;[m iString *pickFileCommand;[m iSystemTextInput *sysCtrl;[m [32m+[m[32m float sysCtrlLineSpacing;[m }[m @property (nonatomic, assign) BOOL isHapticsAvailable;[m @property (nonatomic, strong) NSObject *haptic;[m [36m@@ -183,23 +184,10 @@[m [mstatic UIScrollView *statusBarTapper_; /* dummy scroll view just for getting not[m fileBeingSaved = NULL;[m pickFileCommand = NULL;[m sysCtrl = NULL;[m [32m+[m[32m sysCtrlLineSpacing = 0.0f;[m return self;[m }[m [m [31m--(void)setSystemTextInput:(iSystemTextInput *)sys {[m [31m- sysCtrl = sys;[m [31m-}[m [31m-[m [31m--(iSystemTextInput *)systemTextInput {[m [31m- return sysCtrl;[m [31m-}[m [31m-[m [31m-- (CGFloat)layoutManager:(NSLayoutManager *)layoutManager[m [31m- lineSpacingAfterGlyphAtIndex:(NSUInteger)glyphIndex[m [31m- withProposedLineFragmentRect:(CGRect)rect {[m [31m- return lineHeight_Text(default_FontId) / get_MainWindow()->base.pixelRatio * 0.3f;[m [31m-}[m [31m-[m -(void)setPickFileCommand:(const char *)command {[m if (!pickFileCommand) {[m pickFileCommand = new_String();[m [36m@@ -262,6 +250,11 @@[m [mdidPickDocumentsAtURLs:(NSArray*)urls {[m }[m }[m [m [32m+[m[32m- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView {[m [32m+[m[32m postCommand_App("scroll.top smooth:1");[m [32m+[m[32m return NO;[m [32m+[m[32m}[m [32m+[m -(void)keyboardOnScreen:(NSNotification *)notification {[m NSDictionary *info = notification.userInfo;[m NSValue *value = info[UIKeyboardFrameEndUserInfoKey];[m [36m@@ -295,6 +288,24 @@[m [mstatic void sendReturnKeyPress_(void) {[m return NO;[m }[m [m [32m+[m[32m-(void)setSystemTextInput:(iSystemTextInput *)sys {[m [32m+[m[32m sysCtrl = sys;[m [32m+[m[32m}[m [32m+[m [32m+[m[32m-(void)setSystemTextLineSpacing:(float)height {[m [32m+[m[32m sysCtrlLineSpacing = height;[m [32m+[m[32m}[m [32m+[m [32m+[m[32m-(iSystemTextInput *)systemTextInput {[m [32m+[m[32m return sysCtrl;[m [32m+[m[32m}[m [32m+[m [32m+[m[32m- (CGFloat)layoutManager:(NSLayoutManager *)layoutManager[m [32m+[m[32m lineSpacingAfterGlyphAtIndex:(NSUInteger)glyphIndex[m [32m+[m[32m withProposedLineFragmentRect:(CGRect)rect {[m [32m+[m[32m return sysCtrlLineSpacing / get_MainWindow()->base.pixelRatio;[m [32m+[m[32m}[m [32m+[m - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range[m replacementString:(NSString *)string {[m iSystemTextInput *sysCtrl = [appState_ systemTextInput];[m [36m@@ -318,11 +329,6 @@[m [mreplacementString:(NSString *)string {[m notifyChange_SystemTextInput_(sysCtrl);[m }[m [m [31m-- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView {[m [31m- postCommand_App("scroll.top smooth:1");[m [31m- return NO;[m [31m-}[m [31m-[m @end[m [m /*----------------------------------------------------------------------------------------------*/[m [36m@@ -751,17 +757,17 @@[m [mstatic CGRect convertToCGRect_(const iRect *rect, iBool expanded) {[m CGRect frame;[m // TODO: Convert coordinates properly![m frame.origin.x = rect->pos.x / win->pixelRatio;[m [31m- frame.origin.y = (rect->pos.y - gap_UI + 1) / win->pixelRatio;[m [32m+[m[32m frame.origin.y = (rect->pos.y - gap_UI * 0.875f) / win->pixelRatio;[m frame.size.width = rect->size.x / win->pixelRatio;[m frame.size.height = rect->size.y / win->pixelRatio;[m /* Some padding to account for insets. If we just zero out the insets, the insertion point[m may be clipped at the edges. */[m [32m+[m[32m const float inset = gap_UI / get_Window()->pixelRatio;[m if (expanded) {[m [31m- const float inset = gap_UI / get_Window()->pixelRatio;[m [31m- frame.origin.x -= inset + 1;[m [31m- frame.origin.y -= inset / 2;[m [31m- frame.size.width += 2 * inset + 3;[m [31m- frame.size.height += inset + 1 + inset;[m [32m+[m[32m frame.origin.x -= 2 * inset;[m [32m+[m[32m frame.origin.y -= inset;[m [32m+[m[32m frame.size.width += 4 * inset;[m [32m+[m[32m frame.size.height += 2.5f * inset;[m }[m return frame;[m }[m [36m@@ -812,14 +818,16 @@[m [mvoid init_SystemTextInput(iSystemTextInput *d, iRect rect, int flags) {[m [REF_d_view setTextAlignment:NSTextAlignmentRight];[m }[m }[m [31m- UIColor *textColor = makeUIColor_(uiInputTextFocused_ColorId);[m [32m+[m[32m UIColor *textColor = makeUIColor_(uiInputTextFocused_ColorId);[m UIColor *backgroundColor = makeUIColor_(uiInputBackgroundFocused_ColorId);[m [31m- UIColor *tintColor = makeUIColor_(uiInputCursor_ColorId);[m [32m+[m[32m UIColor *tintColor = makeUIColor_(uiInputCursor_ColorId);[m [appState_ setSystemTextInput:d];[m [32m+[m[32m const float inset = gap_UI / get_Window()->pixelRatio;[m if (d->field) {[m UITextField *field = REF_d_field;[m [field setTextColor:textColor];[m [field setTintColor:tintColor];[m [32m+[m[32m// [field setBackgroundColor:[UIColor colorWithRed:1.0f green:0.0f blue:0.0f alpha:0.5f]];[m [field setDelegate:appState_];[m [field becomeFirstResponder];[m }[m [36m@@ -827,10 +835,14 @@[m [mvoid init_SystemTextInput(iSystemTextInput *d, iRect rect, int flags) {[m UITextView *view = REF_d_view;[m [[view layoutManager] setDelegate:appState_];[m [view setBackgroundColor:[UIColor colorWithWhite:1.0f alpha:0.0f]];[m [32m+[m[32m// [view setBackgroundColor:[UIColor colorWithRed:1.0f green:0.0f blue:0.0f alpha:0.5f]];[m [view setTextColor:textColor];[m [view setTintColor:tintColor];[m if (flags & extraPadding_SystemTextInputFlag) {[m [31m- [view setContentInset:(UIEdgeInsets){ 0, 0, 3 * gap_UI / get_Window()->pixelRatio, 0}];[m [32m+[m[32m [view setContentInset:(UIEdgeInsets){ -inset * 0.125f, inset * 0.875f, 3 * inset, 0}];[m [32m+[m[32m }[m [32m+[m[32m else {[m [32m+[m[32m [view setContentInset:(UIEdgeInsets){ inset / 2, inset * 0.875f, -inset / 2, inset / 2 }];[m }[m [view setEditable:YES];[m [view setDelegate:appState_];[m [36m@@ -912,9 +924,11 @@[m [mvoid setFont_SystemTextInput(iSystemTextInput *d, int fontId) {[m // printf("fontname: %s\n", [name cStringUsingEncoding:NSUTF8StringEncoding]);[m // }[m font = [UIFont fontWithName:@"Iosevka-Term-Extended" size:height * 0.82f];[m [32m+[m[32m [appState_ setSystemTextLineSpacing:0.0f];[m }[m else {[m font = [UIFont fontWithName:@"Roboto-Regular" size:height * 0.66f];[m [32m+[m[32m [appState_ setSystemTextLineSpacing:height * 0.66f];[m }[m if (d->field) {[m [REF_d_field setFont:font];[m [1mdiff --git a/src/ui/listwidget.c b/src/ui/listwidget.c[m [1mindex e2dbd5b8..7a627188 100644[m [1m--- a/src/ui/listwidget.c[m [1m+++ b/src/ui/listwidget.c[m [36m@@ -664,6 +664,7 @@[m [mstatic void draw_ListWidget_(const iListWidget *d) {[m SDL_SetRenderDrawBlendMode(renderer_Window(get_Window()), SDL_BLENDMODE_NONE);[m }[m unsetClip_Paint(&p);[m [32m+[m[32m drawBorders_Widget(w); /* background overdraws the normal borders */[m drawChildren_Widget(w);[m }[m [m [1mdiff --git a/src/ui/mobile.c b/src/ui/mobile.c[m [1mindex 1b5e6a63..dfa02422 100644[m [1m--- a/src/ui/mobile.c[m [1m+++ b/src/ui/mobile.c[m [36m@@ -749,6 +749,7 @@[m [mvoid makePanelItem_Mobile(iWidget *panel, const iMenuItem *item) {[m iListWidget *list = (iListWidget *) certList;[m setBackgroundColor_Widget(as_Widget(list), uiBackgroundSidebar_ColorId);[m widget = as_Widget(certList);[m [32m+[m[32m setFlags_Widget(widget, borderTop_WidgetFlag | borderBottom_WidgetFlag, iTrue);[m updateItems_CertListWidget(certList);[m invalidate_ListWidget(list);[m }[m [1mdiff --git a/src/ui/uploadwidget.c b/src/ui/uploadwidget.c[m [1mindex cb1c7c83..3286ad71 100644[m [1m--- a/src/ui/uploadwidget.c[m [1m+++ b/src/ui/uploadwidget.c[m [36m@@ -184,6 +184,7 @@[m [mvoid init_UploadWidget(iUploadWidget *d) {[m const iMenuItem fileItems[] = {[m { "navi.action text:${dlg.upload.send}", 0, 0, "upload.accept" },[m { "title id:heading.upload.file" },[m [32m+[m[32m { "padding arg:0.667" },[m { "button text:" uiTextAction_ColorEscape "${dlg.upload.pickfile}", 0, 0, "upload.pickfile" }, [m { "heading id:upload.file.name" },[m { "label id:upload.filepathlabel text:\u2014" },[m [36m@@ -196,16 +197,16 @@[m [mvoid init_UploadWidget(iUploadWidget *d) {[m };[m initPanels_Mobile(w, NULL, (iMenuItem[]){ [m { "title id:heading.upload" },[m [32m+[m[32m { "heading id:upload.content" },[m [32m+[m[32m { "panel id:dlg.upload.text icon:0x1f5b9 noscroll:1", 0, 0, (const void *) textItems },[m [32m+[m[32m { "panel id:dlg.upload.file icon:0x1f4c1", 0, 0, (const void *) fileItems },[m [32m+[m[32m { "heading text:${heading.upload.id}" },[m [32m+[m[32m { "dropdown id:upload.id icon:0x1f464 text:", 0, 0, constData_Array(makeIdentityItems_UploadWidget_(d)) },[m [32m+[m[32m { "input id:upload.token hint:hint.upload.token.long icon:0x1f516 text:" },[m { "heading id:upload.url" },[m { format_CStr("label id:upload.info font:%d",[m deviceType_App() == phone_AppDeviceType ? uiLabelBig_FontId : uiLabelMedium_FontId) },[m { "input id:upload.path hint:hint.upload.path noheading:1 url:1 text:" },[m [31m- { "heading text:${heading.upload.id}" },[m [31m- { "dropdown id:upload.id icon:0x1f464 text:", 0, 0, constData_Array(makeIdentityItems_UploadWidget_(d)) },[m [31m- { "input id:upload.token hint:hint.upload.token.long icon:0x1f516 text:" },[m [31m- { "heading id:upload.content" },[m [31m- { "panel id:dlg.upload.text icon:0x1f5b9 noscroll:1", 0, 0, (const void *) textItems },[m [31m- { "panel id:dlg.upload.file icon:0x1f4c1", 0, 0, (const void *) fileItems },[m { NULL }[m }, actions, iElemCount(actions) - 1 /* no Accept button on main panel */);[m d->info = findChild_Widget(w, "upload.info");[m [1mdiff --git a/src/ui/widget.c b/src/ui/widget.c[m [1mindex 6ad6f8de..dbf992aa 100644[m [1m--- a/src/ui/widget.c[m [1m+++ b/src/ui/widget.c[m [36m@@ -1536,6 +1536,26 @@[m [mvoid drawLayerEffects_Widget(const iWidget *d) {[m #endif[m }[m [m [32m+[m[32mvoid drawBorders_Widget(const iWidget *d) {[m [32m+[m[32m if (d->flags & (borderTop_WidgetFlag | borderBottom_WidgetFlag)) {[m [32m+[m[32m const iRect rect = bounds_Widget(d);[m [32m+[m[32m iPaint p;[m [32m+[m[32m init_Paint(&p);[m [32m+[m[32m const int hgt = gap_UI / 4;[m [32m+[m[32m const int borderColor = uiSeparator_ColorId; /* TODO: Add a property to customize? */[m [32m+[m[32m if (d->flags & borderTop_WidgetFlag) {[m [32m+[m[32m fillRect_Paint(&p, (iRect){ topLeft_Rect(rect),[m [32m+[m[32m init_I2(width_Rect(rect), hgt) },[m [32m+[m[32m borderColor);[m [32m+[m[32m }[m [32m+[m[32m if (d->flags & borderBottom_WidgetFlag) {[m [32m+[m[32m fillRect_Paint(&p, (iRect) { addY_I2(bottomLeft_Rect(rect), -hgt),[m [32m+[m[32m init_I2(width_Rect(rect), hgt) },[m [32m+[m[32m borderColor);[m [32m+[m[32m }[m [32m+[m[32m }[m [32m+[m[32m}[m [32m+[m void drawBackground_Widget(const iWidget *d) {[m if (d->flags & noBackground_WidgetFlag) {[m return;[m [36m@@ -1559,23 +1579,7 @@[m [mvoid drawBackground_Widget(const iWidget *d) {[m gap_UI / 4, d->frameColor);[m }[m }[m [31m- if (d->flags & (borderTop_WidgetFlag | borderBottom_WidgetFlag)) {[m [31m- const iRect rect = bounds_Widget(d);[m [31m- iPaint p;[m [31m- init_Paint(&p);[m [31m- const int hgt = gap_UI / 4;[m [31m- const int borderColor = uiSeparator_ColorId; /* TODO: Add a property to customize? */[m [31m- if (d->flags & borderTop_WidgetFlag) {[m [31m- fillRect_Paint(&p, (iRect){ topLeft_Rect(rect),[m [31m- init_I2(width_Rect(rect), hgt) },[m [31m- borderColor);[m [31m- }[m [31m- if (d->flags & borderBottom_WidgetFlag) {[m [31m- fillRect_Paint(&p, (iRect) { addY_I2(bottomLeft_Rect(rect), -hgt),[m [31m- init_I2(width_Rect(rect), hgt) },[m [31m- borderColor);[m [31m- }[m [31m- }[m [32m+[m[32m drawBorders_Widget(d);[m }[m [m int drawCount_;[m [1mdiff --git a/src/ui/widget.h b/src/ui/widget.h[m [1mindex 9d05d8db..1ea198ad 100644[m [1m--- a/src/ui/widget.h[m [1m+++ b/src/ui/widget.h[m [36m@@ -218,6 +218,7 @@[m [msize_t childCount_Widget (const iWidget *);[m void draw_Widget (const iWidget *);[m void drawLayerEffects_Widget (const iWidget *);[m void drawBackground_Widget (const iWidget *);[m [32m+[m[32mvoid drawBorders_Widget (const iWidget *); /* called by `drawBackground` */[m void drawChildren_Widget (const iWidget *);[m void drawRoot_Widget (const iWidget *); /* root only */[m void setDrawBufferEnabled_Widget (iWidget *, iBool enable);[m
text/gemini; charset=utf-8
This content has been proxied by September (ba2dc).