| Maintainer | Toshio Ito <debug.ito@gmail.com> |
|---|---|
| Safe Haskell | None |
| Language | Haskell2010 |
WildBind.X11
Description
This module exports a FrontEnd for X11 environments.
- withFrontEnd :: (XKeyInput i, Describable i, Ord i) => (FrontEnd ActiveWindow i -> IO a) -> IO a
- class XKeyInput k where
- data Window
- type ActiveWindow = Window
- winInstance :: Window -> Text
- winClass :: Window -> Text
- winName :: Window -> Text
- data XKeyEvent = XKeyEvent {}
- data XMod
- data KeyEventType
- class ToXKeyEvent k where
- press :: ToXKeyEvent k => k -> XKeyEvent
- release :: ToXKeyEvent k => k -> XKeyEvent
- shift :: ToXKeyEvent k => k -> XKeyEvent
- ctrl :: ToXKeyEvent k => k -> XKeyEvent
- alt :: ToXKeyEvent k => k -> XKeyEvent
- super :: ToXKeyEvent k => k -> XKeyEvent
- addXMod :: ToXKeyEvent k => XMod -> k -> XKeyEvent
- data X11Front k
- withX11Front :: (X11Front k -> IO a) -> IO a
- makeFrontEnd :: (XKeyInput k, Describable k, Ord k) => X11Front k -> FrontEnd ActiveWindow k
- defaultRootWindow :: X11Front k -> Window
X11 front-end
withFrontEnd :: (XKeyInput i, Describable i, Ord i) => (FrontEnd ActiveWindow i -> IO a) -> IO a Source #
Initialize and obtain FrontEnd for X11, and run the given
action.
The X11 FrontEnd watches and provides ActiveWindow as the
front-end state. ActiveWindow keeps information about the window
currently active. As for the input type i, this FrontEnd gets
keyboard events from the X server.
CAVEATS
Code using this function must be compiled
with -threaded option enabled in ghc. Otherwise, it aborts.
Because this FrontEnd currently uses XGrabKey(3) to get the
input, it may cause some weird behavior such as:
- Every input event makes the active window lose focus temporarily. This may result in flickering cursor, for example. See also: https://stackoverflow.com/questions/15270420/
- Key input is captured only while the first grabbed key is
pressed. For example, if
(release xK_a)and(release xK_b)are bound, and you input(press xK_a),(press xK_b),(release xK_a),(release xK_b), the last(release xK_b)is NOT captured because key grab ends with(release xK_a).
class XKeyInput k where Source #
Class of data types that can be handled by X11. The data type can tell X11 to grab key with optional modifiers, and it can be extracted from a X11 Event object.
Since: 0.2.0.0
Minimal complete definition
Methods
toKeySym :: k -> KeySym Source #
Get the X11 keysym for this input.
toModifierMasks :: KeyMaskMap -> k -> NonEmpty KeyMask Source #
Get modifer masks to grab the keysym. The grab action is repeated for all modifier masks. By default, it just returns 0.
fromKeyEvent :: KeyMaskMap -> KeyEventType -> KeySym -> KeyMask -> Maybe k Source #
Create the input object from a key event type, a keysym and a modifier (got from XEvent.)
Instances
| XKeyInput NumPadUnlocked Source # | This input event captures the |
| XKeyInput NumPadLocked Source # | This input event captures the |
| XKeyInput XKeyEvent Source # |
|
| (XKeyInput a, XKeyInput b) => XKeyInput (Either a b) Source # |
|
Windows in X11
Information about window. You can inspect properties winInstance
and winClass by wmctrl command.
$ wmctrl -lx 0x01400004 -1 xfce4-panel.Xfce4-panel mydesktop xfce4-panel 0x01800003 -1 xfdesktop.Xfdesktop mydesktop desktop 0x03800004 0 xfce4-terminal.Xfce4-terminal mydesktop Terminal - toshio@mydesktop - byobu 0x03a000a7 0 emacs.Emacs23 mydesktop emacs@mydesktop 0x03e010fc 0 Navigator.Firefox mydesktop debug-ito (Toshio Ito) - Mozilla Firefox 0x02600003 0 totem.Totem mydesktop Movie Player
In the above example, the third column shows winInstance.winClass.
type ActiveWindow = Window Source #
Use this type especially when the Window is active.
Getters
winInstance :: Window -> Text Source #
name of the application instance (part of WM_CLASS property)
Keys in X11
High-level X11 key event.
Since: 0.2.0.0
Constructors
| XKeyEvent | |
Fields
| |
X11 key modifiers.
Since: 0.2.0.0
data KeyEventType Source #
Whether the key is pressed or released.
Since: 0.2.0.0
Constructors
| KeyPress | |
| KeyRelease |
Instances
class ToXKeyEvent k where Source #
Something that can converted to XKeyEvent.
Since: 0.2.0.0
Minimal complete definition
Methods
toXKeyEvent :: k -> XKeyEvent Source #
Instances
| ToXKeyEvent KeySym Source # | |
| ToXKeyEvent XKeyEvent Source # | |
| (ToXKeyEvent a, ToXKeyEvent b) => ToXKeyEvent (Either a b) Source # | |
Setters
press :: ToXKeyEvent k => k -> XKeyEvent Source #
Set KeyPress to xKeyEventType.
Since: 0.2.0.0
release :: ToXKeyEvent k => k -> XKeyEvent Source #
Set KeyRelease to xKeyEventType.
Since: 0.2.0.0
shift :: ToXKeyEvent k => k -> XKeyEvent Source #
Add Shift modifier to xKeyEventMods.
Since: 0.2.0.0
ctrl :: ToXKeyEvent k => k -> XKeyEvent Source #
Add Ctrl modifier to xKeyEventMods.
Since: 0.2.0.0
alt :: ToXKeyEvent k => k -> XKeyEvent Source #
Add Alt modifier to xKeyEventMods.
Since: 0.2.0.0
super :: ToXKeyEvent k => k -> XKeyEvent Source #
Add Super modifier to xKeyEventMods.
Since: 0.2.0.0
addXMod :: ToXKeyEvent k => XMod -> k -> XKeyEvent Source #
Add a XMod to xKeyEventMods.
Since: 0.2.0.0
X11Front
The X11 front-end. k is the input key type.
This is the implementation of the FrontEnd given by
withFrontEnd function. With this object, you can do more advanced
actions. See WildBind.X11.Emulate.
X11Front is relatively low-level interface, so it's more likely
for this API to change in the future than FrontEnd.
Since: 0.2.0.0
withX11Front :: (X11Front k -> IO a) -> IO a Source #
Same as withFrontEnd, but it creates X11Front. To create
FrontEnd, use makeFrontEnd.
Since: 0.2.0.0
makeFrontEnd :: (XKeyInput k, Describable k, Ord k) => X11Front k -> FrontEnd ActiveWindow k Source #
defaultRootWindow :: X11Front k -> Window Source #
Get the default root window.
Since: 0.2.0.0