Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Use Zenity as a file chooser when in a Flatpak sandbox #1894

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rmnvgr
Copy link
Contributor

@rmnvgr rmnvgr commented May 24, 2021

Fixes #1887

Describe what the proposed change does

  • Add a new method to the app to open a file chooser
  • Call this method for all file choosers that need to access the host file system
  • If the game is in a Flatpak sandbox, spawn a zenity dialog to access the host file system, else use the in-game file chooser

@rmnvgr
Copy link
Contributor Author

rmnvgr commented Jun 7, 2021

@TheCycoONE I'm kinda stuck with it, I'm facing two issues:

  • After selecting the folder, the game is stuck. If I close the window, the game restarts itself and loads fine.
  • The mouse is captured in the game window, preventing it from going to the zenity dialog. I found the app.video:setCaptureMouse() method but the cursor is unable to appear in the dialog until it leaves the game's window.

Do you have any ideas to help me resolve them?

@lewri
Copy link
Member

lewri commented Jun 23, 2021

Ping @TheCycoONE

@TheCycoONE
Copy link
Member

TheCycoONE commented Aug 7, 2021

In swaywm I don't have a problem with the capture. I suspect I could solve it if I could reproduce - I think the function you need is ui:setMouseReleased(true); which should return the hardware cursor and stop capture.

The problem with the callback/exit is because the init() function which calls all this stuff is before the run method which sets the flag. Since you basically block the game you are not yet in the run loop when the directory is chosen.

The following worked for me:

diff --git a/CorsixTH/Lua/app.lua b/CorsixTH/Lua/app.lua
index 47b671f8..52a9e4db 100644
--- a/CorsixTH/Lua/app.lua
+++ b/CorsixTH/Lua/app.lua
@@ -85,6 +85,7 @@ end
 
 function App:init()
   -- App initialisation 1st goal: Get the loading screen up
+  self.running = true
 
   print("")
   print("")
@@ -1027,7 +1028,9 @@ function App:run()
     local yield = coroutine.yield
     local dispatch = app.dispatch
     local repaint = true
-    while app.running do
+    local first = true
+    while app.running or first do
+      first = false
       repaint = dispatch(app, yield(repaint))
     end
   end)
@@ -1037,7 +1040,6 @@ function App:run()
     SDL.limitFPS(false)
   end
 
-  self.running = true
   do
     local num_iterations = 0
     self.resetInfiniteLoopChecker = function()
@@ -1104,6 +1106,7 @@ function App:run()
       -- might not otherwise be drawn for a while.
       pcall(self.drawFrame, self)
     end
+    self.running = true
     return self:run()
   end
 end

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

Successfully merging this pull request may close these issues.

Use File chooser portal
3 participants