From: Sebastian Boldt
Subject: CLX
Date: 
Message-ID: <20020217121702.39e4cad9.SebastianBoldt@t-online.de>
Hi ppl,

I'm just checking out CLX. On Windows, I liked programmin' round windows, is this possible
with X too? And if it is, how can it be done??

thanks in advance...
	...Sebastian

From: Brian P Templeton
Subject: Re: CLX
Date: 
Message-ID: <87ofin1wze.fsf@tunes.org>
Sebastian Boldt <··············@t-online.de> writes:

> Hi ppl,
> 
> I'm just checking out CLX. On Windows, I liked programmin' round windows, is this possible
> with X too? And if it is, how can it be done??
> 
In X11, you can use the shape extension to create shaped windows. I'm
not sure how to do this with CLX (or with C xlib, for that matter :)).

> thanks in advance...
> 	...Sebastian

hth,
-- 
BPT <···@tunes.org>	    		/"\ ASCII Ribbon Campaign
backronym for Linux:			\ / No HTML or RTF in mail
	Linux Is Not Unix			 X  No MS-Word in mail
Meme plague ;)   --------->		/ \ Respect Open Standards
From: Steven M. Haflich
Subject: Re: CLX
Date: 
Message-ID: <3C71CDE3.24470203@pacbell.net>
Sebastian Boldt wrote:
 
> I'm just checking out CLX. On Windows, I liked programmin' round windows, is this possible
> with X too? And if it is, how can it be done??

Yes, xeyes is one example of a standard application using nonrectangular
window.s  I believe this is done by giving the window a transparency
mask with the desired shape.  Search your favorite X11 documentation for "transparency" and you should find it, or else look at the source for
xclock.  Transparency didn't arrive until some version like X11R4, but
that's older than some readers of this list...
From: Daniel Barlow
Subject: Re: CLX
Date: 
Message-ID: <871yfhzrtc.fsf@noetbook.telent.net>
"Steven M. Haflich" <·······@pacbell.net> writes:

> Sebastian Boldt wrote:
>  
> > I'm just checking out CLX. On Windows, I liked programmin' round windows, is this possible
> > with X too? And if it is, how can it be done??
> 
> Yes, xeyes is one example of a standard application using nonrectangular
> window.s  I believe this is done by giving the window a transparency
> mask with the desired shape.  Search your favorite X11 documentation for "transparency" and you should find it, or else look at the source for
> xclock.  Transparency didn't arrive until some version like X11R4, but
> that's older than some readers of this list...

xeyes uses the SHAPE extension to get non-rectangular windows:
googling for "x shape extension" is instructive.  See e.g.

http://cvsweb.netbsd.org/bsdweb.cgi/xsrc/xc/doc/specs/Xext/shape.ms

for some version of the spec.


-dan

-- 

  http://ww.telent.net/cliki/ - Link farm for free CL-on-Unix resources 
From: Fred Gilham
Subject: Re: CLX
Date: 
Message-ID: <u7pu3187e8.fsf@snapdragon.csl.sri.com>
 
> I'm just checking out CLX. On Windows, I liked programmin' round
> windows, is this possible with X too? And if it is, how can it be
> done??


The standard way of doing it is to use the shape extension.

Someone once wrote some code to do this in CLX.  I'm sure he's still
around.  I just don't remember his name.  Anyway, the following is his
code, not mine.

There are two files: shape.lisp and test.lisp.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;; shape.lisp ;;;;;;;;;;;;;

;;; -*- Mode:Lisp; Package:XLIB; Syntax:COMMON-LISP; Base:10; Lowercase:T -*-

;;; CLX interface for Shape Extension

(in-package "XLIB" :use '(lisp))

(define-extension "SHAPE")

(export '(
  query-shape-version
  shape-mask
  shape-combine
  shape-offset
  shape-query-extents
  shape-set
  shape-union
  shape-invert
  shape-bounding
  shape-clip
  shape-notify-mask
  shape-notify

  shape-combine-mask
  shape-combine-shape
  shape-offset-shape
  shape-query-extents))

(defconstant query-shape-version  0) ; not sure about this one
(defconstant shape-rectangles     1) ; unimplemented
(defconstant shape-mask           2)
(defconstant shape-combine        3)
(defconstant shape-offset         4)
(defconstant shape-query-extents  5)
(defconstant shape-select-input   6) ; unimplemented - need to figure inputs
(defconstant shape-input-selected 7) ; unimplemented -       " "
(defconstant shape-get-rectangles 8) ; unimplemented

