Skip to content

Commit

Permalink
Merge pull request #885 from t-sin/sdl2-wm-class-in-x11
Browse files Browse the repository at this point in the history
Set WM_CLASS in X11
  • Loading branch information
cxxxr authored Jul 28, 2023
2 parents 9516805 + 63610d2 commit c2ac9c9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions frontends/sdl2/main.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
(defconstant +display-width+ 100)
(defconstant +display-height+ 40)

(defvar +lem-x11-wm-class+ "Lem SDL2")

(defmacro with-bindings (bindings &body body)
`(let ,bindings
(let ((bt:*default-special-bindings*
Expand Down Expand Up @@ -57,6 +59,19 @@
`(call-with-debug (lambda () (log:debug ,@args))
(lambda () ,@body)))

;; this is SDL2 way
;; if the stable version of SDL is 3, set WM_CLASS is set via hint SDL_HINT_APP_ID
;;
;; cf.
;; - how SDL3 gets WM_CLASS:
;; - https://github.com/libsdl-org/SDL/blob/d3f2de7f297d761a7dc5b0dda3c7b5d7bd49eac9/src/video/x11/SDL_x11window.c#L633C40-L633C40
;; - how to set WM_CLASS in here:
;; - SDL_SetHint() function with key SDL_HINT_APP_ID
;; - https://wiki.libsdl.org/SDL2/SDL_SetHint
;; - https://github.com/libsdl-org/SDL/blob/d3f2de7f297d761a7dc5b0dda3c7b5d7bd49eac9/src/core/unix/SDL_appid.c#L63C45-L63C45
(defun set-x11-wm-class (classname)
(setf (uiop:getenv "SDL_VIDEO_X11_WMCLASS") classname))

(defun create-texture (renderer width height)
(sdl2:create-texture renderer
sdl2:+pixelformat-rgba8888+
Expand Down Expand Up @@ -773,6 +788,7 @@
nil)))))

(defun create-display (function)
(set-x11-wm-class +lem-x11-wm-class+)
(sdl2:with-init (:video)
(sdl2-ttf:init)
(sdl2-image:init '(:png))
Expand Down

0 comments on commit c2ac9c9

Please sign in to comment.