From c94ba8665b3fbd42c76c8f4533b2ac8ea7f3e8c5 Mon Sep 17 00:00:00 2001 From: slava Date: Tue, 21 Mar 2006 07:40:16 +0000 Subject: [PATCH] Fixed some resource leaks in the UI --- library/cocoa/ui.factor | 9 +++++---- library/ui/hand.factor | 6 ++++-- library/ui/listener.factor | 2 +- library/ui/world.factor | 9 ++++++--- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/library/cocoa/ui.factor b/library/cocoa/ui.factor index 447ee04472..ed184b2a62 100644 --- a/library/cocoa/ui.factor +++ b/library/cocoa/ui.factor @@ -134,10 +134,10 @@ H{ } clone views set-global [ 2drop 1 ] } - { "init" "id" { "id" "SEL" } + { "initWithFrame:pixelFormat:" "id" { "id" "SEL" "NSRect" "id" } [ - drop - SUPER-> [init] + rot drop + SUPER-> [initWithFrame:pixelFormat:] dup "updateFactorGadgetSize:" add-resize-observer ] } @@ -165,7 +165,8 @@ H{ } clone views set-global IN: gadgets -: repaint-handle ( handle -- ) 1 [setNeedsDisplay:] ; +: repaint-handle ( handle -- ) + 1 [setNeedsDisplay:] ; : in-window ( gadget status dim title -- ) >r r> drop ; diff --git a/library/ui/hand.factor b/library/ui/hand.factor index 64902339da..76f36167bf 100644 --- a/library/ui/hand.factor +++ b/library/ui/hand.factor @@ -69,12 +69,14 @@ V{ } clone hand-buttons set-global [ lose-focus ] swap each-gesture [ gain-focus ] swap each-gesture ; -: request-focus ( gadget -- ) - dup focusable-child swap find-world +: request-focus* ( gadget world -- ) dup focused-ancestors >r [ set-world-focus ] keep focused-ancestors r> focus-gestures ; +: request-focus ( gadget -- ) + dup focusable-child swap find-world request-focus* ; + : drag-loc ( -- loc ) hand-loc get-global hand-click-loc get-global v- ; diff --git a/library/ui/listener.factor b/library/ui/listener.factor index c6cb32c5cf..ac95751f75 100644 --- a/library/ui/listener.factor +++ b/library/ui/listener.factor @@ -59,7 +59,7 @@ SYMBOL: stack-bar dup pane set-global ; : ( -- gadget status ) - dup solid-interior + dup pane set-global over @center frame-add >r over @bottom frame-add r> ; diff --git a/library/ui/world.factor b/library/ui/world.factor index 142a27c60d..6acbe10142 100644 --- a/library/ui/world.factor +++ b/library/ui/world.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2005, 2006 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. IN: gadgets -USING: freetype gadgets-layouts generic hashtables kernel +USING: errors freetype gadgets-layouts generic hashtables kernel namespaces opengl sequences ; ! The world gadget is the top level gadget that all (visible) @@ -19,7 +19,10 @@ TUPLE: world glass status focus fonts handle ; world-fonts [ drop V{ } clone ] cache ; : close-world ( world -- ) - dup remove-notify dup free-fonts f swap set-world-handle ; + f over request-focus* + dup remove-notify + dup free-fonts + f swap set-world-handle ; C: world ( gadget status dim -- world ) over set-delegate @@ -49,7 +52,7 @@ M: gadget find-world gadget-parent find-world ; M: world find-world ; : repaint ( gadget -- ) - find-world [ world-handle repaint-handle ] when* ; + find-world [ world-handle [ repaint-handle ] when* ] when* ; : focused-ancestors ( world -- seq ) world-focus parents reverse-slice ;