(defconstant shape-set              0)
(defconstant shape-union            1)
(defconstant shape-intersect        2)
(defconstant shape-subtract         3)
(defconstant shape-invert           4)

(defconstant shape-bounding         0)
(defconstant shape-clip             1)

(defconstant shape-notify-mask      0)
(defconstant shape-notify           1)

; kinds are shape-bounding, or shape-clipped
(defun shape-combine-mask (drawable dst-kind x-off y-off bitmap op)
  (let* ((display (drawable-display drawable))
         (opcode (extension-opcode display "SHAPE")))
    (with-buffer-request (display opcode :length 5)
      ((data card8) shape-mask)
      (card8  op dst-kind 0 0)
      (drawable drawable)
      (int16  x-off y-off)
      (drawable bitmap))))

; kinds are shape-bounding, or shape-clipped
(defun shape-combine-shape (drawable dst-kind x-off y-off bitmap src-kind op)
  (let* ((display (drawable-display drawable))
         (opcode (extension-opcode display "SHAPE")))
    (with-buffer-request (display opcode :length 5)
      ((data card8) shape-combine)
      (card8  op dst-kind src-kind 0)
      (drawable drawable)
      (int16  x-off y-off)
      (drawable bitmap))))

; kinds are shape-bounding or shape-clip
(defun shape-offset-shape (drawable dst-kind x-off y-off)
  (let* ((display (drawable-display drawable))
         (opcode (extension-opcode display "SHAPE")))
    (with-buffer-request (display opcode :length 4)
      ((data card8) shape-combine)
      (card8  dst-kind 0)
      (card16 0)
      (drawable drawable)
      (int16  x-off y-off))))

(defun shape-query-extents (drawable)
  (let* ((display (drawable-display drawable))
         (opcode (extension-opcode display "SHAPE")))
    (with-buffer-request-and-reply (display opcode 2 :sizes (8 16 32))
      (((data card8) shape-query-extents)
       (drawable drawable))
      (values
       (card8-get 8) ; bounding shape?
       (int16-get 12) ; bounding x
       (int16-get 14) ; bounding y
       (card16-get 16) ; bounding width
       (card16-get 18) ; bounding height

       (card8-get 9) ; bounding shape?
       (int16-get 20) ; bounding x
       (int16-get 22) ; bounding y
       (card16-get 24) ; bounding width
       (card16-get 26) ; bounding height
       ))))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;; end of shape.lisp ;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;test.lisp ;;;;;;;;;;;;;;

; test code

;(load "shape")

(defun test (&optional (host "localhost"))
  (let* ((d (xlib:open-display host))
         (s (first (xlib:display-roots d)))
         (r (xlib:screen-root s))
         (w (xlib:create-window :x 0 :y 0 :parent r :width 100 :height 100))
         (p (xlib:create-pixmap :width 100 :height 100 :depth 1 :drawable w))
         (g (xlib:create-gcontext :drawable p :foreground 0)))

    (multiple-value-bind (b? bx by bw bh c? cx cy cw ch) (xlib:shape-query-extents w)
      (print (list b? bx by bw bh c? cx cy cw ch)))
    (setf (xlib:window-background w) 0)
    (xlib:draw-rectangle p g 0 0 100 100 t)
    (setf (xlib:gcontext-foreground g) 1)
    (xlib:draw-arc p g 0 0 100 100 0.0 6.29 t)
    (xlib:shape-combine-mask w xlib:shape-bounding 0 0 p xlib::shape-set)
    (xlib:map-window w)
    (xlib:display-finish-output d)

    (multiple-value-bind (b? bx by bw bh c? cx cy cw ch) (xlib:shape-query-extents w)
      (print (list b? bx by bw bh c? cx cy cw ch)))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;; end of test.lisp ;;;;;;;;;;


-- 
Fred Gilham                                        ······@csl.sri.com
And then [Clinton] turned to Hunter Thompson, of all people, and said
with wholehearted fervor, "We're going to put one hundred thousand new 
police officers on the street."
I was up all night persuading Hunter that this was not a personal
threat.                                              -- P. J. O'Rourke