diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-09-18 16:05:14 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-09-18 16:05:14 +0300 |
commit | b7da52ec5711e999963df218d4fad69a8025daeb (patch) | |
tree | f196680c65574195b528d9382cf9c4c2755bd6f5 /src | |
parent | ebee2c2cd7741c5174cbea7190bad94556bd7362 (diff) |
Added build options for X11
Build option to use software rendering if running under X11, and another
option to set the position of a window only after the window has been
shown. The latter is a workaround for an SDL bug regarding window
borders affecting the initial position.
Diffstat (limited to 'src')
-rw-r--r-- | src/app.c | 10 | ||||
-rw-r--r-- | src/ui/window.c | 11 | ||||
-rw-r--r-- | src/ui/window.h | 1 |
3 files changed, 21 insertions, 1 deletions
@@ -547,7 +547,15 @@ iBool forceLineWrap_App(void) { | |||
547 | } | 547 | } |
548 | 548 | ||
549 | iBool forceSoftwareRender_App(void) { | 549 | iBool forceSoftwareRender_App(void) { |
550 | return app_.forceSoftwareRender; | 550 | if (app_.forceSoftwareRender) { |
551 | return iTrue; | ||
552 | } | ||
553 | #if defined (LAGRANGE_ENABLE_X11_SWRENDER) | ||
554 | if (getenv("DISPLAY")) { | ||
555 | return iTrue; | ||
556 | } | ||
557 | #endif | ||
558 | return iFalse; | ||
551 | } | 559 | } |
552 | 560 | ||
553 | enum iColorTheme colorTheme_App(void) { | 561 | enum iColorTheme colorTheme_App(void) { |
diff --git a/src/ui/window.c b/src/ui/window.c index b43e8421..8ebb67a8 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -506,6 +506,7 @@ iBool create_Window_(iWindow *d, iRect rect, uint32_t flags) { | |||
506 | void init_Window(iWindow *d, iRect rect) { | 506 | void init_Window(iWindow *d, iRect rect) { |
507 | theWindow_ = d; | 507 | theWindow_ = d; |
508 | iZap(d->cursors); | 508 | iZap(d->cursors); |
509 | d->initialPos = rect.pos; | ||
509 | d->pendingCursor = NULL; | 510 | d->pendingCursor = NULL; |
510 | d->isDrawFrozen = iTrue; | 511 | d->isDrawFrozen = iTrue; |
511 | uint32_t flags = 0; | 512 | uint32_t flags = 0; |
@@ -597,6 +598,16 @@ SDL_Renderer *renderer_Window(const iWindow *d) { | |||
597 | 598 | ||
598 | static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { | 599 | static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { |
599 | switch (ev->event) { | 600 | switch (ev->event) { |
601 | #if defined (LAGRANGE_ENABLE_WINDOWPOS_FIX) | ||
602 | case SDL_WINDOWEVENT_EXPOSED: | ||
603 | if (d->initialPos.x >= 0) { | ||
604 | int bx, by; | ||
605 | SDL_GetWindowBordersSize(d->win, &by, &bx, NULL, NULL); | ||
606 | SDL_SetWindowPosition(d->win, d->initialPos.x + bx, d->initialPos.y + by); | ||
607 | d->initialPos = init1_I2(-1); | ||
608 | } | ||
609 | return iFalse; | ||
610 | #endif | ||
600 | case SDL_WINDOWEVENT_MOVED: | 611 | case SDL_WINDOWEVENT_MOVED: |
601 | /* No need to do anything. */ | 612 | /* No need to do anything. */ |
602 | return iTrue; | 613 | return iTrue; |
diff --git a/src/ui/window.h b/src/ui/window.h index 4aec2fa7..b067d30e 100644 --- a/src/ui/window.h +++ b/src/ui/window.h | |||
@@ -34,6 +34,7 @@ iDeclareTypeConstructionArgs(Window, iRect rect) | |||
34 | 34 | ||
35 | struct Impl_Window { | 35 | struct Impl_Window { |
36 | SDL_Window * win; | 36 | SDL_Window * win; |
37 | iInt2 initialPos; | ||
37 | iBool isDrawFrozen; /* avoids premature draws while restoring window state */ | 38 | iBool isDrawFrozen; /* avoids premature draws while restoring window state */ |
38 | SDL_Renderer *render; | 39 | SDL_Renderer *render; |
39 | iWidget * root; | 40 | iWidget * root; |