[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CLX and ICCCM



Here is a proposal for changes to CLX to support the draft standard Interclient
Communications Conventions Manual. Comments and suggestions welcome. All changes
are summarized below.

1. wm-class replaces get-wm-class, for greater consistency. Unfortunately,
   set-wm-class remains, but only temporarily, since Common Lisp will soon
   define multiple value setf's.

2. wm-hints, wm-normal-hints: an optional argument to store the returned
   property value structure is added.

3. transient-for renamed to wm-transient-for in order to be consistent with the
   other property functions and with the property name itself.

4. New property functions added: wm-colormap-windows, wm-protocols, wm-state.

5. wm-icon-size replaces icon-sizes.  A new wm-icon-size structure is defined
   for the value of this property.

6. wm-icon-name, wm-name, wm-client-machine, wm-command: These return a
   new second value giving the type atom for the string encoding.  setf forms
   also accept new keyword arguments for type, translate, and size.

7. wm-command now returns/stores a single string value, instead of a
   list encoded as a sequence of strings.  This interface is more correct given
   that the interpretation of this property is system-dependent.

8. wm-hints structure: The type of initial-state is changed to (member :normal
   :iconic :withdrawn).

9. wm-size-hints structure: The default values of user-specified-size/position-p 
   are changed to nil, in order to better reflect the typical case. x, y, width,
   height slots have been removed. New slots are added for base-width,
   base-height, and gravity

        
;;;----------------------------------------------------------------------------+
;;;                                                                            |
;;;                     Window Manager Properties                              |
;;;                                                                            |
;;;----------------------------------------------------------------------------+


(defun wm-class (window)
  "Return the two string values from the :WM_CLASS property of the window: 
   the application resource name and the application resource class."
  (declare (type   window window))
  (declare-values  name class))

(defun set-wm-class (window name class)
  "Set the :WM_CLASS property of the window with the given application resource
   name and application resource class name."
  (declare (type   window window)
           (type   stringable name class))
  (declare-values  name class))

 
(defun wm-colormap-windows (window)
  "Return the list of windows from the :WM_COLORMAP_WINDOWS property
   of the window."
  (declare (type   window   window))
  (declare-values  list))

(defsetf wm-colormap-windows (window) (sequence)
  "Store a sequence of windows in the :WM_COLORMAP_WINDOWS property
   of the window."
  (declare (type   window            window)
           (type   (sequence window) sequence))
  (declare-values  sequence))

(defun wm-hints (window &optional structure)
  "Return the wm-hints structure from the :WM_HINTS property
   of the window. If a non-nil structure is given, then it is used
   to store the return value; otherwise, a new structure is
   created and returned."
  (declare (type   window   window)
           (type   wm-hints structure))
  (declare-values  structure))

(defsetf wm-hints (window) (hints)
  "Store the wm-hints structure in the :WM_HINTS property
   of the window."
  (declare (type   window   window)
           (type   wm-hints hints))
  (declare-values  hints))

(defstruct wm-hints
  (input         nil :type (or null (member :off :on)))
  (initial-state nil :type (or null (member :normal :iconic :withdrawn)))
  (icon-pixmap   nil :type (or null pixmap))
  (icon-window   nil :type (or null window))
  (icon-x        nil :type (or null card16))
  (icon-y        nil :type (or null card16))
  (icon-mask     nil :type (or null pixmap))
  (window-group  nil :type (or null resource-id))
  (flags          0 :type card32)    ;; Extension-hook
  )

(defun wm-icon-name (window)
  "Return the array of characters from the :WM_ICON_NAME property of the window.
   The second value returned is the type atom indicating the character encoding
   of the array."
  (declare (type   window window))
  (declare-values  array type))

(defsetf wm-icon-name (window &key (type :string) translate (size 8)) (name)
  "Set the sequence of characters in the :WM_ICON_NAME property of the window
   using the given type atom to indicate the character encoding of the sequence.
   The translate function is used to transform elements of the name sequence
   into octets.  The size defines the element size of the dst buffer used by
   translate."
  (declare (type   window               window)
           (type   (or symbol sequence) name)
           (type   translate            translate)
           (type   index-size           size))
  (declare-values  name type))


(defun wm-icon-size (window &optional structure)
  "Return the wm-icon-size structure from the :WM_ICON_SIZE property
   of the (root) window. If a non-nil structure is given, then it is used
   to store the return value; otherwise, a new structure is
   created and returned."
  (declare (type   window       window)
           (type   wm-icon-size structure))
  (declare-values  structure))

(defstruct wm-icon-size
  (min-width  nil :type (or null card16))
  (min-height nil :type (or null card16))
  (max-width  nil :type (or null card16))
  (max-height nil :type (or null card16))
  (width-inc  nil :type (or null card16))
  (height-inc nil :type (or null card16)))

(defun wm-name (window)
  "Return the array of characters from the :WM_NAME property of the window. The
   second value returned is the type atom indicating the character
   encoding of the array."
  (declare (type   window window))
  (declare-values  array type))


(defsetf wm-name (window &key (type :string) translate (size 8)) (name)
  "Set the sequence of characters in the :WM_NAME property of the window, using
   the given type atom to indicate the character encoding of the sequence.  The
   translate function is used to transform elements of the name sequence into
   octets.  The size defines the element size of the dst buffer used by
   translate."
  (declare (type   window               window)
           (type   (or symbol sequence) name)
           (type   translate            translate)
           (type   index-size           size))
  (declare-values  name type))


(defun wm-normal-hints (window &optional structure)
  "Return the wm-size-hints structure from the :WM_NORMAL_HINTS property
   of the window. If a non-nil structure is given, then it is used
   to store the return value; otherwise, a new structure is
   created and returned."
  (declare (type   window        window)
           (type   wm-size-hints structure))
  (declare-values  structure))

(defsetf wm-normal-hints (window) (hints)
  "Store the wm-size-hints structure in the :WM_NORMAL_HINTS property
   of the window."
  (declare (type   window        window)
           (type   wm-size-hints hints))
  (declare-values  hints))

(defstruct wm-size-hints
  (user-specified-position-p nil :type boolean)
  (user-specified-size-p     nil :type boolean)
  (min-width                 nil :type (or null card16))
  (min-height                nil :type (or null card16))
  (max-width                 nil :type (or null card16))
  (max-height                nil :type (or null card16))
  (width-inc                 nil :type (or null card16))
  (height-inc                nil :type (or null card16))
  (min-aspect                nil :type (or null number))
  (max-aspect                nil :type (or null number))
  (base-width                nil :type (or null card16))
  (base-height               nil :type (or null card16))
  (gravity                   nil :type win-gravity))



(defun wm-protocols (window)
  "Return the list of atoms from the :WM_PROTOCOLS property of the window. "
  (declare (type   window   window))
  (declare-values  list))

(defsetf wm-protocols (window) (sequence)
  "Store a sequence of atoms in the :WM_PROTOCOLS property of the window.
   Standard atoms are any of :wm_take_focus, :wm_save_yourself, or
   :wm_delete_window."
  (declare (type   window   window)
           (type   sequence sequence))
  (declare-values  sequence))

(defun wm-state (window)
  "Return the current window-manager state of the window from its :WM_STATE property. 
   The return value is either :normal, :iconic, or :withdrawn, or an integer
   specifiying a window-manager-dependent state."
  (declare (type   window window))
  (declare-values  state))

(defsetf wm-state (window &optional current-state) (new-state)
  "Change the current window-manager state of the window. If the current-state
   is omitted and the new-state is :iconic, then the current state is assumed
   to be :normal."
  (declare (type   window window)
           (type   (member :normal :iconic :withdrawn) new-state current-state))
  (declare-values  new-state))

(defun wm-transient-for (window)
  "Return the window object in the :WM_TRANSIENT_FOR property of the window."
  (declare (type   window   window))
  (declare-values  transient-for))

(defsetf wm-transient-for (window) (transient-for)
  "Store a window object in the :WM_TRANSIENT_FOR property of the window."
  (declare (type   window   window transient-for))
  (declare-values  transient-for))



;;;----------------------------------------------------------------------------+
;;;                                                                            |
;;;                    Session Manager Properties                              |
;;;                                                                            |
;;;----------------------------------------------------------------------------+

(defun wm-client-machine (window)
  "Return the array of characters from the :WM_CLIENT_MACHINE property
   of the window.  The second value returned is the type atom indicating the
   character encoding of the array."
  (declare (type   window window))
  (declare-values  array type))


(defsetf wm-client-machine (window &key (type :string) translate (size 8)) (name)
  "Set the sequence of characters in the :WM_CLIENT_MACHINE property
   of the window, using the given type atom to indicate the character encoding
   of the sequence.  The translate function is used to transform elements of the
   name sequence into octets. The size defines the element size of the dst
   buffer used by translate."
   (declare (type window window)
           (type   (or symbol sequence) name)
           (type   translate            translate)
           (type   index-size           size))  
  (declare-values  name type))


(defun wm-command (window)
  "Return the array of characters from the :WM_COMMAND property
   of the window. The second value returned is the type atom indicating the
   character
   encoding of the array."
  (declare (type   window window))
  (declare-values  array type))


(defsetf wm-command (window &key (type :string) translate (size 8)) (name)
  "Set the sequence of characters in the :WM_COMMAND property of the window,
   using the given type atom to indicate the character encoding of the sequence.
   The translate function is used to transform elements of the name sequence
   into octets.  The size defines the element size of the dst buffer used by
   translate."
  (declare (type window window)
           (type   (or symbol sequence) name)
           (type   translate            translate)
           (type   index-size           size))  
  (declare-values  name type))