wild-bind-x11-0.2.0.4: X11-specific implementation for WildBind

MaintainerToshio Ito <debug.ito@gmail.com>
Safe HaskellNone
LanguageHaskell2010

WildBind.X11

Contents

Description

This module exports a FrontEnd for X11 environments.

Synopsis

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

toKeySym, fromKeyEvent

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 KeyRelease event only. That way, you can deliver events to the window that originally has the keyboard focus.

XKeyInput NumPadLocked Source #

This input event captures the KeyRelease event only. That way, you can deliver events to the window that originally has the keyboard focus.

XKeyInput XKeyEvent Source #

fromKeyEvent always returns Just.

(XKeyInput a, XKeyInput b) => XKeyInput (Either a b) Source #

fromKeyEvent first tries to create Left (type a). If it fails, then it tries to create Right (type b).

Windows in X11

data Window Source #

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)

winClass :: Window -> Text Source #

name of the application class (part of WM_CLASS property)

winName :: Window -> Text Source #

what's shown in the title bar

Keys in X11

data XMod Source #

X11 key modifiers.

Since: 0.2.0.0

Constructors

Shift 
Ctrl 
Alt 
Super 

Instances

Bounded XMod Source # 
Enum XMod Source # 

Methods

succ :: XMod -> XMod #

pred :: XMod -> XMod #

toEnum :: Int -> XMod #

fromEnum :: XMod -> Int #

enumFrom :: XMod -> [XMod] #

enumFromThen :: XMod -> XMod -> [XMod] #

enumFromTo :: XMod -> XMod -> [XMod] #

enumFromThenTo :: XMod -> XMod -> XMod -> [XMod] #

Eq XMod Source # 

Methods

(==) :: XMod -> XMod -> Bool #

(/=) :: XMod -> XMod -> Bool #

Ord XMod Source # 

Methods

compare :: XMod -> XMod -> Ordering #

(<) :: XMod -> XMod -> Bool #

(<=) :: XMod -> XMod -> Bool #

(>) :: XMod -> XMod -> Bool #

(>=) :: XMod -> XMod -> Bool #

max :: XMod -> XMod -> XMod #

min :: XMod -> XMod -> XMod #

Show XMod Source # 

Methods

showsPrec :: Int -> XMod -> ShowS #

show :: XMod -> String #

showList :: [XMod] -> ShowS #

class ToXKeyEvent k where Source #

Something that can converted to XKeyEvent.

Since: 0.2.0.0

Minimal complete definition

toXKeyEvent

Methods

toXKeyEvent :: k -> XKeyEvent 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

data X11Front k Source #

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 #

Create FrontEnd from X11Front object.

Since: 0.2.0.0

defaultRootWindow :: X11Front k -> Window Source #

Get the default root window.

Since: 0.2.0.0