Ferada / cl-cffi-gtk

#cl-cffi-gtk on Freenode. A Lisp binding to GTK+3. SBCL/CCL/ABCL (ECL/CLISP unstable)
http://www.crategus.com/books/cl-cffi-gtk
41 stars 8 forks source link

Transparent window drawing issue on Linux #57

Open pbella opened 3 years ago

pbella commented 3 years ago

I have been trying, without success, to create a transparent window which appears supported per http://www.crategus.com/books/cl-cffi-gtk/pages/gtk_class_gtk-window.html and http://www.crategus.com/books/cl-cffi-gtk/pages/gtk_fun_gtk-widget-opacity.html. The problem is that the window is drawn completely opaque on my desktop. However, when I switched from my desktop to a laptop the same trivial window creation code worked perfectly:

(defun simple-overlay ()
   (within-main-loop
     (let ((window (make-instance 'gtk-window
                                  :type :toplevel
                                  :title "Test"
                 :opacity 0.5
                                  :default-width 250
                                  :border-width 12)))
       ;; answers true on both systems...
       ;;(print (gtk-widget-is-composited window))
       ;; Connect a handler for the signal "destroy" to window.
       (g-signal-connect window "destroy"
                         (lambda (widget)
                           (declare (ignore widget))
                           (leave-gtk-main)))
       (gtk-widget-show-all window))))

After a bit of digging, the issue appears to be related to my desktop having an nVidia GPU, and as a result running the proprietary nVidia drivers with XOrg rather than Wayland on Linux. I've found several references to similar issues when running this combination of card/driver/display server with other software. The only workaround I've found so far appears to be to manually draw transparent widgets offscreen and then copy them onscreen.

It is entirely possible (probable?) that this is not a cl-cffi-gtk specific bug (possibly a GTK bug/limitation?) but regardless of where the issue resides, if it can't be resolved it would be nice if the issue, and any workaround, was documented in cl-cffi-gtk. It is at least a notable caveat for a rather common video configuration on Linux.

Ferada commented 3 years ago

It most certainly doesn't sound like a cl-cffi-gtk bug, but as you've described, a GTK / X* limitation. This library is an FFI binding, so, almost everything that applies to the GTK family of libraries by necessity also applies to it. I'm not going to document those, as there are too many to count. At most I'd consider a big warning sign to explain that, with a link to the relevant bug trackers if that's at all helpful.