sharplispers / clx

a fork of crhodes' fork of danb's fork of the CLX library, an X11 client for Common Lisp
Other
116 stars 46 forks source link

CLX' move to CLOS seems to have resulted loss of functionality in object creation. #105

Closed earl-ducaine closed 5 years ago

earl-ducaine commented 6 years ago

(ql version: clx-20180711-git) Related to issue #104, it is no longer possible to pass arbitrary initialization parameters to xlib constructors when creating the standard objects (fonts, windows, etc.)

The old xlib class system mapped all class slots to a &key in the constructor lambda list, unless that feature was explicitly turned off in the class definition.

(defmacro def-clx-class ((name &rest options) &body slots)
         ...
            (if (eq constructor-args t)
            `(defun ,constructor (&rest args)
               (apply #',(closintern 'make-instance)
                  ',name args))

Note, that in the new code, most classes work fine since slots mentioned in the documentation are explicitly given :initargs to match the documentation. But this breaks some code that depends on incompletely documented features like wm-hints. In cases like that, those values must be set after object creation. An example of code that used to work.

(xlib:make-wm-hints :input :on :initial-state :normal)
dkochmanski commented 6 years ago

So you say that all slots should have initargs?

earl-ducaine commented 6 years ago

So you say that all slots should have initargs?

Perhaps not. That's really an architecture question. In the old framework, def-clx-class, created the equivalent of an :initarg for each slot. Using defclass, the new policy seems to be that only those slots specifically needed for constructors have :initarg Maybe that was intentional and is a better design choice?

But I think each slot of wm-hints should have an :initarg and make-wm-hints should accept them. The xrender extension uses defstruct, so this issue doesn't apply there and the other CLX classes I've looked at seem to conform to the documentation.

dkochmanski commented 5 years ago

master branch has been reset