Add setGDKx11Property.hs
This commit is contained in:
parent
c0d490ad90
commit
6ec1e5f4ce
1 changed files with 49 additions and 0 deletions
49
setGDKx11Property.hs
Normal file
49
setGDKx11Property.hs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE OverloadedLabels #-}
|
||||
{-# LANGUAGE ImplicitParams #-}
|
||||
|
||||
import Data.GI.Base
|
||||
import qualified GI.Gtk as Gtk
|
||||
import qualified GI.Gdk as Gdk
|
||||
import qualified GI.GdkX11 as GdkX11
|
||||
import GI.Gio
|
||||
import Control.Monad (void)
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
app <- new Gtk.Application [#applicationId := "org.example.test"]
|
||||
on app #activate $ do
|
||||
win <- new Gtk.ApplicationWindow
|
||||
[ #application := app
|
||||
, #title := "Dialog Window"
|
||||
, #defaultWidth := 100
|
||||
, #defaultHeight := 40
|
||||
, #resizable := False
|
||||
, #decorated := False
|
||||
]
|
||||
Gtk.widgetShow win
|
||||
|
||||
mSurface <- #getSurface win
|
||||
case mSurface of
|
||||
Just surface -> do
|
||||
-- get X11 surface and display
|
||||
x11Surface <- castTo GdkX11.X11Surface surface
|
||||
display <- Gdk.surfaceGetDisplay surface
|
||||
x11Display <- castTo GdkX11.X11Display display
|
||||
|
||||
case (x11Display, x11Surface) of
|
||||
(Just d, Just s) -> do
|
||||
-- retrieve atoms via GDK X11
|
||||
atomDialog <- GdkX11.x11GetXatomByNameForDisplay d "_NET_WM_WINDOW_TYPE_DIALOG"
|
||||
atomType <- GdkX11.x11GetXatomByNameForDisplay d "_NET_WM_WINDOW_TYPE"
|
||||
|
||||
-- set window type using UTF8 property (technically still a string, but fine for WM hints)
|
||||
GdkX11.x11SurfaceSetUtf8Property
|
||||
s
|
||||
"_NET_WM_WINDOW_TYPE"
|
||||
(Just "_NET_WM_WINDOW_TYPE_DIALOG")
|
||||
|
||||
_ -> putStrLn "Not running under X11."
|
||||
Nothing -> pure ()
|
||||
|
||||
void $ applicationRun app Nothing
|
||||
Loading…
Reference in a new issue