diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/documentwidget.c | 5 | ||||
-rw-r--r-- | src/ui/text.c | 20 | ||||
-rw-r--r-- | src/ui/window.c | 36 |
3 files changed, 49 insertions, 12 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 7c071f47..f8cc10b9 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -5275,6 +5275,11 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e | |||
5275 | "document.upload", | 5275 | "document.upload", |
5276 | !equalCase_Rangecc(urlScheme_String(d->mod.url), "gemini") && | 5276 | !equalCase_Rangecc(urlScheme_String(d->mod.url), "gemini") && |
5277 | !equalCase_Rangecc(urlScheme_String(d->mod.url), "titan")); | 5277 | !equalCase_Rangecc(urlScheme_String(d->mod.url), "titan")); |
5278 | setMenuItemDisabled_Widget( | ||
5279 | d->menu, | ||
5280 | "document.upload copy:1", | ||
5281 | !equalCase_Rangecc(urlScheme_String(d->mod.url), "gemini") && | ||
5282 | !equalCase_Rangecc(urlScheme_String(d->mod.url), "titan")); | ||
5278 | } | 5283 | } |
5279 | processContextMenuEvent_Widget(d->menu, ev, {}); | 5284 | processContextMenuEvent_Widget(d->menu, ev, {}); |
5280 | } | 5285 | } |
diff --git a/src/ui/text.c b/src/ui/text.c index 51531057..83e87d0c 100644 --- a/src/ui/text.c +++ b/src/ui/text.c | |||
@@ -295,6 +295,7 @@ static void setupFontVariants_Text_(iText *d, const iFontSpec *spec, int baseId) | |||
295 | /* This is the highest priority override font. */ | 295 | /* This is the highest priority override font. */ |
296 | d->overrideFontId = baseId; | 296 | d->overrideFontId = baseId; |
297 | } | 297 | } |
298 | iAssert(activeText_ == d); | ||
298 | pushBack_Array(&d->fontPriorityOrder, &(iPrioMapItem){ spec->priority, baseId }); | 299 | pushBack_Array(&d->fontPriorityOrder, &(iPrioMapItem){ spec->priority, baseId }); |
299 | for (enum iFontStyle style = 0; style < max_FontStyle; style++) { | 300 | for (enum iFontStyle style = 0; style < max_FontStyle; style++) { |
300 | for (enum iFontSize sizeId = 0; sizeId < max_FontSize; sizeId++) { | 301 | for (enum iFontSize sizeId = 0; sizeId < max_FontSize; sizeId++) { |
@@ -499,10 +500,13 @@ static void resetCache_Text_(iText *d) { | |||
499 | } | 500 | } |
500 | 501 | ||
501 | void resetFonts_Text(iText *d) { | 502 | void resetFonts_Text(iText *d) { |
503 | iText *oldActive = activeText_; | ||
504 | setCurrent_Text(d); /* some routines rely on the global `activeText_` pointer */ | ||
502 | deinitFonts_Text_(d); | 505 | deinitFonts_Text_(d); |
503 | deinitCache_Text_(d); | 506 | deinitCache_Text_(d); |
504 | initCache_Text_(d); | 507 | initCache_Text_(d); |
505 | initFonts_Text_(d); | 508 | initFonts_Text_(d); |
509 | setCurrent_Text(oldActive); | ||
506 | } | 510 | } |
507 | 511 | ||
508 | static SDL_Palette *glyphPalette_(void) { | 512 | static SDL_Palette *glyphPalette_(void) { |
@@ -1476,14 +1480,14 @@ static void evenMonospaceAdvances_GlyphBuffer_(iGlyphBuffer *d, iFont *baseFont) | |||
1476 | } | 1480 | } |
1477 | 1481 | ||
1478 | static iRect run_Font_(iFont *d, const iRunArgs *args) { | 1482 | static iRect run_Font_(iFont *d, const iRunArgs *args) { |
1479 | const int mode = args->mode; | 1483 | const int mode = args->mode; |
1480 | const iInt2 orig = args->pos; | 1484 | const iInt2 orig = args->pos; |
1481 | iRect bounds = { orig, init_I2(0, d->height) }; | 1485 | iRect bounds = { orig, init_I2(0, d->height) }; |
1482 | float xCursor = 0.0f; | 1486 | float xCursor = 0.0f; |
1483 | float yCursor = 0.0f; | 1487 | float yCursor = 0.0f; |
1484 | float xCursorMax = 0.0f; | 1488 | float xCursorMax = 0.0f; |
1485 | const iBool isMonospaced = isMonospaced_Font(d); | 1489 | const iBool isMonospaced = isMonospaced_Font(d); |
1486 | iWrapText *wrap = args->wrap; | 1490 | iWrapText *wrap = args->wrap; |
1487 | iAssert(args->text.end >= args->text.start); | 1491 | iAssert(args->text.end >= args->text.start); |
1488 | /* Split the text into a number of attributed runs that specify exactly which | 1492 | /* Split the text into a number of attributed runs that specify exactly which |
1489 | font is used and other attributes such as color. (HarfBuzz shaping is done | 1493 | font is used and other attributes such as color. (HarfBuzz shaping is done |
diff --git a/src/ui/window.c b/src/ui/window.c index bc32e479..0a97b97c 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -865,7 +865,7 @@ static iBool handleWindowEvent_MainWindow_(iMainWindow *d, const SDL_WindowEvent | |||
865 | if (d->base.isMinimized) { | 865 | if (d->base.isMinimized) { |
866 | return iFalse; | 866 | return iFalse; |
867 | } | 867 | } |
868 | closePopups_App(); | 868 | closePopups_App(iFalse); |
869 | checkPixelRatioChange_Window_(as_Window(d)); | 869 | checkPixelRatioChange_Window_(as_Window(d)); |
870 | const iInt2 newPos = init_I2(ev->data1, ev->data2); | 870 | const iInt2 newPos = init_I2(ev->data1, ev->data2); |
871 | if (isEqual_I2(newPos, init1_I2(-32000))) { /* magic! */ | 871 | if (isEqual_I2(newPos, init1_I2(-32000))) { /* magic! */ |
@@ -915,7 +915,7 @@ static iBool handleWindowEvent_MainWindow_(iMainWindow *d, const SDL_WindowEvent | |||
915 | // updateSize_Window_(d, iTrue); | 915 | // updateSize_Window_(d, iTrue); |
916 | return iTrue; | 916 | return iTrue; |
917 | } | 917 | } |
918 | closePopups_App(); | 918 | closePopups_App(iFalse); |
919 | if (unsnap_MainWindow_(d, NULL)) { | 919 | if (unsnap_MainWindow_(d, NULL)) { |
920 | return iTrue; | 920 | return iTrue; |
921 | } | 921 | } |
@@ -937,7 +937,7 @@ static iBool handleWindowEvent_MainWindow_(iMainWindow *d, const SDL_WindowEvent | |||
937 | return iTrue; | 937 | return iTrue; |
938 | case SDL_WINDOWEVENT_MINIMIZED: | 938 | case SDL_WINDOWEVENT_MINIMIZED: |
939 | d->base.isMinimized = iTrue; | 939 | d->base.isMinimized = iTrue; |
940 | closePopups_App(); | 940 | closePopups_App(iTrue); |
941 | return iTrue; | 941 | return iTrue; |
942 | #else /* if defined (!iPlatformDesktop) */ | 942 | #else /* if defined (!iPlatformDesktop) */ |
943 | case SDL_WINDOWEVENT_RESIZED: | 943 | case SDL_WINDOWEVENT_RESIZED: |
@@ -973,7 +973,7 @@ static iBool handleWindowEvent_MainWindow_(iMainWindow *d, const SDL_WindowEvent | |||
973 | #if !defined (iPlatformDesktop) | 973 | #if !defined (iPlatformDesktop) |
974 | setFreezeDraw_MainWindow(d, iTrue); | 974 | setFreezeDraw_MainWindow(d, iTrue); |
975 | #endif | 975 | #endif |
976 | closePopups_App(); | 976 | closePopups_App(iTrue); |
977 | return iFalse; | 977 | return iFalse; |
978 | case SDL_WINDOWEVENT_TAKE_FOCUS: | 978 | case SDL_WINDOWEVENT_TAKE_FOCUS: |
979 | SDL_SetWindowInputFocus(d->base.win); | 979 | SDL_SetWindowInputFocus(d->base.win); |
@@ -1178,7 +1178,35 @@ iLocalDef iBool isEscapeKeypress_(const SDL_Event *ev) { | |||
1178 | return (ev->type == SDL_KEYDOWN || ev->type == SDL_KEYUP) && ev->key.keysym.sym == SDLK_ESCAPE; | 1178 | return (ev->type == SDL_KEYDOWN || ev->type == SDL_KEYUP) && ev->key.keysym.sym == SDLK_ESCAPE; |
1179 | } | 1179 | } |
1180 | 1180 | ||
1181 | static uint32_t windowId_SDLEvent_(const SDL_Event *ev) { | ||
1182 | switch (ev->type) { | ||
1183 | case SDL_MOUSEBUTTONDOWN: | ||
1184 | case SDL_MOUSEBUTTONUP: | ||
1185 | return ev->button.windowID; | ||
1186 | case SDL_MOUSEMOTION: | ||
1187 | return ev->motion.windowID; | ||
1188 | case SDL_MOUSEWHEEL: | ||
1189 | return ev->wheel.windowID; | ||
1190 | case SDL_KEYDOWN: | ||
1191 | case SDL_KEYUP: | ||
1192 | return ev->key.windowID; | ||
1193 | case SDL_TEXTINPUT: | ||
1194 | return ev->text.windowID; | ||
1195 | case SDL_USEREVENT: | ||
1196 | return ev->user.windowID; | ||
1197 | default: | ||
1198 | return 0; | ||
1199 | } | ||
1200 | } | ||
1201 | |||
1181 | iBool dispatchEvent_Window(iWindow *d, const SDL_Event *ev) { | 1202 | iBool dispatchEvent_Window(iWindow *d, const SDL_Event *ev) { |
1203 | #if 0 | ||
1204 | /* For the right window? */ | ||
1205 | const uint32_t evWin = windowId_SDLEvent_(ev); | ||
1206 | if (evWin && evWin != id_Window(d)) { | ||
1207 | return iFalse; /* Meant for a different window. */ | ||
1208 | } | ||
1209 | #endif | ||
1182 | if (ev->type == SDL_MOUSEMOTION) { | 1210 | if (ev->type == SDL_MOUSEMOTION) { |
1183 | /* Hover widget may change. */ | 1211 | /* Hover widget may change. */ |
1184 | setHover_Widget(NULL); | 1212 | setHover_Widget(NULL); |