windows-terminal-quake icon indicating copy to clipboard operation
windows-terminal-quake copied to clipboard

Oem5 key works on Windows but not on plasma.

Open nabaxo opened this issue 6 months ago • 9 comments

Since I change between keyboard layouts, I'd like it if win+[whatever key that is under the escape] would work.

Oem3/Oemtilde key works on both Windows and Linux, Oem5/OemPipe however, does not work in Plasma.

nabaxo avatar Jun 16 '25 14:06 nabaxo

Thank you for reaching out!

Could you try the GUI, see what it shows when you press the desired hotkey?

Image

flyingpie avatar Jun 16 '25 16:06 flyingpie

I get Oemtilde, even in Swedish layout, and that's wrong. It should be OemPipe when I'm in Swedish layout.

Image The arrow points to when I press win+§ in Swedish layout.

nabaxo avatar Jun 16 '25 23:06 nabaxo

Does it work when you use "OemPipe"?

Also, can you show me the exact keyboard layout you're using, since there are multiple Swedish ones?

flyingpie avatar Jun 16 '25 23:06 flyingpie

It does not work when I use OemPipe and this is the swedish keyboard layout I use,just the standard one AFAIK: https://kbdlayout.info/KBDSW/

nabaxo avatar Jun 17 '25 05:06 nabaxo

Okay, I think that I've found the issue. I need to investigate a bit more for a proper fix, but I made a release that contains a temporary bugfix: https://github.com/flyingpie/windows-terminal-quake/releases/tag/vDevSE

Could you check whether that version fixes it for you, so I know that my repro was correct?

The GUI still doesn't work correctly, but you can use the "OemPipe" now in the config:

{
	"Apps": [{
		"Name": "WezTerm",
		"Hotkeys": [{ "Modifiers": "Super", "Key": "OemPipe" }]
	}]
}

flyingpie avatar Jun 17 '25 10:06 flyingpie

Sorry, just got around to this. Now both "Key": "Oem5" and "Key": "OemPipe" work! 👌

nabaxo avatar Jun 17 '25 20:06 nabaxo

Thank you for testing! I'll report back when I investigated a bit further on how to handle this properly, including fixing the GUI.

flyingpie avatar Jun 17 '25 21:06 flyingpie

Update: I've figured out what is causing this, and it's lots of fun.

I'll put some of this in the upcoming PR that deals with this.

When you define a shortcut in WTQ, it's done through "key codes" or "virtual key codes".

These codes are used to logically identify a key on a keyboard. It basically is the key's name on a US ANSI keyboard, disregarding configured keyboard layout.

https://github.com/flyingpie/windows-terminal-quake/blob/master/src/10-Core/Wtq/Configuration/Keys.cs

They uniquely identify each key, which is especially useful when dealing with multiple keys that output the same character. Like "1", which exists as part of the alphanumeric set (key code "D1", 0x31), but also on the numpad ("Numpad1", 0x61).

Also useful, is that since these are layout-independent, the physical key that's mapped does not change, when the keyboard layout changes. Though that could also be considered a con, depending on who you ask I guess.

Now, on KDE Plasma, shortcuts are defined by using (keyboard layout dependent) key characters, not key codes.

In WTQ settings, we're using e.g. "Oemtilde" to refer to the key under the "Esc". But when we then go to define the actual shortcut with Plasma (KWin), we need to convert this to a key character (like "`" or "§").

This is currently done using a hard-coded mapping, that is basically just the US ANSI keyboard layout on top of the virtual key codes.

https://github.com/flyingpie/windows-terminal-quake/blob/master/src/20-Services/Wtq.Services.KWin/Mapping.cs#L31

That breaks when the layout is not in fact US ANSI-like. Such as Swedish. I tweaked the mapping to output "§" instead of "`" for the "Oemtilde" code, to verify we were looking at the same issue.

https://github.com/flyingpie/windows-terminal-quake/blob/bugfix/se-pipe-keycode/src/20-Services/Wtq.Services.KWin/Mapping.cs#L112

I've been trying to make this mapping not-hard-coded, base it on the actual keyboard layout in use. On Windows, that's fairly straight-forward. On Linux + X11, that's still fairly easy. On Wayland, it's a really hard problem.

As an alternative, which may even be preferable in some ways, I'm looking into just using the key characters in the settings, and basically not doing the key codes at all (in addition to key codes, I mean as an alternative way to configure hotkeys).

That has been quite successful so far, also got that to work on Windows.

Before:

