Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from ... import Command
from ...batoceraPaths import CACHE, CONFIGS, SAVES, ensure_parents_and_open
from ...controller import Controller, generate_sdl_game_controller_config
from ...utils import vulkan
from ...utils import videoMode, vulkan
from ..Generator import Generator

if TYPE_CHECKING:
Expand Down Expand Up @@ -40,6 +40,11 @@ def getHotkeysContext(self) -> HotkeysContext:
def generate(self, system, rom, playersControllers, metadata, guns, wheels, gameResolution):
AzaharGenerator.writeAZAHARConfig(CONFIGS / "azahar-emu" / "qt-config.ini", system, playersControllers)

# windows position is handled by coordonnates by the application (xorg) or the windows manager (wayland)
screens = videoMode.getScreensInfos(system.config)
videoMode.configureWindow(screens, identifier="azahar", output="primary")
videoMode.configureWindow(screens, identifier="azahar", title="*Secondary Window*", output="backglass", toogleFullscreen=True)

commandArray = ['/usr/bin/azahar', rom]

return Command.Command(array=commandArray, env={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ def generate(self, system, rom, playersControllers, metadata, guns, wheels, game
with configFileName.open("w") as toml_file:
toml.dump(config, toml_file)

# windows position is handled by coordonnates by the application (xorg) or the windows manager (wayland)
screens = videoMode.getScreensInfos(system.config)
videoMode.configureWindow(screens, identifier="net.kuribo64.melonDS", title="*w1*", output="primary")
videoMode.configureWindow(screens, identifier="net.kuribo64.melonDS", title="*w2*", output="backglass")

commandArray = ["/usr/bin/melonDS", "-f", rom]
return Command.Command(
array=commandArray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ def configurePlayfield(vpinballSettings: CaseSensitiveConfigParser, screens: lis
vpinballSettings.set("Player", "PlayfieldWndY", str(screens[playFieldScreen]["y"]))
vpinballSettings.set("Player", "PlayfieldWidth", str(screens[playFieldScreen]["width"]))
vpinballSettings.set("Player", "PlayfieldHeight", str(screens[playFieldScreen]["height"]))
# windows position is handled by coordonnates by the application (xorg) or the windows manager (wayland)
videoMode.configureWindow(screens, identifier="VPinballX_BGFX", title="Visual Pinball Player", output="backglass" if playFieldScreen == 1 else "primary")

def getDMDWindowSize(system: Emulator, gameResolution: Resolution):
if not system.isOptSet("vpinball_dmdsize"):
Expand Down Expand Up @@ -115,6 +117,8 @@ def configureBackglass(vpinballSettings: CaseSensitiveConfigParser, backglass_co
vpinballSettings.set("Backglass", "BackglassWndY", str(screens[backglassScreen]["y"]))
vpinballSettings.set("Backglass", "BackglassWidth", str(screens[backglassScreen]["width"]))
vpinballSettings.set("Backglass", "BackglassHeight", str(screens[backglassScreen]["height"]))
# windows position is handled by coordonnates by the application (xorg) or the windows manager (wayland)
videoMode.configureWindow(screens, identifier="VPinballX_BGFX", title="Visual Pinball Backglass", output="backglass" if backglassScreen == 1 else "primary")
else:
if backglass_config == "topright_small":
width = small
Expand All @@ -140,6 +144,9 @@ def configureBackglass(vpinballSettings: CaseSensitiveConfigParser, backglass_co
vpinballSettings.set("Backglass", "BackglassWndY", ConvertToPixel(gameResolution["height"], y))
vpinballSettings.set("Backglass", "BackglassWidth", ConvertToPixel(gameResolution["width"], width))
vpinballSettings.set("Backglass", "BackglassHeight", ConvertToPixel(gameResolution["height"], height))
# windows position is handled by coordonnates by the application (xorg) or the windows manager (wayland)
# this position by coordonates should not work for now. to be done correctly later.
videoMode.configureWindow(screens, identifier="VPinballX_BGFX", title="Visual Pinball Backglass", output="backglass" if backglassScreen == 1 else "primary")

# Extra_windows (backglass)
# VideogetCurrentResolution to convert from percentage to pixel value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def getScreensInfos(config: SystemConfig) -> list[ScreenInfo]:
vo1 = getCurrentOutput()
resolution1 = getCurrentResolution()
res.append({
"name": vo1,
"width": resolution1["width"],
"height": resolution1["height"],
"x": 0,
Expand All @@ -85,6 +86,7 @@ def getScreensInfos(config: SystemConfig) -> list[ScreenInfo]:
try:
resolution2 = getCurrentResolution(vo2)
res.append({
"name": vo2,
"width": resolution2["width"],
"height": resolution2["height"],
"x": resolution1["width"],
Expand All @@ -107,6 +109,7 @@ def getScreensInfos(config: SystemConfig) -> list[ScreenInfo]:
try:
resolution3 = getCurrentResolution(vo3)
res.append({
"name": vo3,
"width": resolution3["width"],
"height": resolution3["height"],
# if resolution2 can't be determined, place screen3 where screen2 would be
Expand Down Expand Up @@ -233,3 +236,30 @@ def getAltDecoration(systemName: str, rom: str | Path, emulator: str) -> str:
return str(row[1])

return "0"

def configureWindow(screens, identifier=None, title=None, output=None, toogleFullscreen=None):
# default to the primary screen
output_name = ""
if output is not None:
output_name = screens[0]["name"]
if output == "backglass" and len(screens) >= 2:
output_name = screens[1]["name"]

params = ["/usr/bin/labwc-configure-window"]
if identifier is not None:
params.extend(["--identifier", identifier])
if title is not None:
params.extend(["--title", title])
if output is not None:
params.extend(["--output", output_name])
if toogleFullscreen is not None:
if toogleFullscreen:
params.extend(["--toggle-fullscreen", "true"])
else:
params.extend(["--toggle-fullscreen", "false"])
res = subprocess.run(params)


_logger.info("configuring window %s", params)
if res.returncode != 0:
_logger.error("configuring window %s / %s failed", identifier, title)
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ case "${ACTION}" in
"getDisplayMode")
echo "drm"
;;

"configureWindow")
# not needed on drm
;;

*)
f_usage
;;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ case "${ACTION}" in
;;
"getDisplayMode")
echo "tvservice"
;;
;;

"configureWindow")
# not needed on tvservice
;;

*)
f_usage
>&2 echo "error: invalid command ${ACTION}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,52 +491,6 @@ case "${ACTION}" in
s#\s*<output>.*</output># <output>'"${BACKGLASS_OUT}"'</output>#
} }' "${RC_XML}"

# Set the main azahar window to the primary output
if [ -n "${PRIMARY_OUT}" ]; then
_log "Setting main azahar window to output: ${PRIMARY_OUT}"
sed -i -e '/<windowRule identifier="azahar"/,/\/windowRule>/ { /<action name="MoveToOutput">/ {
n
s#\s*<output>.*</output># <output>'"${PRIMARY_OUT}"'</output>#
} }' "${RC_XML}"
fi

# Set the azahar Secondary Window to the secondary output
AZAHAR_SECONDARY_OUT=""
if [ -n "${SECONDARY_OUT}" ]; then
_log "Setting azahar Secondary Window to output: ${SECONDARY_OUT}"
AZAHAR_SECONDARY_OUT="${SECONDARY_OUT}"
else
_log "No secondary output. Clearing azahar Secondary Window output rule."
fi

sed -i -e '/<windowRule.*identifier="azahar".*title=".*Secondary Window.*"/,/\/windowRule>/ { /<action name="MoveToOutput">/ {
n
s#\s*<output>.*</output># <output>'"${AZAHAR_SECONDARY_OUT}"'</output>#
} }' "${RC_XML}"

# Set the primary melonDS window [w1] to the primary output
if [ -n "${PRIMARY_OUT}" ]; then
_log "Setting melonDS [w1] window to output: ${PRIMARY_OUT}"
sed -i -e '/<windowRule.*identifier="net.kuribo64.melonDS".*title="\*w1\*"/,/\/windowRule>/ { /<action name="MoveToOutput">/ {
n
s#\s*<output>.*</output># <output>'"${PRIMARY_OUT}"'</output>#
} }' "${RC_XML}"
fi

