From c3a6e02a38e8891f58485e960154022e7c26f84f Mon Sep 17 00:00:00 2001 From: slava Date: Fri, 17 Nov 2006 09:36:59 +0000 Subject: [PATCH] Better top-level window positioning on Cocoa and X11 --- TODO.FACTOR.txt | 1 + library/ui/cocoa/ui.factor | 8 ++++++++ library/ui/x11/windows.factor | 6 +++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index eb4a99a9e9..41ff57a492 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -1,5 +1,6 @@ + 0.87: +- live search operations need to hide the minibuffer - vocab links don't work - browse modules and vocabs by showing a new list - get rid of the navigator in the browser tool diff --git a/library/ui/cocoa/ui.factor b/library/ui/cocoa/ui.factor index c1b42719a5..8f2a443eb4 100644 --- a/library/ui/cocoa/ui.factor +++ b/library/ui/cocoa/ui.factor @@ -79,9 +79,17 @@ IN: gadgets : set-title ( string world -- ) world-handle second swap -> setTitle: ; +: auto-position ( world -- ) + dup world-loc { 0 0 } = [ + world-handle second -> center + ] [ + drop + ] if ; + : open-window* ( world -- ) dup gadget-window dup start-world + dup auto-position world-handle second f -> makeKeyAndOrderFront: ; : raise-window ( world -- ) diff --git a/library/ui/x11/windows.factor b/library/ui/x11/windows.factor index 3360363340..2ec859137a 100644 --- a/library/ui/x11/windows.factor +++ b/library/ui/x11/windows.factor @@ -36,12 +36,16 @@ USING: alien gadgets hashtables kernel math namespaces sequences ; USPosition over set-XSizeHints-flags dpy get -rot XSetWMNormalHints ; +: auto-position ( window loc -- ) + { 0 0 } = [ drop ] [ set-size-hints ] if ; + : create-window ( loc dim visinfo -- window ) + pick >r >r >r >r dpy get root get r> first2 r> first2 0 r> [ XVisualInfo-depth InputOutput ] keep [ XVisualInfo-visual create-window-mask ] keep window-attributes XCreateWindow - dup set-size-hints ; + dup r> auto-position ; : glx-window ( loc dim -- window context ) choose-visual