File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
src/Graphics/UI/FLTK/LowLevel/Base Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,9 @@ import Graphics.UI.FLTK.LowLevel.Dispatch
4141import qualified Data.Text as T
4242import Graphics.UI.FLTK.LowLevel.Hierarchy
4343import Graphics.UI.FLTK.LowLevel.Base.Widget
44+ import Graphics.UI.FLTK.LowLevel.RGBImage ()
45+ import Control.Exception (throwIO )
46+ import System.IO.Error (userError )
4447
4548#c
4649 enum WindowType {
@@ -320,7 +323,14 @@ instance (impl ~ ( IO (Maybe (Ref Image)))) => Op (GetIcon ()) WindowBase orig i
320323
321324{# fun Fl_Window_set_icon as setIcon' { id `Ptr () ', id `Ptr () ' } -> `() ' supressWarningAboutRes # }
322325instance (Parent a RGBImage , impl ~ (Maybe ( Ref a ) -> IO () )) => Op (SetIcon () ) WindowBase orig impl where
323- runOp _ _ win bitmap = withRef win $ \ winPtr -> withMaybeRef bitmap $ \ bitmapPtr -> setIcon' winPtr bitmapPtr
326+ runOp _ _ win rgbM = do
327+ case rgbM of
328+ Nothing -> withRef win $ \ winPtr -> setIcon' winPtr (castPtr nullPtr)
329+ Just rgb -> do
330+ copyIM <- copy (safeCast rgb :: Ref RGBImage ) (Nothing :: Maybe Size )
331+ case copyIM of
332+ Just copyI -> withRef win $ \ winPtr -> withRef copyI $ \ iPtr -> setIcon' winPtr iPtr
333+ Nothing -> throwIO (userError " Could not make a copy of icon image" )
324334
325335{# fun Fl_Window_shown as shown' { id `Ptr () ' } -> `Bool' toBool # }
326336instance (impl ~ ( IO (Bool ))) => Op (Shown () ) WindowBase orig impl where
You can’t perform that action at this time.
0 commit comments