diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-08-29 16:52:04 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-08-29 16:52:04 +0300 |
commit | 88a9376327733a06490bd8322fe18f12a85560bc (patch) | |
tree | a53dfd851003b73458827b0fe4083bece699f304 /src | |
parent | 9895b10c9cb2d69be718dd3847206e98631dc1c0 (diff) | |
parent | 7ec39c46f2efdbc084beacdfae7b79ba794042b4 (diff) |
Merge branch 'dev' into work/v1.7
Diffstat (limited to 'src')
-rw-r--r-- | src/app.c | 14 | ||||
-rw-r--r-- | src/app.h | 2 | ||||
-rw-r--r-- | src/ui/documentwidget.c | 15 | ||||
-rw-r--r-- | src/ui/inputwidget.c | 7 | ||||
-rw-r--r-- | src/ui/labelwidget.c | 2 | ||||
-rw-r--r-- | src/ui/window.c | 13 |
6 files changed, 40 insertions, 13 deletions
@@ -122,6 +122,7 @@ struct Impl_App { | |||
122 | uint32_t lastTickerTime; | 122 | uint32_t lastTickerTime; |
123 | uint32_t elapsedSinceLastTicker; | 123 | uint32_t elapsedSinceLastTicker; |
124 | iBool isRunning; | 124 | iBool isRunning; |
125 | iBool isRunningUnderWindowSystem; | ||
125 | #if defined (LAGRANGE_ENABLE_IDLE_SLEEP) | 126 | #if defined (LAGRANGE_ENABLE_IDLE_SLEEP) |
126 | iBool isIdling; | 127 | iBool isIdling; |
127 | uint32_t lastEventTime; | 128 | uint32_t lastEventTime; |
@@ -626,6 +627,12 @@ static iBool hasCommandLineOpenableScheme_(const iRangecc uri) { | |||
626 | } | 627 | } |
627 | 628 | ||
628 | static void init_App_(iApp *d, int argc, char **argv) { | 629 | static void init_App_(iApp *d, int argc, char **argv) { |
630 | #if defined (iPlatformLinux) | ||
631 | d->isRunningUnderWindowSystem = !iCmpStr(SDL_GetCurrentVideoDriver(), "x11") || | ||
632 | !iCmpStr(SDL_GetCurrentVideoDriver(), "wayland"); | ||
633 | #else | ||
634 | d->isRunningUnderWindowSystem = iTrue; | ||
635 | #endif | ||
629 | init_CommandLine(&d->args, argc, argv); | 636 | init_CommandLine(&d->args, argc, argv); |
630 | /* Where was the app started from? We ask SDL first because the command line alone is | 637 | /* Where was the app started from? We ask SDL first because the command line alone is |
631 | not a reliable source of this information, particularly when it comes to different | 638 | not a reliable source of this information, particularly when it comes to different |
@@ -749,7 +756,8 @@ static void init_App_(iApp *d, int argc, char **argv) { | |||
749 | mulfv_I2(&d->initialWindowRect.size, desktopDPI_Win32()); | 756 | mulfv_I2(&d->initialWindowRect.size, desktopDPI_Win32()); |
750 | #endif | 757 | #endif |
751 | #if defined (iPlatformLinux) | 758 | #if defined (iPlatformLinux) |
752 | /* Scale by the primary (?) monitor DPI. */ { | 759 | /* Scale by the primary (?) monitor DPI. */ |
760 | if (isRunningUnderWindowSystem_App()) { | ||
753 | float vdpi; | 761 | float vdpi; |
754 | SDL_GetDisplayDPI(0, NULL, NULL, &vdpi); | 762 | SDL_GetDisplayDPI(0, NULL, NULL, &vdpi); |
755 | const float factor = vdpi / 96.0f; | 763 | const float factor = vdpi / 96.0f; |
@@ -1586,6 +1594,10 @@ enum iAppDeviceType deviceType_App(void) { | |||
1586 | #endif | 1594 | #endif |
1587 | } | 1595 | } |
1588 | 1596 | ||
1597 | iBool isRunningUnderWindowSystem_App(void) { | ||
1598 | return app_.isRunningUnderWindowSystem; | ||
1599 | } | ||
1600 | |||
1589 | iGmCerts *certs_App(void) { | 1601 | iGmCerts *certs_App(void) { |
1590 | return app_.certs; | 1602 | return app_.certs; |
1591 | } | 1603 | } |
@@ -87,6 +87,8 @@ iBool isLandscape_App (void); | |||
87 | iLocalDef iBool isPortrait_App (void) { return !isLandscape_App(); } | 87 | iLocalDef iBool isPortrait_App (void) { return !isLandscape_App(); } |
88 | enum iAppDeviceType deviceType_App (void); | 88 | enum iAppDeviceType deviceType_App (void); |
89 | iLocalDef iBool isPortraitPhone_App (void) { return isPortrait_App() && deviceType_App() == phone_AppDeviceType; } | 89 | iLocalDef iBool isPortraitPhone_App (void) { return isPortrait_App() && deviceType_App() == phone_AppDeviceType; } |
90 | iBool isRunningUnderWindowSystem_App (void); | ||
91 | |||
90 | iGmCerts * certs_App (void); | 92 | iGmCerts * certs_App (void); |
91 | iVisited * visited_App (void); | 93 | iVisited * visited_App (void); |
92 | iBookmarks * bookmarks_App (void); | 94 | iBookmarks * bookmarks_App (void); |
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 83f38dee..76e843d5 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -4213,12 +4213,12 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) { | |||
4213 | /* Fill the background. */ { | 4213 | /* Fill the background. */ { |
4214 | if (run->linkId && linkFlags & isOpen_GmLinkFlag && ~linkFlags & content_GmLinkFlag) { | 4214 | if (run->linkId && linkFlags & isOpen_GmLinkFlag && ~linkFlags & content_GmLinkFlag) { |
4215 | /* Open links get a highlighted background. */ | 4215 | /* Open links get a highlighted background. */ |
4216 | int bg = tmBackgroundOpenLink_ColorId; | 4216 | int bg = tmBackgroundOpenLink_ColorId; |
4217 | const int frame = tmFrameOpenLink_ColorId; | 4217 | const int frame = tmFrameOpenLink_ColorId; |
4218 | iRect wideRect = { init_I2(left_Rect(d->widgetBounds), visPos.y), | 4218 | iRect wideRect = { init_I2(left_Rect(d->widgetBounds), visPos.y), |
4219 | init_I2(width_Rect(d->widgetBounds) + | 4219 | init_I2(width_Rect(d->widgetBounds) + |
4220 | width_Widget(d->widget->scroll), | 4220 | width_Widget(d->widget->scroll), |
4221 | height_Rect(run->visBounds)) }; | 4221 | height_Rect(run->visBounds)) }; |
4222 | /* The first line is composed of two runs that may be drawn in either order, so | 4222 | /* The first line is composed of two runs that may be drawn in either order, so |
4223 | only draw half of the background. */ | 4223 | only draw half of the background. */ |
4224 | if (run->flags & decoration_GmRunFlag) { | 4224 | if (run->flags & decoration_GmRunFlag) { |
@@ -4238,8 +4238,11 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) { | |||
4238 | // &d->paint, addY_I2(bottomLeft_Rect(wideRect), -1), width_Rect(wideRect), frame); | 4238 | // &d->paint, addY_I2(bottomLeft_Rect(wideRect), -1), width_Rect(wideRect), frame); |
4239 | // } | 4239 | // } |
4240 | } | 4240 | } |
4241 | else if (run->linkId) { | 4241 | else { |
4242 | /* Normal background for runs that may change appearance. */ | 4242 | /* Normal background for other runs. There are cases when runs get drawn multiple times, |
4243 | e.g., at the buffer boundary, and there are slightly overlapping characters in | ||
4244 | monospace blocks. Clearing the background here ensures a cleaner visual appearance | ||
4245 | since only one glyph is visible at any given point. */ | ||
4243 | fillRect_Paint(&d->paint, (iRect){ visPos, run->visBounds.size }, tmBackground_ColorId); | 4246 | fillRect_Paint(&d->paint, (iRect){ visPos, run->visBounds.size }, tmBackground_ColorId); |
4244 | } | 4247 | } |
4245 | } | 4248 | } |
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c index fa65cf3c..690107a2 100644 --- a/src/ui/inputwidget.c +++ b/src/ui/inputwidget.c | |||
@@ -541,6 +541,11 @@ static int contentHeight_InputWidget_(const iInputWidget *d) { | |||
541 | return size_Range(&d->visWrapLines) * lineHeight_Text(d->font); | 541 | return size_Range(&d->visWrapLines) * lineHeight_Text(d->font); |
542 | } | 542 | } |
543 | 543 | ||
544 | static void updateTextInputRect_InputWidget_(const iInputWidget *d) { | ||
545 | const iRect bounds = bounds_Widget(constAs_Widget(d)); | ||
546 | SDL_SetTextInputRect(&(SDL_Rect){ bounds.pos.x, bounds.pos.y, bounds.size.x, bounds.size.y }); | ||
547 | } | ||
548 | |||
544 | static void updateMetrics_InputWidget_(iInputWidget *d) { | 549 | static void updateMetrics_InputWidget_(iInputWidget *d) { |
545 | iWidget *w = as_Widget(d); | 550 | iWidget *w = as_Widget(d); |
546 | updateSizeForFixedLength_InputWidget_(d); | 551 | updateSizeForFixedLength_InputWidget_(d); |
@@ -553,6 +558,7 @@ static void updateMetrics_InputWidget_(iInputWidget *d) { | |||
553 | invalidateBuffered_InputWidget_(d); | 558 | invalidateBuffered_InputWidget_(d); |
554 | if (height_Rect(w->rect) != oldHeight) { | 559 | if (height_Rect(w->rect) != oldHeight) { |
555 | postCommand_Widget(d, "input.resized"); | 560 | postCommand_Widget(d, "input.resized"); |
561 | updateTextInputRect_InputWidget_(d); | ||
556 | } | 562 | } |
557 | } | 563 | } |
558 | 564 | ||
@@ -988,6 +994,7 @@ void begin_InputWidget(iInputWidget *d) { | |||
988 | iZap(d->mark); | 994 | iZap(d->mark); |
989 | } | 995 | } |
990 | enableEditorKeysInMenus_(iFalse); | 996 | enableEditorKeysInMenus_(iFalse); |
997 | updateTextInputRect_InputWidget_(d); | ||
991 | updateVisible_InputWidget_(d); | 998 | updateVisible_InputWidget_(d); |
992 | } | 999 | } |
993 | 1000 | ||
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c index 58294c6a..3bfa600b 100644 --- a/src/ui/labelwidget.c +++ b/src/ui/labelwidget.c | |||
@@ -311,7 +311,7 @@ static void draw_LabelWidget_(const iLabelWidget *d) { | |||
311 | #endif | 311 | #endif |
312 | drawLines_Paint(&p, points + 2, 3, frame2); | 312 | drawLines_Paint(&p, points + 2, 3, frame2); |
313 | drawLines_Paint( | 313 | drawLines_Paint( |
314 | &p, points, !isHover && flags & d->flags.noTopFrame ? 2 : 3, frame); | 314 | &p, points, !isHover && d->flags.noTopFrame ? 2 : 3, frame); |
315 | } | 315 | } |
316 | } | 316 | } |
317 | setClip_Paint(&p, rect); | 317 | setClip_Paint(&p, rect); |
diff --git a/src/ui/window.c b/src/ui/window.c index 3bafd9a4..3ac02495 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -278,11 +278,14 @@ static float displayScale_Window_(const iWindow *d) { | |||
278 | iUnused(d); | 278 | iUnused(d); |
279 | return desktopDPI_Win32(); | 279 | return desktopDPI_Win32(); |
280 | #else | 280 | #else |
281 | float vdpi = 0.0f; | 281 | if (isRunningUnderWindowSystem_App()) { |
282 | SDL_GetDisplayDPI(SDL_GetWindowDisplayIndex(d->win), NULL, NULL, &vdpi); | 282 | float vdpi = 0.0f; |
283 | // printf("DPI: %f\n", vdpi); | 283 | SDL_GetDisplayDPI(SDL_GetWindowDisplayIndex(d->win), NULL, NULL, &vdpi); |
284 | const float factor = vdpi / baseDPI_Window / pixelRatio_Window_(d); | 284 | // printf("DPI: %f\n", vdpi); |
285 | return iMax(1.0f, factor); | 285 | const float factor = vdpi / baseDPI_Window / pixelRatio_Window_(d); |
286 | return iMax(1.0f, factor); | ||
287 | } | ||
288 | return 1.0f; | ||
286 | #endif | 289 | #endif |
287 | } | 290 | } |
288 | 291 | ||