=> 89b0c96982370eb7fa4c43eb1080163dedcc4b0a
[1mdiff --git a/src/app.c b/src/app.c[m [1mindex 5abfdb4e..63c32e8a 100644[m [1m--- a/src/app.c[m [1m+++ b/src/app.c[m [36m@@ -2243,6 +2243,19 @@[m [mstatic int resizeWatcher_(void *user, SDL_Event *event) {[m return 0;[m }[m [m [32m+[m[32miLocalDef iBool isResizeDrawEnabled_(void) {[m [32m+[m[32m#if defined (LAGRANGE_ENABLE_RESIZE_DRAW)[m [32m+[m[32m# if defined (LAGRANGE_ENABLE_X11_XLIB)[m [32m+[m[32m if (!isXSession_X11()) {[m [32m+[m[32m return iFalse; /* not on Wayland */[m [32m+[m[32m }[m [32m+[m[32m# endif[m [32m+[m[32m return iTrue;[m [32m+[m[32m#else[m [32m+[m[32m return iFalse;[m [32m+[m[32m#endif[m[41m [m [32m+[m[32m}[m [32m+[m static int run_App_(iApp *d) {[m /* Initial arrangement. */[m iForIndices(i, d->window->roots) {[m [36m@@ -2252,9 +2265,9 @@[m [mstatic int run_App_(iApp *d) {[m }[m d->isRunning = iTrue;[m SDL_EventState(SDL_DROPFILE, SDL_ENABLE); /* open files via drag'n'drop */[m [31m-#if defined (LAGRANGE_ENABLE_RESIZE_DRAW)[m [31m- SDL_AddEventWatch(resizeWatcher_, d); /* redraw window during resizing */[m [31m-#endif[m [32m+[m[32m if (isResizeDrawEnabled_()) {[m [32m+[m[32m SDL_AddEventWatch(resizeWatcher_, d); /* redraw window during resizing */[m [32m+[m[32m }[m while (d->isRunning) {[m processEvents_App(waitForNewEvents_AppEventMode);[m runTickers_App_(d);[m [1mdiff --git a/src/ui/util.c b/src/ui/util.c[m [1mindex 296aedba..21e9d490 100644[m [1m--- a/src/ui/util.c[m [1m+++ b/src/ui/util.c[m [36m@@ -51,6 +51,10 @@[m [mSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */[m # include "macos.h"[m #endif[m [m [32m+[m[32m#if defined (LAGRANGE_ENABLE_X11_XLIB)[m [32m+[m[32m# include "x11.h"[m [32m+[m[32m#endif[m [32m+[m #include[m #include [m #include [m [36m@@ -1220,6 +1224,11 @@[m [mvoid unselectAllNativeMenuItems_Widget(iWidget *menu) {[m [m iLocalDef iBool isUsingMenuPopupWindows_(void) {[m #if defined (LAGRANGE_ENABLE_POPUP_MENUS) && !defined (iPlatformTerminal)[m [32m+[m[32m# if defined (LAGRANGE_ENABLE_X11_XLIB)[m [32m+[m[32m if (!isXSession_X11()) {[m [32m+[m[32m return iFalse; /* popup windows not supported on Wayland */[m [32m+[m[32m }[m [32m+[m[32m# endif[m return deviceType_App() == desktop_AppDeviceType;[m #else[m return iFalse;[m [36m@@ -1268,64 +1277,64 @@[m [mvoid openMenuFlags_Widget(iWidget *d, iInt2 windowCoord, int menuOpenFlags) {[m }[m }[m }[m [31m-#if defined (LAGRANGE_ENABLE_POPUP_MENUS) && !defined (iPlatformTerminal)[m [31m- /* Determine total display bounds where the popup may appear. */[m [31m- iRect displayRect = zero_Rect(); [m [31m- for (int i = 0; i < SDL_GetNumVideoDisplays(); i++) {[m [31m- SDL_Rect dispBounds;[m [31m- SDL_GetDisplayUsableBounds(i, &dispBounds);[m [31m- displayRect = union_Rect([m [31m- displayRect, init_Rect(dispBounds.x, dispBounds.y, dispBounds.w, dispBounds.h));[m [31m- }[m [31m- iRect winRect;[m [31m- SDL_Window *sdlWin = get_Window()->win;[m [31m- const float pixelRatio = get_Window()->pixelRatio;[m [31m- iInt2 winPos;[m [31m- SDL_GetWindowPosition(sdlWin, &winPos.x, &winPos.y);[m [31m- winRect = rootRect;[m [31m- winRect.pos.x /= pixelRatio;[m [31m- winRect.pos.y /= pixelRatio;[m [31m- winRect.size.x /= pixelRatio;[m [31m- winRect.size.y /= pixelRatio;[m [31m- addv_I2(&winRect.pos, winPos);[m [31m- iRect visibleWinRect = intersect_Rect(winRect, displayRect);[m [31m- /* Only use a popup window if the menu can't fit inside the main window. */[m [31m- if (height_Widget(d) / pixelRatio > visibleWinRect.size.y && isUsingMenuPopupWindows_()) {[m [31m- if (postCommands) {[m [31m- postCommand_Widget(d, "menu.opened");[m [31m- }[m [31m- updateMenuItemFonts_Widget_(d);[m [31m- iRoot *oldRoot = current_Root();[m [31m- setFlags_Widget(d, keepOnTop_WidgetFlag, iFalse);[m [31m- setUserData_Object(d, parent_Widget(d));[m [31m- iAssert(userData_Object(d));[m [31m- removeChild_Widget(parent_Widget(d), d); /* we'll borrow the widget for a while */[m [32m+[m[32m if (isUsingMenuPopupWindows_()) {[m [32m+[m[32m /* Determine total display bounds where the popup may appear. */[m [32m+[m[32m iRect displayRect = zero_Rect();[m[41m [m [32m+[m[32m for (int i = 0; i < SDL_GetNumVideoDisplays(); i++) {[m [32m+[m[32m SDL_Rect dispBounds;[m [32m+[m[32m SDL_GetDisplayUsableBounds(i, &dispBounds);[m [32m+[m[32m displayRect = union_Rect([m [32m+[m[32m displayRect, init_Rect(dispBounds.x, dispBounds.y, dispBounds.w, dispBounds.h));[m [32m+[m[32m }[m [32m+[m[32m iRect winRect;[m [32m+[m[32m SDL_Window *sdlWin = get_Window()->win;[m [32m+[m[32m const float pixelRatio = get_Window()->pixelRatio;[m iInt2 winPos;[m SDL_GetWindowPosition(sdlWin, &winPos.x, &winPos.y);[m [31m- iInt2 menuPos = add_I2(winPos,[m [31m- divf_I2(sub_I2(windowCoord, divi_I2(gap2_UI, 2)), pixelRatio));[m [31m- /* Check display bounds. */ {[m [31m- iInt2 menuSize = divf_I2(d->rect.size, pixelRatio);[m [31m- if (menuOpenFlags & center_MenuOpenFlags) {[m [31m- iInt2 winSize;[m [31m- SDL_GetWindowSize(sdlWin, &winSize.x, &winSize.y);[m [31m- menuPos = sub_I2(add_I2(winPos, divi_I2(winSize, 2)), divi_I2(menuSize, 2));[m [32m+[m[32m winRect = rootRect;[m [32m+[m[32m winRect.pos.x /= pixelRatio;[m [32m+[m[32m winRect.pos.y /= pixelRatio;[m [32m+[m[32m winRect.size.x /= pixelRatio;[m [32m+[m[32m winRect.size.y /= pixelRatio;[m [32m+[m[32m addv_I2(&winRect.pos, winPos);[m [32m+[m[32m iRect visibleWinRect = intersect_Rect(winRect, displayRect);[m [32m+[m[32m /* Only use a popup window if the menu can't fit inside the main window. */[m [32m+[m[32m if (height_Widget(d) / pixelRatio > visibleWinRect.size.y && isUsingMenuPopupWindows_()) {[m [32m+[m[32m if (postCommands) {[m [32m+[m[32m postCommand_Widget(d, "menu.opened");[m }[m [31m- menuPos.x = iMin(menuPos.x, right_Rect(displayRect) - menuSize.x);[m [31m- menuPos.y = iMax(0, iMin(menuPos.y, bottom_Rect(displayRect) - menuSize.y));[m [32m+[m[32m updateMenuItemFonts_Widget_(d);[m [32m+[m[32m iRoot *oldRoot = current_Root();[m [32m+[m[32m setFlags_Widget(d, keepOnTop_WidgetFlag, iFalse);[m [32m+[m[32m setUserData_Object(d, parent_Widget(d));[m [32m+[m[32m iAssert(userData_Object(d));[m [32m+[m[32m removeChild_Widget(parent_Widget(d), d); /* we'll borrow the widget for a while */[m [32m+[m[32m iInt2 winPos;[m [32m+[m[32m SDL_GetWindowPosition(sdlWin, &winPos.x, &winPos.y);[m [32m+[m[32m iInt2 menuPos = add_I2(winPos,[m [32m+[m[32m divf_I2(sub_I2(windowCoord, divi_I2(gap2_UI, 2)), pixelRatio));[m [32m+[m[32m /* Check display bounds. */ {[m [32m+[m[32m iInt2 menuSize = divf_I2(d->rect.size, pixelRatio);[m [32m+[m[32m if (menuOpenFlags & center_MenuOpenFlags) {[m [32m+[m[32m iInt2 winSize;[m [32m+[m[32m SDL_GetWindowSize(sdlWin, &winSize.x, &winSize.y);[m [32m+[m[32m menuPos = sub_I2(add_I2(winPos, divi_I2(winSize, 2)), divi_I2(menuSize, 2));[m [32m+[m[32m }[m [32m+[m[32m menuPos.x = iMin(menuPos.x, right_Rect(displayRect) - menuSize.x);[m [32m+[m[32m menuPos.y = iMax(0, iMin(menuPos.y, bottom_Rect(displayRect) - menuSize.y));[m [32m+[m[32m }[m [32m+[m[32m iWindow *win = newPopup_Window(menuPos, d); /* window takes the widget */[m [32m+[m[32m setCurrent_Window(win);[m [32m+[m[32m SDL_SetWindowTitle(win->win, "Menu");[m [32m+[m[32m arrange_Widget(d);[m [32m+[m[32m addPopup_App(win);[m [32m+[m[32m SDL_ShowWindow(win->win);[m [32m+[m[32m draw_Window(win);[m [32m+[m[32m setCurrent_Window(mainWindow_App());[m [32m+[m[32m setCurrent_Root(oldRoot);[m [32m+[m[32m return;[m }[m [31m- iWindow *win = newPopup_Window(menuPos, d); /* window takes the widget */[m [31m- setCurrent_Window(win);[m [31m- SDL_SetWindowTitle(win->win, "Menu");[m [31m- arrange_Widget(d);[m [31m- addPopup_App(win);[m [31m- SDL_ShowWindow(win->win);[m [31m- draw_Window(win);[m [31m- setCurrent_Window(mainWindow_App());[m [31m- setCurrent_Root(oldRoot);[m [31m- return;[m }[m [31m-#endif[m raise_Widget(d);[m if (deviceType_App() != desktop_AppDeviceType) {[m setFlags_Widget(d, arrangeWidth_WidgetFlag | resizeChildrenToWidestChild_WidgetFlag, [m [1mdiff --git a/src/x11.c b/src/x11.c[m [1mindex 40878c30..94f6701a 100644[m [1m--- a/src/x11.c[m [1m+++ b/src/x11.c[m [36m@@ -30,7 +30,18 @@[m [mSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */[m #include [m #include [m [m [32m+[m[32miBool isXSession_X11(void) {[m [32m+[m[32m const char *driver = SDL_GetCurrentVideoDriver();[m [32m+[m[32m if (driver && !iCmpStr(driver, "wayland")) {[m [32m+[m[32m return iFalse;[m [32m+[m[32m }[m [32m+[m[32m return iTrue; /* assume yes if this source file is being used */[m [32m+[m[32m}[m [32m+[m void setDarkWindowTheme_SDLWindow(SDL_Window *d, iBool setDark) {[m [32m+[m[32m if (!isXSession_X11()) {[m [32m+[m[32m return;[m [32m+[m[32m }[m SDL_SysWMinfo wmInfo;[m SDL_VERSION(&wmInfo.version);[m if (SDL_GetWindowWMInfo(d, &wmInfo)) {[m [36m@@ -45,6 +56,9 @@[m [mvoid setDarkWindowTheme_SDLWindow(SDL_Window *d, iBool setDark) {[m }[m [m void handleCommand_X11(const char *cmd) {[m [32m+[m[32m if (!isXSession_X11()) {[m [32m+[m[32m return;[m [32m+[m[32m }[m if (equal_Command(cmd, "theme.changed")) { [m iConstForEach(PtrArray, iter, mainWindows_App()) {[m iMainWindow *mw = iter.ptr;[m [1mdiff --git a/src/x11.h b/src/x11.h[m [1mindex 2eb195ad..c25a212a 100644[m [1m--- a/src/x11.h[m [1m+++ b/src/x11.h[m [36m@@ -25,6 +25,7 @@[m [mSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */[m #include [m #include [m [m [32m+[m[32miBool isXSession_X11 (void);[m void setDarkWindowTheme_SDLWindow (SDL_Window *, iBool setDark);[m void handleCommand_X11 (const char *cmd);[m [m
text/gemini; charset=utf-8
This content has been proxied by September (ba2dc).