From: Axel S. <si...@co...> - 2009-04-27 19:48:15
|
Mon Apr 27 15:46:38 EDT 2009 Axe...@en... * Fix drawWindowGetPointer, trac #802. hunk ./gtk/Graphics/UI/Gtk/Gdk/DrawWindow.chs.pp 75 + drawWindowGetPointerPos, hunk ./gtk/Graphics/UI/Gtk/Gdk/DrawWindow.chs.pp 475 - --- | Obtains the current pointer position and modifier state. +-- Superseded by 'drawWindowGetPointerPos', won't be removed. +-- Obtains the current pointer position and modifier state. hunk ./gtk/Graphics/UI/Gtk/Gdk/DrawWindow.chs.pp 503 +-- | Obtains the current pointer position and modifier state. +-- +-- * The position is +-- given in coordinates relative to the given window. +-- [_$_] +-- * The return value is @(Just win, x, y, mod)@ where @win@ is the +-- window over which the mouse currently resides and @mod@ denotes +-- the keyboard modifiers currently being depressed. +-- +-- * The return value is @Nothing@ for the window if the mouse cursor is [_$_] +-- not over a known window. +-- +drawWindowGetPointerPos :: DrawWindowClass self => self + -> IO (Maybe DrawWindow, Int, Int, [Modifier]) +drawWindowGetPointerPos self = + alloca $ \xPtr -> alloca $ \yPtr -> alloca $ \mPtr -> do + winPtr <- {# call gdk_window_get_pointer #} (toDrawWindow self) + xPtr yPtr mPtr + x <- peek xPtr + y <- peek yPtr + m <- peek mPtr + mWin <- if winPtr==nullPtr then return Nothing else liftM Just $ + makeNewGObject mkDrawWindow (return winPtr) + return (mWin, fromIntegral x, fromIntegral y, toFlags (fromIntegral m)) + + |