summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app.c8
-rw-r--r--src/app.h3
-rw-r--r--src/ui/documentwidget.c2
-rw-r--r--src/ui/window.c27
4 files changed, 28 insertions, 12 deletions
diff --git a/src/app.c b/src/app.c
index 5eceebec..42244c80 100644
--- a/src/app.c
+++ b/src/app.c
@@ -98,6 +98,7 @@ struct Impl_App {
98 float uiScale; 98 float uiScale;
99 int zoomPercent; 99 int zoomPercent;
100 iBool forceWrap; 100 iBool forceWrap;
101 iBool forceSoftwareRender;
101 enum iColorTheme theme; 102 enum iColorTheme theme;
102 iBool useSystemTheme; 103 iBool useSystemTheme;
103 iString gopherProxy; 104 iString gopherProxy;
@@ -304,6 +305,7 @@ static void init_App_(iApp *d, int argc, char **argv) {
304 d->pendingRefresh = iFalse; 305 d->pendingRefresh = iFalse;
305 d->zoomPercent = 100; 306 d->zoomPercent = 100;
306 d->forceWrap = iFalse; 307 d->forceWrap = iFalse;
308 d->forceSoftwareRender = checkArgument_CommandLine(&d->args, "sw") != NULL;
307 d->certs = new_GmCerts(dataDir_App_); 309 d->certs = new_GmCerts(dataDir_App_);
308 d->visited = new_Visited(); 310 d->visited = new_Visited();
309 d->bookmarks = new_Bookmarks(); 311 d->bookmarks = new_Bookmarks();
@@ -531,10 +533,14 @@ int zoom_App(void) {
531 return app_.zoomPercent; 533 return app_.zoomPercent;
532} 534}
533 535
534iBool isLineWrapForced_App(void) { 536iBool forceLineWrap_App(void) {
535 return app_.forceWrap; 537 return app_.forceWrap;
536} 538}
537 539
540iBool forceSoftwareRender_App(void) {
541 return app_.forceSoftwareRender;
542}
543
538enum iColorTheme colorTheme_App(void) { 544enum iColorTheme colorTheme_App(void) {
539 return app_.theme; 545 return app_.theme;
540} 546}
diff --git a/src/app.h b/src/app.h
index 69b8d274..a5b1266d 100644
--- a/src/app.h
+++ b/src/app.h
@@ -58,7 +58,8 @@ iBool isRefreshPending_App (void);
58uint32_t elapsedSinceLastTicker_App (void); /* milliseconds */ 58uint32_t elapsedSinceLastTicker_App (void); /* milliseconds */
59 59
60int zoom_App (void); 60int zoom_App (void);
61iBool isLineWrapForced_App(void); 61iBool forceLineWrap_App (void);
62iBool forceSoftwareRender_App(void);
62enum iColorTheme colorTheme_App (void); 63enum iColorTheme colorTheme_App (void);
63const iString * schemeProxy_App (iRangecc scheme); 64const iString * schemeProxy_App (iRangecc scheme);
64 65
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index fce548b4..ab8af9b8 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -269,7 +269,7 @@ static iRect documentBounds_DocumentWidget_(const iDocumentWidget *d) {
269} 269}
270 270
271static int forceBreakWidth_DocumentWidget_(const iDocumentWidget *d) { 271static int forceBreakWidth_DocumentWidget_(const iDocumentWidget *d) {
272 if (isLineWrapForced_App()) { 272 if (forceLineWrap_App()) {
273 const iRect bounds = bounds_Widget(constAs_Widget(d)); 273 const iRect bounds = bounds_Widget(constAs_Widget(d));
274 const iRect docBounds = documentBounds_DocumentWidget_(d); 274 const iRect docBounds = documentBounds_DocumentWidget_(d);
275 return right_Rect(bounds) - left_Rect(docBounds) - gap_UI * d->pageMargin; 275 return right_Rect(bounds) - left_Rect(docBounds) - gap_UI * d->pageMargin;
diff --git a/src/ui/window.c b/src/ui/window.c
index 0a63a941..38df42e0 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -477,26 +477,35 @@ static void drawBlank_Window_(iWindow *d) {
477 SDL_RenderPresent(d->render); 477 SDL_RenderPresent(d->render);
478} 478}
479 479
480// #define ENABLE_SWRENDER 480iBool create_Window_(iWindow *d, iRect rect, uint32_t flags) {
481 flags |= SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI;
482 if (SDL_CreateWindowAndRenderer(
483 width_Rect(rect), height_Rect(rect), flags, &d->win, &d->render)) {
484 return iFalse;
485 }
486 return iTrue;
487}
481 488
482void init_Window(iWindow *d, iRect rect) { 489void init_Window(iWindow *d, iRect rect) {
483 theWindow_ = d; 490 theWindow_ = d;
484 iZap(d->cursors); 491 iZap(d->cursors);
485 d->pendingCursor = NULL; 492 d->pendingCursor = NULL;
486 d->isDrawFrozen = iTrue; 493 d->isDrawFrozen = iTrue;
487 uint32_t flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI; 494 uint32_t flags = 0;
488#if defined (ENABLE_SWRENDER) 495#if defined (iPlatformApple)
489 SDL_SetHint(SDL_HINT_RENDER_DRIVER, "software");
490#elif defined (iPlatformApple)
491 SDL_SetHint(SDL_HINT_RENDER_DRIVER, "metal"); 496 SDL_SetHint(SDL_HINT_RENDER_DRIVER, "metal");
492#else 497#else
493 flags |= SDL_WINDOW_OPENGL; 498 flags |= SDL_WINDOW_OPENGL;
494#endif 499#endif
495 SDL_SetHint(SDL_HINT_RENDER_VSYNC, "1"); 500 SDL_SetHint(SDL_HINT_RENDER_VSYNC, "1");
496 if (SDL_CreateWindowAndRenderer( 501 /* First try SDL's default renderer that should be the best option. */
497 width_Rect(rect), height_Rect(rect), flags, &d->win, &d->render)) { 502 if (forceSoftwareRender_App() || !create_Window_(d, rect, flags)) {
498 fprintf(stderr, "Error when creating window: %s\n", SDL_GetError()); 503 /* No luck, maybe software only? This should always work as long as there is a display. */
499 exit(-2); 504 SDL_SetHint(SDL_HINT_RENDER_DRIVER, "software");
505 if (!create_Window_(d, rect, 0)) {
506 fprintf(stderr, "Error when creating window: %s\n", SDL_GetError());
507 exit(-2);
508 }
500 } 509 }
501 if (left_Rect(rect) >= 0) { 510 if (left_Rect(rect) >= 0) {
502 SDL_SetWindowPosition(d->win, left_Rect(rect), top_Rect(rect)); 511 SDL_SetWindowPosition(d->win, left_Rect(rect), top_Rect(rect));