{
  "Apps": [{
    "Hotkeys": [{ "Modifiers": "...", "Key": "Oemtilde" }]
  }]
}

After:

{
  "Apps": [{
    "Hotkeys": [{ "Modifiers": "...", "KeyChar": "§" }]
  }]
}

Pros:

  • Easier to configure, since now it's just "§" instead of "Oemtilde", which on layouts like this one don't make sense
  • Looks nicer in the GUI too, corresponds closer to what you're actually pressing

Cons:

  • When to choose what option in the GUI? That seems not straight forward, and just always using KeyChar doesn't work, as some keys don't have a char (like "F1")
  • Some keys do have a char, but still can't use it, like "Numpad1", which is "Num+1" in KWin.

So still some work to do, but lots learned as well!

flyingpie avatar Jun 20 '25 00:06 flyingpie

Thanks for the write up!

nabaxo avatar Jun 21 '25 08:06 nabaxo

@nabaxo Well that was quite the rabbit hole!

I've merged everything related to this into master, and a release (with a proper fix) is available in the vNext release.

It's basically what I already mentioned, that there is now support for "key characters", as an alternative to "key codes".

Through the settings file, this looks like this

{
  "Apps": [{
    "Hotkeys": [{ "Modifiers": "Control", "KeyChar": "§" }]
    //                                     ^^^^^^^ "KeyChar" instead of "Key"
  }]
}

And through the GUI, it looks like this: Image

I'm testing and polishing the coming days, and hopefully determine that a stable release can be made.

If you're up for it, could you take the prerelease for a spin?

flyingpie avatar Jun 29 '25 17:06 flyingpie

I mean, great work on getting the buttons to work! But it seems to have broken the core functionality of the app, which is, when I press the buttons, it just spawns a new window instead of doing the drop.

nabaxo avatar Jun 29 '25 21:06 nabaxo

Can you show me your current settings file?

Maybe also the log, that'd be helpful 🙂

flyingpie avatar Jun 29 '25 21:06 flyingpie

Well, here's my old one:

{
  "$schema": "wtq.schema.json",
  "Apps": [
    {
      "Name": "Wezterm",
      "Hotkeys": [
        {
          "Key": "Oem3",
          "Modifiers": "Super"
        },
        {
          "Key": "Oem5",
          "Modifiers": "Super"
        }
      ],
      "FileName": "wezterm",
      "ProcessName": "wezquake",
      "Arguments": "start --class=wezquake"
    }
  ],
  "AnimationTargetFps": 120,
  "HideOnFocusLost": "Never",
  "HorizontalScreenCoverage": 40,
  "VerticalScreenCoverage": 40,
  "AnimationDurationMs": 350,
  "AnimationTypeToggleOn": "EaseOutCubic",
  "AnimationTypeToggleOff": "EaseInQuart"
}

Here's the new one with the keychars instead:

{
	"$schema": "wtq.schema.json",
	"Apps": [
		{
			"Name": "Wezterm",
			"Hotkeys": [
				{
					"Modifiers": "Super",
					"KeyChar": "`"
				},
				{
					"Modifiers": "Super",
					"KeyChar": "§"
				}
			],
			"FileName": "wezterm",
			"ProcessName": "wezquake",
			"Arguments": "start --class=wezquake"
		}
	],
	"AnimationTargetFps": 120,
	"HideOnFocusLost": "Never",
	"HorizontalScreenCoverage": 40,
	"VerticalScreenCoverage": 40,
	"AnimationDurationMs": 350,
	"AnimationTypeToggleOn": "EaseOutCubic",
	"AnimationTypeToggleOff": "EaseInQuart"
}

nabaxo avatar Jun 29 '25 21:06 nabaxo

Also some logs perhaps?

flyingpie avatar Jun 29 '25 22:06 flyingpie

Oh and the log just keeps repeating:


23:59:42
INFORMATION
Wtq.Services.WtqWindowResolver
Using find-or-start process attach mode for app with options "Wezterm", looking for process (allow start new: False)

nabaxo avatar Jun 29 '25 22:06 nabaxo

Wait, here's some more:

00:03:35
INFORMATION
Wtq.Services.WtqWindowResolver
Using find-or-start process attach mode for app with options "Wezterm", looking for process (allow start new: False)
00:03:35
WARNING
Wtq.WtqApp|05ecf75c-758c-4296-9bf4-3490869f1030|Wezterm
App '"[App:Wezterm] <no process>"' is not attached, skipping further action
00:03:34
INFORMATION
Wtq.Services.WtqWindowResolver
Got no process for options "Wezterm", attempting to create one
00:03:34
INFORMATION
Wtq.Services.WtqWindowResolver
Using find-or-start process attach mode for app with options "Wezterm", looking for process (allow start new: True)
00:03:34
INFORMATION
Wtq.WtqApp|05ecf75c-758c-4296-9bf4-3490869f1030|Wezterm
Opening app '"[App:Wezterm] <no process>"'
00:03:34
INFORMATION
Wtq.Services.KWin.DBus.WtqDBusObject
"OnPressShortcutAsync"("Super", "", "Oem3")
00:03:33
WARNING
Wtq.WtqApp|05ecf75c-758c-4296-9bf4-3490869f1030|Wezterm
Attempted to close inactive app "[App:Wezterm] <no

nabaxo avatar Jun 29 '25 22:06 nabaxo

Could you try the "wezterm-gui" version, like so:

{
  "Apps": [
    {
      "FileName": "wezterm-gui"
//                        ^^^^
    }
  ]
}

flyingpie avatar Jun 29 '25 22:06 flyingpie

Bingo, that was it!

nabaxo avatar Jun 29 '25 22:06 nabaxo

Woohoo, thank you for testing 🙂

flyingpie avatar Jun 29 '25 22:06 flyingpie

No worries! You might wanna fix the json schema for the next release too.

Image

nabaxo avatar Jun 29 '25 22:06 nabaxo

And with that said, thanks a lot for dealing with this. Much appreciated! :heart:

nabaxo avatar Jun 29 '25 22:06 nabaxo

Great points, thank you so much! :heart:

flyingpie avatar Jun 29 '25 22:06 flyingpie

Funnily enough, now super+§ won't work in windows.

nabaxo avatar Jul 17 '25 07:07 nabaxo

Can you show me your settings?

I've tested using the Swedish keyboard layout, and it seems to work for me.

Image

With these settings:

{
	"Apps": [
		{
			"Name": "SystemInformer",
			"Hotkeys": [{ "Modifiers": "Super", "KeyChar": "§" }],
			"FileName": "wezterm-gui",
			"OffScreenLocations": ["Below"]
		}
	]
}

I did notice that that particular hotkey seems to have some side effects, like being the default for Windows Terminal's own Quake mode, and it messes with my language settings somewhy.

flyingpie avatar Jul 17 '25 08:07 flyingpie

Here's my settings:

  "Apps": [
    {
      "Name": "Wezterm",
      "Hotkeys": [
        {
          "Modifiers": "Super",
          "KeyChar": "`"
        },
        {
          "Modifiers": "Super",
          "KeyChar": "§"
        }
      ],
      "FileName": "C:\\Program Files\\WezTerm\\wezterm-gui.exe",
      "ProcessName": "wezterm-gui",
      "VerticalScreenCoverage": 50
    }
  ],

nabaxo avatar Jul 17 '25 12:07 nabaxo

Is anything happening in the logs? Could you drop them here?

flyingpie avatar Jul 17 '25 13:07 flyingpie

Just checked, it correctly does this on win+`:

09:38:00 | Information | Wtq.WtqApp\|Wezterm | Closing app '"[App:Wezterm] WindowHandle:11820 ProcessId:11820 ProcessName:wezterm-gui Title:MINGW64:/c/Users/r04334 WindowClass:org.wezfurlong.wezterm Rect:{X=-3072,Y=-1071,Width=2304,Height=1080} IsMainWindow:True"'
09:38:00 | Information | Wtq.WtqApp\|Wezterm | Opening app '"[App:Wezterm] WindowHandle:11820 ProcessId:11820 ProcessName:wezterm-gui Title:MINGW64:/c/Users/r04334 WindowClass:org.wezfurlong.wezterm Rect:{X=-3072,Y=-2251,Width=2304,Height=1080} IsMainWindow:True"'

but absolutely nothing on win+§.

nabaxo avatar Jul 18 '25 07:07 nabaxo

Oh and "Key": "Oem5" for § doesn't work either. But "key": "Oem3" for ` does.

nabaxo avatar Jul 18 '25 07:07 nabaxo

Are you doing all this on a Swedish layout, and weren't "§" and "`" the same keys?

Like, does it work if you manually configure it as "Win+`", on the same tilde-key-thing under the escape key?

flyingpie avatar Jul 18 '25 09:07 flyingpie

Ah, sorry for the confusion. When I switch to US layout, it works with both "key": "Oem3" and "keychar": "`"

When I switch to Swedish layout, no combination I've tested works.

nabaxo avatar Jul 18 '25 10:07 nabaxo