-- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte -- License : LGPL-2.1 -- Maintainer : Iñaki García Etxebarria #if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__)) #define ENABLE_OVERLOADING #endif module GI.Wnck.Functions ( -- * Methods -- ** pidReadResourceUsage #method:pidReadResourceUsage# pidReadResourceUsage , -- ** setClientType #method:setClientType# setClientType , -- ** setDefaultIconSize #method:setDefaultIconSize# setDefaultIconSize , -- ** setDefaultMiniIconSize #method:setDefaultMiniIconSize# setDefaultMiniIconSize , -- ** shutdown #method:shutdown# shutdown , -- ** xidReadResourceUsage #method:xidReadResourceUsage# xidReadResourceUsage , ) where import Data.GI.Base.ShortPrelude import qualified Data.GI.Base.ShortPrelude as SP import qualified Data.GI.Base.Overloading as O import qualified Prelude as P import qualified Data.GI.Base.Attributes as GI.Attributes import qualified Data.GI.Base.BasicTypes as B.Types import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr import qualified Data.GI.Base.GClosure as B.GClosure import qualified Data.GI.Base.GError as B.GError import qualified Data.GI.Base.GVariant as B.GVariant import qualified Data.GI.Base.GValue as B.GValue import qualified Data.GI.Base.GParamSpec as B.GParamSpec import qualified Data.GI.Base.CallStack as B.CallStack import qualified Data.GI.Base.Properties as B.Properties import qualified Data.GI.Base.Signals as B.Signals import qualified Control.Monad.IO.Class as MIO import qualified Data.Text as T import qualified Data.ByteString.Char8 as B import qualified Data.Map as Map import qualified Foreign.Ptr as FP import qualified GHC.OverloadedLabels as OL import qualified GI.Gdk.Objects.Display as Gdk.Display import {-# SOURCE #-} qualified GI.Wnck.Enums as Wnck.Enums import {-# SOURCE #-} qualified GI.Wnck.Structs.ResourceUsage as Wnck.ResourceUsage -- function xid_read_resource_usage -- Args: [ Arg -- { argCName = "gdk_display" -- , argType = -- TInterface Name { namespace = "Gdk" , name = "Display" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a <classname>GdkDisplay</classname>." -- , sinceVersion = Nothing -- } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- , Arg -- { argCName = "xid" -- , argType = TBasicType TULong -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "an X window ID." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- , Arg -- { argCName = "usage" -- , argType = -- TInterface Name { namespace = "Wnck" , name = "ResourceUsage" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = -- Just -- "return location for the X resource usage of the application owning\nthe X window ID @xid." -- , sinceVersion = Nothing -- } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Nothing -- throws : False -- Skip return : False foreign import ccall "wnck_xid_read_resource_usage" wnck_xid_read_resource_usage :: Ptr Gdk.Display.Display -> -- gdk_display : TInterface (Name {namespace = "Gdk", name = "Display"}) CULong -> -- xid : TBasicType TULong Ptr Wnck.ResourceUsage.ResourceUsage -> -- usage : TInterface (Name {namespace = "Wnck", name = "ResourceUsage"}) IO () -- | Looks for the X resource usage of the application owning the X window ID -- /@xid@/ on display /@gdisplay@/. If no resource usage can be found, then all -- fields of /@usage@/ are set to 0. -- -- To properly work, this function requires the XRes extension on the X server. -- -- /Since: 2.6/ xidReadResourceUsage :: (B.CallStack.HasCallStack, MonadIO m, Gdk.Display.IsDisplay a) => a -- ^ /@gdkDisplay@/: a \<classname>GdkDisplay\<\/classname>. -> CULong -- ^ /@xid@/: an X window ID. -> Wnck.ResourceUsage.ResourceUsage -- ^ /@usage@/: return location for the X resource usage of the application owning -- the X window ID /@xid@/. -> m () xidReadResourceUsage :: a -> CULong -> ResourceUsage -> m () xidReadResourceUsage a gdkDisplay CULong xid ResourceUsage usage = IO () -> m () forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO () -> m ()) -> IO () -> m () forall a b. (a -> b) -> a -> b $ do Ptr Display gdkDisplay' <- a -> IO (Ptr Display) forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b) unsafeManagedPtrCastPtr a gdkDisplay Ptr ResourceUsage usage' <- ResourceUsage -> IO (Ptr ResourceUsage) forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a) unsafeManagedPtrGetPtr ResourceUsage usage Ptr Display -> CULong -> Ptr ResourceUsage -> IO () wnck_xid_read_resource_usage Ptr Display gdkDisplay' CULong xid Ptr ResourceUsage usage' a -> IO () forall a. ManagedPtrNewtype a => a -> IO () touchManagedPtr a gdkDisplay ResourceUsage -> IO () forall a. ManagedPtrNewtype a => a -> IO () touchManagedPtr ResourceUsage usage () -> IO () forall (m :: * -> *) a. Monad m => a -> m a return () -- function shutdown -- Args: [] -- Lengths: [] -- returnType: Nothing -- throws : False -- Skip return : False foreign import ccall "wnck_shutdown" wnck_shutdown :: IO () -- | Makes libwnck stop listening to events and tear down all resources from -- libwnck. This should be done if you are not going to need the state change -- notifications for an extended period of time, to avoid wakeups with every -- key and focus event. -- -- After this, all pointers to Wnck object you might still hold are invalid. -- -- Due to the fact that \<link -- linkend=\"getting-started.pitfalls.memory-management\">Wnck objects are all -- owned by libwnck\<\/link>, users of this API through introspection should be -- extremely careful: they must explicitly clear variables referencing objects -- before this call. Failure to do so might result in crashes. -- -- /Since: 3.4/ shutdown :: (B.CallStack.HasCallStack, MonadIO m) => m () shutdown :: m () shutdown = IO () -> m () forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO () -> m ()) -> IO () -> m () forall a b. (a -> b) -> a -> b $ do IO () wnck_shutdown () -> IO () forall (m :: * -> *) a. Monad m => a -> m a return () -- function set_default_mini_icon_size -- Args: [ Arg -- { argCName = "size" -- , argType = TBasicType TUInt64 -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = -- Just "the default size for windows and application mini icons." -- , sinceVersion = Nothing -- } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Nothing -- throws : False -- Skip return : False foreign import ccall "wnck_set_default_mini_icon_size" wnck_set_default_mini_icon_size :: Word64 -> -- size : TBasicType TUInt64 IO () -- | The default main icon size is 'GI.Wnck.Constants.DEFAULT_MINI_ICON_SIZE'. This function -- allows to change this value. -- -- /Since: 2.4.6/ setDefaultMiniIconSize :: (B.CallStack.HasCallStack, MonadIO m) => Word64 -- ^ /@size@/: the default size for windows and application mini icons. -> m () setDefaultMiniIconSize :: Word64 -> m () setDefaultMiniIconSize Word64 size = IO () -> m () forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO () -> m ()) -> IO () -> m () forall a b. (a -> b) -> a -> b $ do Word64 -> IO () wnck_set_default_mini_icon_size Word64 size () -> IO () forall (m :: * -> *) a. Monad m => a -> m a return () -- function set_default_icon_size -- Args: [ Arg -- { argCName = "size" -- , argType = TBasicType TUInt64 -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = -- Just "the default size for windows and application standard icons." -- , sinceVersion = Nothing -- } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Nothing -- throws : False -- Skip return : False foreign import ccall "wnck_set_default_icon_size" wnck_set_default_icon_size :: Word64 -> -- size : TBasicType TUInt64 IO () -- | The default main icon size is 'GI.Wnck.Constants.DEFAULT_ICON_SIZE'. This function allows -- to change this value. -- -- /Since: 2.4.6/ setDefaultIconSize :: (B.CallStack.HasCallStack, MonadIO m) => Word64 -- ^ /@size@/: the default size for windows and application standard icons. -> m () setDefaultIconSize :: Word64 -> m () setDefaultIconSize Word64 size = IO () -> m () forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO () -> m ()) -> IO () -> m () forall a b. (a -> b) -> a -> b $ do Word64 -> IO () wnck_set_default_icon_size Word64 size () -> IO () forall (m :: * -> *) a. Monad m => a -> m a return () -- function set_client_type -- Args: [ Arg -- { argCName = "ewmh_sourceindication_client_type" -- , argType = -- TInterface Name { namespace = "Wnck" , name = "ClientType" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a role for the client." -- , sinceVersion = Nothing -- } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Nothing -- throws : False -- Skip return : False foreign import ccall "wnck_set_client_type" wnck_set_client_type :: CUInt -> -- ewmh_sourceindication_client_type : TInterface (Name {namespace = "Wnck", name = "ClientType"}) IO () -- | Sets the role of the libwnck user. -- -- The default role is 'GI.Wnck.Enums.ClientTypeApplication'. Therefore, for -- applications providing some window management features, like pagers or -- tasklists, it is important to set the role to 'GI.Wnck.Enums.ClientTypePager' for -- libwnck to properly work. -- -- This function should only be called once per program. Additional calls -- with the same client type will be silently ignored. An attempt to change -- the client type to a differnet value after it has already been set will -- be ignored and a critical warning will be logged. -- -- /Since: 2.14/ setClientType :: (B.CallStack.HasCallStack, MonadIO m) => Wnck.Enums.ClientType -- ^ /@ewmhSourceindicationClientType@/: a role for the client. -> m () setClientType :: ClientType -> m () setClientType ClientType ewmhSourceindicationClientType = IO () -> m () forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO () -> m ()) -> IO () -> m () forall a b. (a -> b) -> a -> b $ do let ewmhSourceindicationClientType' :: CUInt ewmhSourceindicationClientType' = (Int -> CUInt forall a b. (Integral a, Num b) => a -> b fromIntegral (Int -> CUInt) -> (ClientType -> Int) -> ClientType -> CUInt forall b c a. (b -> c) -> (a -> b) -> a -> c . ClientType -> Int forall a. Enum a => a -> Int fromEnum) ClientType ewmhSourceindicationClientType CUInt -> IO () wnck_set_client_type CUInt ewmhSourceindicationClientType' () -> IO () forall (m :: * -> *) a. Monad m => a -> m a return () -- function pid_read_resource_usage -- Args: [ Arg -- { argCName = "gdk_display" -- , argType = -- TInterface Name { namespace = "Gdk" , name = "Display" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a <classname>GdkDisplay</classname>." -- , sinceVersion = Nothing -- } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- , Arg -- { argCName = "pid" -- , argType = TBasicType TULong -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a process ID." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- , Arg -- { argCName = "usage" -- , argType = -- TInterface Name { namespace = "Wnck" , name = "ResourceUsage" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = -- Just -- "return location for the X resource usage of the application with\nprocess ID @pid." -- , sinceVersion = Nothing -- } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Nothing -- throws : False -- Skip return : False foreign import ccall "wnck_pid_read_resource_usage" wnck_pid_read_resource_usage :: Ptr Gdk.Display.Display -> -- gdk_display : TInterface (Name {namespace = "Gdk", name = "Display"}) CULong -> -- pid : TBasicType TULong Ptr Wnck.ResourceUsage.ResourceUsage -> -- usage : TInterface (Name {namespace = "Wnck", name = "ResourceUsage"}) IO () -- | Looks for the X resource usage of the application with process ID /@pid@/ on -- display /@gdisplay@/. If no resource usage can be found, then all fields of -- /@usage@/ are set to 0. -- -- In order to find the resource usage of an application that does not have an -- X window visible to libwnck (panel applets do not have any toplevel windows, -- for example), 'GI.Wnck.Functions.pidReadResourceUsage' walks through the whole tree of -- X windows. Since this walk is expensive in CPU, a cache is created. This -- cache is updated in the background. This means there is a non-null -- probability that no resource usage will be found for an application, even if -- it is an X client. If this happens, calling 'GI.Wnck.Functions.pidReadResourceUsage' -- again after a few seconds should work. -- -- To properly work, this function requires the XRes extension on the X server. -- -- /Since: 2.6/ pidReadResourceUsage :: (B.CallStack.HasCallStack, MonadIO m, Gdk.Display.IsDisplay a) => a -- ^ /@gdkDisplay@/: a \<classname>GdkDisplay\<\/classname>. -> CULong -- ^ /@pid@/: a process ID. -> Wnck.ResourceUsage.ResourceUsage -- ^ /@usage@/: return location for the X resource usage of the application with -- process ID /@pid@/. -> m () pidReadResourceUsage :: a -> CULong -> ResourceUsage -> m () pidReadResourceUsage a gdkDisplay CULong pid ResourceUsage usage = IO () -> m () forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO () -> m ()) -> IO () -> m () forall a b. (a -> b) -> a -> b $ do Ptr Display gdkDisplay' <- a -> IO (Ptr Display) forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b) unsafeManagedPtrCastPtr a gdkDisplay Ptr ResourceUsage usage' <- ResourceUsage -> IO (Ptr ResourceUsage) forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a) unsafeManagedPtrGetPtr ResourceUsage usage Ptr Display -> CULong -> Ptr ResourceUsage -> IO () wnck_pid_read_resource_usage Ptr Display gdkDisplay' CULong pid Ptr ResourceUsage usage' a -> IO () forall a. ManagedPtrNewtype a => a -> IO () touchManagedPtr a gdkDisplay ResourceUsage -> IO () forall a. ManagedPtrNewtype a => a -> IO () touchManagedPtr ResourceUsage usage () -> IO () forall (m :: * -> *) a. Monad m => a -> m a return ()