# Set the secondary melonDS window [w2] to the secondary output
MELONDS_SECONDARY_OUT=""
if [ -n "${SECONDARY_OUT}" ]; then
_log "Setting melonDS [w2] window to output: ${SECONDARY_OUT}"
MELONDS_SECONDARY_OUT="${SECONDARY_OUT}"
else
_log "No secondary output. Clearing melonDS [w2] window output rule."
fi

sed -i -e '/<windowRule.*identifier="net.kuribo64.melonDS".*title="\*w2\*"/,/\/windowRule>/ { /<action name="MoveToOutput">/ {
n
s#\s*<output>.*</output># <output>'"${MELONDS_SECONDARY_OUT}"'</output>#
} }' "${RC_XML}"

# Set batocera-flash-screen (OSD) to the primary output
if [ -n "${PRIMARY_OUT}" ]; then
_log "Setting batocera-flash-screen (OSD) window to output: ${PRIMARY_OUT}"
Expand Down Expand Up @@ -815,6 +769,9 @@ case "${ACTION}" in
"supportSystemReflection")
exit 0
;;
"configureWindow")
labwc-configure-window $*
;;
*)
f_usage
exit 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ case "${ACTION}" in
echo "sway"
;;

"configureWindow")
# not implemented (see labwc if needed)
;;

*)
f_usage
echo "error: invalid command ${ACTION}" >&2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,10 @@ case "${ACTION}" in
echo "openbox"
;;

"configureWindow")
# nothing to do, on xorg, configuring windows is done at application level
;;

*)
f_usage
>&2 echo "error: invalid command ${ACTION}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,6 @@
<output></output>
</action>
</windowRule>
<windowRule identifier="azahar">
<action name="MoveToOutput">
<output></output>
</action>
</windowRule>
<windowRule identifier="azahar" title="*Secondary Window*">
<action name="MoveToOutput">
<output></output>
</action>
<action name="ToggleFullscreen" />
</windowRule>
<windowRule identifier="net.kuribo64.melonDS" title="*w1*">
<action name="MoveToOutput">
<output></output>
</action>
</windowRule>
<windowRule identifier="net.kuribo64.melonDS" title="*w2*">
<action name="MoveToOutput">
<output></output>
</action>
</windowRule>
<windowRule identifier="pcmanfm">
<action name="ToggleFullscreen" />
</windowRule>
Expand Down
Loading
Loading