From 63610d2e958539d2dfba411c23f63d6602a6a5b4 Mon Sep 17 00:00:00 2001 From: t-sin Date: Fri, 28 Jul 2023 23:16:19 +0900 Subject: [PATCH] Set WM_CLASS in X11 --- frontends/sdl2/main.lisp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/frontends/sdl2/main.lisp b/frontends/sdl2/main.lisp index 7e5541e94..131560d56 100644 --- a/frontends/sdl2/main.lisp +++ b/frontends/sdl2/main.lisp @@ -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* @@ -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+ @@ -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))