Skip to content

Preventing terminal windows in Windows#20436

Open
gerritsangel wants to merge 2 commits intodarktable-org:masterfrom
gerritsangel:disable-lua-terminal-window
Open

Preventing terminal windows in Windows#20436
gerritsangel wants to merge 2 commits intodarktable-org:masterfrom
gerritsangel:disable-lua-terminal-window

Conversation

@gerritsangel
Copy link
Contributor

This is basically a WIP for #17193.

It is replacing many of the Lua standard implementation by calling Windows APIs directly, which will not open terminal windows. I have mostly copied the Lua source code and adjusted it where necessary, because everything was so tightly coupled that I could not just replace some functions.

@wpferguson
Copy link
Member

We have a work around that launches a shell, then starts darktable from there. It's been incorporated into the installer, so it works by default.

I'm wondering if the added complexity and maintenance is worth the change? The one issue we struggle with is UTF and filenames. I don't know if this change alleviates any of that by using the Windows API, but if it does it might be worth the "expense".

@lefth
Copy link
Contributor

lefth commented Mar 3, 2026

@wpferguson Is that fix incorporated into the nightly builds? I just installed darktable-5.5.0+448.g73f7976e53-win64.exe and I'm seeing no change in the popups. (Windows 11. In the issue thread @jeanrenaud mentioned some possible reasons a powershell-based fix might not work for some people, but for now I'll go back to using a .vbs script as a launcher.)

@ralfbrown
Copy link
Collaborator

Windows-specific variants of io.* functions are more appropriately contributed to upstream Lua, and only added to darktable if not accepted there.

@wpferguson
Copy link
Member

@lefth I know it was discussed, but I'm not sure if we did it? @victoryforce did we change the launcher?

@gerritsangel
Copy link
Contributor Author

gerritsangel commented Mar 3, 2026

Windows-specific variants of io.* functions are more appropriately contributed to upstream Lua, and only added to darktable if not accepted there.

I tried to have it added there (I also think it's much better directly changed at upstream Lua, because it affects every project), but they didn't want to have the changes.

We have a work around that launches a shell, then starts darktable from there. It's been incorporated into the installer, so it works by default.

I'm wondering if the added complexity and maintenance is worth the change? The one issue we struggle with is UTF and filenames. I don't know if this change alleviates any of that by using the Windows API, but if it does it might be worth the "expense".

Ah okay, sorry then I didn't read properly. Will try it.

I think having issues with Unicode filenames is not really optimal though. I assume many people cannot name their pictures then how they would like to.

I don't see why the windows APIs would not properly support it. There are UTF-16 versions of the APIs available, and other applications support it as well.

But if it at least fixes the terminal popups, might be nice.

@kmilos
Copy link
Contributor

kmilos commented Mar 3, 2026

The one issue we struggle with is UTF and filenames.

#20435

@victoryforce
Copy link
Collaborator

@victoryforce did we change the launcher?

Not yet. And I agree with @ralfbrown that it would be more appropriate to make the necessary changes to upstream Lua than to implement workarounds when launch darktable.

static lua_CFunction init_funcs[]
= { dt_lua_init_glist, dt_lua_init_image, dt_lua_init_styles, dt_lua_init_print,
dt_lua_init_configuration, dt_lua_init_preferences, dt_lua_init_database, dt_lua_init_gui,
dt_lua_init_luastorages, dt_lua_init_tags, dt_lua_init_film, dt_lua_init_call,
dt_lua_init_view, dt_lua_init_events, dt_lua_init_init, dt_lua_init_widget,
dt_lua_init_lualib, dt_lua_init_gettext, dt_lua_init_guides, dt_lua_init_cairo,
dt_lua_init_password, dt_lua_init_util, NULL };

dt_lua_init_password, NULL };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to keep dt_lua_init_util

dt_lua_init_luastorages, dt_lua_init_tags, dt_lua_init_film, dt_lua_init_call,
dt_lua_init_view, dt_lua_init_events, dt_lua_init_init, dt_lua_init_widget,
dt_lua_init_lualib, dt_lua_init_gettext, dt_lua_init_guides, dt_lua_init_cairo,
dt_lua_init_password, dt_lua_init_windows, NULL };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above

@gerritsangel
Copy link
Contributor Author

@victoryforce did we change the launcher?

Not yet. And I agree with @ralfbrown that it would be more appropriate to make the necessary changes to upstream Lua than to implement workarounds when launch darktable.

I agree, but they did not want to change it. I asked on the mailing list (https://groups.google.com/g/lua-l/c/i7h5srLfxIY/m/kqwoFPmWCgAJ), but was declined.

@@ -175,7 +175,7 @@ LUA_API int lua_absindex (lua_State *L, int idx) {

LUA_API int lua_gettop (lua_State *L) {
return cast_int(L->top.p - (L->ci->func.p + 1));
}
}°
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably want to get rid of whatever that character is after the curly brace.

@wpferguson
Copy link
Member

@gerritsangel I read the thread and I can see their point of view, and I don't disagree with it. So now it falls back on us.

My thoughts

  • It's ~1K lines of code to maintain 👎
  • The API should be stable, so we shouldn't have to do any maintenance 👍
  • It's 1 file, 1 header file, and a few lines in data/luarc
  • We have no windows developers other than @gerritsangel 👎
  • Lua already works without it and we have a workaround if we don't want to do this or can't support it 👍
  • It will solve the popping windows problem 👍
  • It might solve the file name issues 👍
  • Most of the work is done 👍

@gerritsangel could you resolve the conflicts and my comments so that I can pull and test? Thanks

@TurboGit I can live with this if it survives testing, which I think it will

"imageio/imageio_tiff.c"
"libs/lib.c"
"views/view.c"
if(WIN32)
Copy link
Member

@wpferguson wpferguson Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you have to move this out of the GLOB and into the if(USE_LUA) section.. I tried to compile on Liinux and it tried to include lua/windows.c

After the GLOB command add

if(WIN32)
  list(APPEND SOURCE_FILES_LUA, "lua/windows.c")
endif(WIN32)

@wpferguson
Copy link
Member

@gerritsangel did you ever get this to compile? I keep choking on dt_lua_init_windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants