-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new keymap/conditional API, now supports device conditionals
- Loading branch information
1 parent
cae3135
commit 6f3e1a5
Showing
6 changed files
with
146 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from ..xorg import get_active_window_wm_class | ||
|
||
class KeyContext: | ||
def __init__(self, device_name): | ||
self._device_name = device_name | ||
self._wm_class = None | ||
|
||
def get_wm_class(self): | ||
# cache this, think it might be expensive | ||
self._wm_class = self._wm_class or get_active_window_wm_class() | ||
return self._wm_class | ||
|
||
def get_device_name(self): | ||
return self._device_name | ||
|
||
wm_class = property(fget=get_wm_class) | ||
device_name = property(fget=get_device_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class Keymap: | ||
def __init__(self, name, mappings): | ||
self.name = name | ||
self.mappings = mappings | ||
self.conditional = None | ||
|
||
def __contains__(self, key): | ||
return key in self.mappings | ||
|
||
def __getitem__(self, item): | ||
return self.mappings[item] | ||
|
Oops, something went wrong.