USING: kernel io combinators namespaces quotations arrays sequences math math.vectors x11.xlib x11.constants mortar mortar.sugar slot-accessors geom.rect math.bitfields x x.gc x.widgets x.widgets.button x.widgets.wm.child x.widgets.wm.frame.drag.move x.widgets.wm.frame.drag.size ; IN: x.widgets.wm.frame SYMBOL: { "child" "gc" "last-state" } accessors define-simple-class "create" !( id -- wm-frame ) [ new-empty swap new* >>child new* "white" <-- set-foreground >>gc { SubstructureRedirectMask ExposureMask ButtonPressMask ButtonReleaseMask ButtonMotionMask EnterWindowMask ! experimental masks SubstructureNotifyMask } flags >>mask <- init-widget "cornflowerblue" <-- set-background dup $child <- position <-- move dup $child over <-- reparent drop <- position-child <- fit-to-child <- make-frame-button <- map-subwindows <- map ] add-class-method SYMBOL: WM_PROTOCOLS SYMBOL: WM_DELETE_WINDOW : init-atoms ( -- ) "WM_PROTOCOLS" 0 intern-atom WM_PROTOCOLS set "WM_DELETE_WINDOW" 0 intern-atom WM_DELETE_WINDOW set ; { "fit-to-child" !( wm-frame -- wm-frame ) [ dup $child <- size { 10 20 } v+ <-- resize ] "position-child" !( wm-frame -- wm-frame ) [ dup $child { 5 15 } <-- move drop ] "set-child-size" !( wm-frame size -- frame ) [ >r dup $child r> <-- resize drop <- fit-to-child ] "set-child-width" !( wm-frame width -- frame ) [ >r dup $child r> <- set-width drop <- fit-to-child ] "set-child-height" !( wm-frame height -- frame ) [ >r dup $child r> <- set-height drop <- fit-to-child ] "adjust-child" !( wm-frame -- wm-frame ) [ dup $child over <- size { 10 20 } v- <-- resize drop ] "update-title" !( wm-frame -- wm-frame ) [ <- clear dup >r ! dup $gc { 5 1 } pick $child <- fetch-name <--- draw-string/top-left dup $gc { 5 11 } pick $child <- fetch-name <---- draw-string r> ] "delete-child" !( wm-frame -- wm-frame ) [ dup $child WM_PROTOCOLS get WM_DELETE_WINDOW get <--- send-client-message drop ] "drag-move" !( event wm-frame -- ) [ new* ] "drag-size" !( event wm-frame -- ) [ new* ] "make-frame-button" !( frame -- frame ) [