This is the mail archive of the insight@sources.redhat.com mailing list for the Insight project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] More managedwin clean up


Hi,

I have committed the following patches to ManagedWin.

Keith

ChangeLog:
2001-05-18  Keith Seitz  <keiths@cygnus.com>

	* library/managedwin.ith (_geometry): Use a protected variable
	instead of a global from ManagedWin::reveal.
	(open): Make arg list reflect managedwin.itb.
	* library/managedwin.itb (window_name): Use class variable
	_top instead of recomputing the toplevel every time.
	(reveal): Ditto.
	Use class variable "_geometry" instead of global variable.
	(shutdown): Do not save ModalDialogs.
	(_create): If centering the new window, use libgui's
	center_window to do it.

Patch:
Index: library/managedwin.ith
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/managedwin.ith,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -p -r1.4 -r1.5
--- managedwin.ith      2001/03/01 20:00:12     1.4
+++ managedwin.ith      2001/05/18 22:57:30     1.5
@@ -27,7 +27,7 @@ class ManagedWin {
     method window_name {wname {iname ""}}

     proc find {win}
-    proc open {args}
+    proc open {class args}
     proc open_dlg {class args}
     proc init {}
     proc restart {}
@@ -38,6 +38,9 @@ class ManagedWin {
   protected {
     # The Tk's toplevel window for this ManagedWin
     variable _top
+
+    # Variable which holds the geometry of this window
+    variable _geometry {}

     # this is the counter of TopLevelWins open
     # when it hits 0, exit.
Index: library/managedwin.itb
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/managedwin.itb,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -p -r1.13 -r1.14
--- managedwin.itb      2001/04/10 15:49:06     1.13
+++ managedwin.itb      2001/05/18 22:57:30     1.14
@@ -38,15 +38,14 @@ body ManagedWin::destructor {} {

 # ------------------------------------------------------------
 #  PUBLIC METHOD:  window_name - Set the name of the window
-#   (and optionally it's icon's name).
+#   (and optionally its icon's name).
 # ------------------------------------------------------------
 body ManagedWin::window_name {wname {iname ""}} {
-  set top [winfo toplevel [namespace tail $this]]
-  wm title $top $wname
+  wm title $_top $wname
   if {$iname != ""} {
-    wm iconname $top $iname
+    wm iconname $_top $iname
   } else {
-    wm iconname $top $wname
+    wm iconname $_top $wname
   }
 }

@@ -66,19 +65,16 @@ body ManagedWin::reveal {} {
   # Do this update to flush all changes before deiconifying the window.
   update idletasks

-  set top [winfo toplevel [namespace tail $this]]
-  set g [wm geometry $top]
-  #debug "$top geometry=$g state=[wm state $top]"
-  raise $top
-  wm deiconify $top
-  if {[info exists ::$top._init_geometry]} {
-    upvar ::$top._init_geometry gm
-    if {$::tcl_platform(platform) == "unix"} {
-      wm geometry $top $gm
-    }
-    unset ::$top._init_geometry
+  raise $_top
+  wm deiconify $_top
+  # Some window managers (on unix) fail to honor the geometry unless
+  # the window is visible.
+  if {$_geometry != "" && $::tcl_platform(platform) == "unix"} {
+    wm geometry $_top $_geometry
+    set _geometry ""
   }
-  #debug "$top geometry=[wm geometry $top] state=[wm state $top]"
+
+  #debug "$_top geometry=[wm geometry $_top] state=[wm state $_top]"

   # There used to be a `focus -force' here, but using -force is
   # unfriendly, so it was removed.  It was then replaced with a simple
@@ -90,7 +86,7 @@ body ManagedWin::reveal {} {
   # register window on top of the source window, but the source window
   # will have the focus. This is not the proper model for Windows.
   if {$::tcl_platform(platform) == "windows"} {
-    focus -force [focus -lastfor $top]
+    focus -force [focus -lastfor $_top]
   }
 }

@@ -118,9 +114,11 @@ body ManagedWin::restart {} {
 body ManagedWin::shutdown {} {
   set activeWins {}
   foreach win [itcl_info objects -isa ManagedWin] {
-    set g [wm geometry [winfo toplevel [namespace tail $win]]]
-    pref setd gdb/geometry/[namespace tail $win] $g
-    lappend activeWins [$win pickle]
+    if {![$win isa ModalDialog]} {
+      set g [wm geometry [winfo toplevel [namespace tail $win]]]
+      pref setd gdb/geometry/[namespace tail $win] $g
+      lappend activeWins [$win pickle]
+    }
   }
   pref set gdb/window/active $activeWins
 }
@@ -244,20 +242,11 @@ body ManagedWin::_create { class args }

   wm maxsize $top $_screenwidth $_screenheight
   wm minsize $top 20 20
-
-  if {$over != ""} {
-    # center new window over widget
-    set t [winfo toplevel [namespace tail $over]]
-    set cx [expr {[winfo rootx $t] + [winfo width $t] / 2}]
-    set cy [expr {[winfo rooty $t] + [winfo height $t] / 2}]
-    set x [expr {$cx - [winfo reqwidth $top] / 2}]
-    set y [expr {$cy - [winfo reqheight $top] / 2}]
-    wm geometry $top +$x+$y
-  } elseif {$center} {
-    # center the window on the screen
-    set x [expr {[winfo screenwidth $top] / 2 - [winfo reqwidth $top] / 2}]
-    set y [expr {[winfo screenheight $top] / 2 - [winfo reqheight $top] / 2}]
-    wm geometry $top +$x+$y
+  update idletasks
+
+  if {$over != "" || $center} {
+    # center new window
+    center_window $top -over $over
   }

   if {$transient} {
@@ -353,7 +342,7 @@ body ManagedWin::destroy_toplevel {} {
 }

 # ------------------------------------------------------------
-#  PRIVATE METHOD:  _freeze_me
+#  PROTECTED METHOD:  _freeze_me
 # ------------------------------------------------------------
 body ManagedWin::_freeze_me {} {
   $_top configure -cursor watch
@@ -361,7 +350,7 @@ body ManagedWin::_freeze_me {} {
 }

 # ------------------------------------------------------------
-#  PRIVATE METHOD: _thaw_me
+#  PROTECTED METHOD: _thaw_me
 # ------------------------------------------------------------
 body ManagedWin::_thaw_me {} {




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]