-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | X11-specific implementation for WildBind
--   
--   X11-specific implementation for WildBind. See
--   <a>https://github.com/debug-ito/wild-bind</a>
@package wild-bind-x11
@version 0.1.0.7


-- | <b>This is an internal module. Package users should not rely on
--   this.</b>
module WildBind.X11.Internal.Window

-- | Information about window. You can inspect properties
--   <a>winInstance</a> and <a>winClass</a> by <tt>wmctrl</tt> command.
--   
--   <pre>
--   $ 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
--   </pre>
--   
--   In the above example, the third column shows
--   <tt>winInstance.winClass</tt>.
data Window

-- | Use this type especially when the <a>Window</a> is active.
type ActiveWindow = Window

-- | An empty Window instance used for fallback and/or default value.
emptyWindow :: Window

-- | name of the application instance (part of <tt>WM_CLASS</tt> property)
winInstance :: Window -> Text

-- | name of the application class (part of <tt>WM_CLASS</tt> property)
winClass :: Window -> Text

-- | what's shown in the title bar
winName :: Window -> Text

-- | Get currently active <a>Window</a>.
getActiveWindow :: Display -> IO ActiveWindow
instance GHC.Show.Show WildBind.X11.Internal.Window.Window
instance GHC.Classes.Ord WildBind.X11.Internal.Window.Window
instance GHC.Classes.Eq WildBind.X11.Internal.Window.Window


-- | <b>This is an internal module. End-users should not rely on it.</b>
--   
--   WildBind.X11 module receives some notification events to update the
--   current state of the desktop (usually it is the active window).
--   However, there are some problems in updating the state every time it
--   receives a notification event.
--   
--   <ul>
--   <li>Notification events can come too fast. It can make siginificant
--   overhead to the system.</li>
--   <li>The active window obtained at the very moment a notification
--   arrives is often unstable. It can become invalid soon. In addition,
--   Xlib is notorious for being bad at handling that kind of exceptions
--   (it just crashes the entire process and it's practically impossible to
--   catch the exceptions).</li>
--   </ul>
--   
--   Personally, I have experienced even weirder behaviors when I did some
--   X11 operations at arrivals of notification events.
--   
--   <ul>
--   <li>Sometimes I could not obtain the current active window. Instead, I
--   ended up with getting the previous active window.</li>
--   <li>Sometimes GetWindowProperty blocked forever.</li>
--   </ul>
--   
--   So, as a workaround, we debounce the raw notification events and
--   generate a ClientMessage X11 event. When we get the ClientMessage, we
--   update the state.
module WildBind.X11.Internal.NotificationDebouncer
data Debouncer

-- | Create a Debouncer and run the specified action.
withDebouncer :: Display -> (Debouncer -> IO a) -> IO a

-- | Notify the <a>Debouncer</a> that a notification event arrives. After a
--   while, the <a>Debouncer</a> emits a ClientMessage X11 event.
notify :: Debouncer -> IO ()

-- | The Xlib EventMask for sending the ClientMessage. You have to select
--   this mask by <tt>selectInput</tt> function to receive the
--   ClientMessage.
xEventMask :: EventMask

-- | Check if the given event is the debounced ClientMessage X11 event.
isDebouncedEvent :: Debouncer -> XEventPtr -> IO Bool


-- | <b>This is an internal module. Package users should not rely on
--   this.</b>
module WildBind.X11.Internal.Key

-- | Convertible to/from Xlib's <tt>KeySym</tt>
--   
--   <pre>
--   fromKeySym . toKeySym == Just
--   </pre>
class KeySymLike k
fromKeySym :: KeySymLike k => KeySym -> Maybe k
toKeySym :: KeySymLike k => k -> KeySym

-- | Extract the <a>KeySymLike</a> associated with the XEvent.
xEventToKeySymLike :: KeySymLike k => XEventPtr -> MaybeT IO k

-- | Convertible into a set of Modifiers.
class ModifierLike k

-- | Grab the specified key on the specified window. The key is captured
--   from now on, so the window won't get that.
xGrabKey :: (KeySymLike k, ModifierLike k) => Display -> Window -> k -> IO ()

-- | Release the grab on the specified key.
xUngrabKey :: (KeySymLike k, ModifierLike k) => Display -> Window -> k -> IO ()
instance GHC.Enum.Enum WildBind.X11.Internal.Key.ModifierKey
instance GHC.Enum.Bounded WildBind.X11.Internal.Key.ModifierKey
instance GHC.Show.Show WildBind.X11.Internal.Key.ModifierKey
instance GHC.Classes.Ord WildBind.X11.Internal.Key.ModifierKey
instance GHC.Classes.Eq WildBind.X11.Internal.Key.ModifierKey
instance WildBind.X11.Internal.Key.KeySymLike Graphics.X11.Types.KeySym
instance WildBind.X11.Internal.Key.KeySymLike WildBind.Input.NumPad.NumPadUnlocked
instance WildBind.X11.Internal.Key.KeySymLike WildBind.Input.NumPad.NumPadLocked
instance WildBind.X11.Internal.Key.ModifierLike WildBind.Input.NumPad.NumPadUnlocked
instance WildBind.X11.Internal.Key.ModifierLike WildBind.Input.NumPad.NumPadLocked


-- | This module exports a <a>FrontEnd</a> for X11 environments.
module WildBind.X11

-- | Initialize and obtain <a>FrontEnd</a> for X11, and run the given
--   action.
--   
--   The X11 <a>FrontEnd</a> watches and provides <a>ActiveWindow</a> as
--   the front-end state. <a>ActiveWindow</a> keeps information about the
--   window currently active. As for the input type <tt>i</tt>,
--   <a>NumPadUnlocked</a> and <a>NumPadLocked</a> are currently supported.
--   
--   Code using this function must be compiled <b>with <tt>-threaded</tt>
--   option enabled</b> in <tt>ghc</tt>. Otherwise, it aborts.
--   
--   Note that bound actions are executed when the key is released. That
--   way, you can deliver events to the window that originally has the
--   keyboard focus.
withFrontEnd :: (KeySymLike i, ModifierLike i, Describable i) => (FrontEnd ActiveWindow i -> IO a) -> IO a

-- | Information about window. You can inspect properties
--   <a>winInstance</a> and <a>winClass</a> by <tt>wmctrl</tt> command.
--   
--   <pre>
--   $ 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
--   </pre>
--   
--   In the above example, the third column shows
--   <tt>winInstance.winClass</tt>.
data Window

-- | Use this type especially when the <a>Window</a> is active.
type ActiveWindow = Window

-- | name of the application instance (part of <tt>WM_CLASS</tt> property)
winInstance :: Window -> Text

-- | name of the application class (part of <tt>WM_CLASS</tt> property)
winClass :: Window -> Text

-- | what's shown in the title bar
winName :: Window -> Text
