summaryrefslogtreecommitdiffstats
path: root/GLX.hs
diff options
context:
space:
mode:
Diffstat (limited to 'GLX.hs')
-rw-r--r--GLX.hs15
1 files changed, 10 insertions, 5 deletions
diff --git a/GLX.hs b/GLX.hs
index a50dbab..e3ce389 100644
--- a/GLX.hs
+++ b/GLX.hs
@@ -13,10 +13,10 @@ import Graphics.X11.Types
import Graphics.X11.Xlib.Atom (internAtom)
import Graphics.X11.Xlib.Display (defaultScreen, openDisplay, rootWindow)
import Graphics.X11.Xlib.Event (XEventPtr, allocaXEvent, nextEvent, get_Window, get_EventType, pending)
-import Graphics.X11.Xlib.Extras (getEvent, ev_event_type, ev_keycode, ev_data)
+import Graphics.X11.Xlib.Extras (ClassHint(..), getEvent, ev_event_type, ev_keycode, ev_data)
import Graphics.X11.Xlib.Misc (keycodeToKeysym, setWMProtocols)
import Graphics.X11.Xlib.Types
-import Graphics.X11.Xlib.Window (destroyWindow, mapWindow)
+import Graphics.X11.Xlib.Window (destroyWindow, mapWindow, storeName)
import Foreign.Marshal.Utils (with)
import Foreign.Ptr
@@ -41,10 +41,10 @@ glxDriver = GLX
instance Driver GLX where
- initialized glx = ((glxContext glx) == (Context nullPtr))
+ initialized glx = ((glxContext glx) /= (Context nullPtr))
initGL glx = do
- when ((glxContext glx) /= (Context nullPtr)) $ fail "GLX already initialized"
+ when (initialized glx) $ fail "GLX already initialized"
disp <- openDisplay ""
delwnd <- internAtom disp "WM_DELETE_WINDOW" False
@@ -64,8 +64,11 @@ instance Driver GLX where
wnd <- with swa $ \swaptr ->
createWindow disp rootwindow 0 0 800 600 0 (fromIntegral $ viDepth visualinfo) inputOutput (viVisual visualinfo) (cWBorderPixel.|.cWColormap.|.cWEventMask) swaptr
+ setClassHint disp wnd (ClassHint "HTanks" "htanks")
setWMProtocols disp wnd [delwnd]
-
+
+ storeName disp wnd "HTanks"
+
mapWindow disp wnd
waitForMapNotify disp wnd
@@ -84,6 +87,8 @@ instance Driver GLX where
destroyWindow (glxDisplay glx) (glxWindow glx)
destroyContext (glxDisplay glx) (glxContext glx)
+ swapBuffers glx = Bindings.GLX.swapBuffers (glxDisplay glx) (glxWindow glx)
+
nextEvent glx = allocaXEvent $ nextEvent' glx $ glxDisplay glx