From d9977d36f8d79dbfec9c6055a9eb35d42d12fb22 Mon Sep 17 00:00:00 2001 From: slava Date: Wed, 22 Mar 2006 07:27:07 +0000 Subject: [PATCH] Bootstrap fix, got close box working --- library/ui/hand.factor | 2 +- library/ui/listener.factor | 13 +++---------- library/x11/ui.factor | 4 ++-- library/x11/windows.factor | 6 +++++- library/x11/xlib.factor | 2 ++ 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/library/ui/hand.factor b/library/ui/hand.factor index 2635bedad8..bb132d98e7 100644 --- a/library/ui/hand.factor +++ b/library/ui/hand.factor @@ -129,7 +129,7 @@ V{ } clone hand-buttons set-global : ui-step ( -- ) do-timers [ layout-queued ] make-hash - [ nip [ draw-world ] when* ] hash-each + [ nip dup world-handle [ draw-world ] when ] hash-each 10 sleep ; : close-world ( world -- ) diff --git a/library/ui/listener.factor b/library/ui/listener.factor index ca121d5631..192972aa7a 100644 --- a/library/ui/listener.factor +++ b/library/ui/listener.factor @@ -1,12 +1,11 @@ ! Copyright (C) 2005, 2006 Slava Pestov. ! See http://factor.sf.net/license.txt for BSD license. IN: gadgets-listener -USING: arrays compiler gadgets gadgets-editors gadgets-labels +USING: arrays gadgets gadgets-editors gadgets-labels gadgets-layouts gadgets-panes gadgets-scrolling gadgets-splitters gadgets-theme generic hashtables -inference inspector io jedit kernel listener lists math -namespaces parser prettyprint sequences shells threads words -help ; +io jedit kernel listener lists math +namespaces parser prettyprint sequences threads words ; TUPLE: listener-gadget pane stack status ; @@ -49,12 +48,6 @@ TUPLE: listener-gadget pane stack status ; : ( -- gadget ) dup status-theme ; -: ( -- gadget status ) - [ - dup stack-bar set-global - 2array make-pile 1 over set-pack-fill - ] keep ; - : ( -- gadget ) dup pane set-global ; diff --git a/library/x11/ui.factor b/library/x11/ui.factor index 2e47ecfd21..20a2445ab4 100644 --- a/library/x11/ui.factor +++ b/library/x11/ui.factor @@ -80,13 +80,13 @@ M: world key-down-event ( event world -- ) M: world key-up-event ( event world -- ) 2drop ; : close-box? ( event -- ) - dup XClientMessageEvent-type "WM_PROTOCOLS" x-atom = + dup XClientMessageEvent-message_type "WM_PROTOCOLS" x-atom = swap XClientMessageEvent-data "WM_DELETE_WINDOW" x-atom = and ; M: world client-event ( event world -- ) swap close-box? [ - dup close-world world-handle destroy-window* + dup world-handle first >r close-world r> destroy-window* ] [ drop ] if ; diff --git a/library/x11/windows.factor b/library/x11/windows.factor index 7aacfd0570..ae48b14575 100644 --- a/library/x11/windows.factor +++ b/library/x11/windows.factor @@ -40,11 +40,15 @@ USING: alien hashtables kernel math namespaces sequences ; : destroy-window* ( win -- ) dup windows get remove-hash destroy-window ; + +: set-closable ( win -- ) + dpy get swap "WM_DELETE_WINDOW" x-atom 1 + XSetWMProtocols drop ; : map-window ( win -- ) dpy get swap XMapWindow drop ; : map-window* ( world win -- ) - [ windows get set-hash ] keep map-window ; + dup set-closable [ windows get set-hash ] keep map-window ; : glx-window* ( world dim -- win context ) glx-window >r [ map-window* ] keep r> ; diff --git a/library/x11/xlib.factor b/library/x11/xlib.factor index 5e66a9c94a..dded6c2eff 100644 --- a/library/x11/xlib.factor +++ b/library/x11/xlib.factor @@ -51,12 +51,14 @@ TYPEDEF: void* Window** : ; : ; : ; +: ; : *ulong *uint ; : *XID *ulong ; : *Window *XID ; : *Drawable *XID ; : *KeySym *XID ; +: *Atom *ulong ; ! ! 2 - Display Functions !