{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc) -} #define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \ && !defined(__HADDOCK_VERSION__)) 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.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.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 wnck_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 GdkDisplay.", 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 \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 gdkDisplay xid usage = liftIO $ do gdkDisplay' <- unsafeManagedPtrCastPtr gdkDisplay usage' <- unsafeManagedPtrGetPtr usage wnck_xid_read_resource_usage gdkDisplay' xid usage' touchManagedPtr gdkDisplay touchManagedPtr usage return () -- function wnck_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 \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 = liftIO $ do wnck_shutdown return () -- function wnck_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 size = liftIO $ do wnck_set_default_mini_icon_size size return () -- function wnck_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 size = liftIO $ do wnck_set_default_icon_size size return () -- function wnck_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 ewmhSourceindicationClientType = liftIO $ do let ewmhSourceindicationClientType' = (fromIntegral . fromEnum) ewmhSourceindicationClientType wnck_set_client_type ewmhSourceindicationClientType' return () -- function wnck_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 GdkDisplay.", 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 \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 gdkDisplay pid usage = liftIO $ do gdkDisplay' <- unsafeManagedPtrCastPtr gdkDisplay usage' <- unsafeManagedPtrGetPtr usage wnck_pid_read_resource_usage gdkDisplay' pid usage' touchManagedPtr gdkDisplay touchManagedPtr usage return ()