Tk Source Code

Check-in [d9be2b12]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:TIP #359: Extended Window Manager Hints support for 8.4
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-4-branch
Files: files | file ages | folders
SHA1: d9be2b12d7a3c20e85d7025e31bdda45b528148b
User & Date: patthoyts 2010-01-23 01:36:03
Context
2010-01-23
11:30
Fix test for the ewmh attributes addition check-in: a325f76b user: patthoyts tags: core-8-4-branch
01:36
TIP #359: Extended Window Manager Hints support for 8.4 check-in: d9be2b12 user: patthoyts tags: core-8-4-branch
2009-12-11
11:18
[Bug 2912473]: Stop problems caused by display names with a double colon in. check-in: ab74dd2e user: dkf tags: core-8-4-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.











1
2
3
4
5
6
7










2009-12-11  Donal K. Fellows  <[email protected]>

	* library/tk.tcl (::tk::ScreenChanged): [Bug 2912473]: Stop problems
	caused by display names with a double colon in.

2009-11-01  Joe Mistachkin  <[email protected]>

>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2010-01-23  Pat Thoyts  <[email protected]>

	* library/bgerror.tcl: [TIP #359]: Extended Window Manager Hints
	* library/clrpick.tcl: backported from 8.5 for use on X11.
	* library/dialog.tcl:
	* library/msgbox.tcl:
	* library/tkfbox.tcl:
	* tests/unixWm.test:
	* unix/tkUnixWm.c:

2009-12-11  Donal K. Fellows  <[email protected]>

	* library/tk.tcl (::tk::ScreenChanged): [Bug 2912473]: Stop problems
	caused by display names with a double colon in.

2009-11-01  Joe Mistachkin  <[email protected]>

Changes to library/bgerror.tcl.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# bgerror.tcl --
#
#	Implementation of the bgerror procedure.  It posts a dialog box with
#	the error message and gives the user a chance to see a more detailed
#	stack trace, and possible do something more interesting with that
#	trace (like save it to a log).  This is adapted from work done by
#	Donal K. Fellows.
#
# Copyright (c) 1998-2000 by Ajuba Solutions.
# Copyright (c) 2007 Daniel A. Steffen <[email protected]>
# 
# RCS: @(#) $Id: bgerror.tcl,v 1.23.2.9 2007/11/09 06:26:54 das Exp $
# $Id: bgerror.tcl,v 1.23.2.9 2007/11/09 06:26:54 das Exp $

namespace eval ::tk::dialog::error {
    namespace import -force ::tk::msgcat::*
    namespace export bgerror
    option add *ErrorDialog.function.text [mc "Save To Log"] \
	widgetDefault
    option add *ErrorDialog.function.command [namespace code SaveToLog]











|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# bgerror.tcl --
#
#	Implementation of the bgerror procedure.  It posts a dialog box with
#	the error message and gives the user a chance to see a more detailed
#	stack trace, and possible do something more interesting with that
#	trace (like save it to a log).  This is adapted from work done by
#	Donal K. Fellows.
#
# Copyright (c) 1998-2000 by Ajuba Solutions.
# Copyright (c) 2007 Daniel A. Steffen <[email protected]>
# 
# RCS: @(#) $Id: bgerror.tcl,v 1.23.2.10 2010/01/23 01:36:03 patthoyts Exp $
# $Id: bgerror.tcl,v 1.23.2.10 2010/01/23 01:36:03 patthoyts Exp $

namespace eval ::tk::dialog::error {
    namespace import -force ::tk::msgcat::*
    namespace export bgerror
    option add *ErrorDialog.function.text [mc "Save To Log"] \
	widgetDefault
    option add *ErrorDialog.function.command [namespace code SaveToLog]
145
146
147
148
149
150
151


152
153
154
155
156
157
158
    wm title .bgerrorDialog $title
    wm iconname .bgerrorDialog ErrorDialog
    wm protocol .bgerrorDialog WM_DELETE_WINDOW { }

    if {($tcl_platform(platform) eq "macintosh")
            || ($windowingsystem eq "aqua")} {
	::tk::unsupported::MacWindowStyle style .bgerrorDialog moveableAlert {}


    }

    frame .bgerrorDialog.bot
    frame .bgerrorDialog.top
    if {$windowingsystem eq "x11"} {
	.bgerrorDialog.bot configure -relief raised -bd 1
	.bgerrorDialog.top configure -relief raised -bd 1







>
>







145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
    wm title .bgerrorDialog $title
    wm iconname .bgerrorDialog ErrorDialog
    wm protocol .bgerrorDialog WM_DELETE_WINDOW { }

    if {($tcl_platform(platform) eq "macintosh")
            || ($windowingsystem eq "aqua")} {
	::tk::unsupported::MacWindowStyle style .bgerrorDialog moveableAlert {}
    } elseif {$windowingsystem eq "x11"} {
	wm attributes .bgerrorDialog -type dialog
    }

    frame .bgerrorDialog.bot
    frame .bgerrorDialog.top
    if {$windowingsystem eq "x11"} {
	.bgerrorDialog.bot configure -relief raised -bd 1
	.bgerrorDialog.top configure -relief raised -bd 1

Changes to library/clrpick.tcl.

1
2
3
4
5
6
7
8
9
10
11
12
13
# clrpick.tcl --
#
#	Color selection dialog for platforms that do not support a
#	standard color selection dialog.
#
# RCS: @(#) $Id: clrpick.tcl,v 1.20.2.2 2006/03/17 10:50:11 patthoyts Exp $
#
# Copyright (c) 1996 Sun Microsystems, Inc.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# ToDo:





|







1
2
3
4
5
6
7
8
9
10
11
12
13
# clrpick.tcl --
#
#	Color selection dialog for platforms that do not support a
#	standard color selection dialog.
#
# RCS: @(#) $Id: clrpick.tcl,v 1.20.2.3 2010/01/23 01:36:03 patthoyts Exp $
#
# Copyright (c) 1996 Sun Microsystems, Inc.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# ToDo:
70
71
72
73
74
75
76

77
78
79
80
81
82
83
    set sc [winfo screen $data(-parent)]
    set winExists [winfo exists $w]
    if {!$winExists || $sc ne [winfo screen $w]} {
	if {$winExists} {
	    destroy $w
	}
	toplevel $w -class TkColorDialog -screen $sc

	BuildDialog $w
    }

    # Dialog boxes should be transient with respect to their parent,
    # so that they will always stay on top of their parent window.  However,
    # some window managers will create the window as withdrawn if the parent
    # window is withdrawn or iconified.  Combined with the grab we put on the







>







70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
    set sc [winfo screen $data(-parent)]
    set winExists [winfo exists $w]
    if {!$winExists || $sc ne [winfo screen $w]} {
	if {$winExists} {
	    destroy $w
	}
	toplevel $w -class TkColorDialog -screen $sc
	if {[tk windowingsystem] eq "x11"} {wm attributes $w -type dialog}
	BuildDialog $w
    }

    # Dialog boxes should be transient with respect to their parent,
    # so that they will always stay on top of their parent window.  However,
    # some window managers will create the window as withdrawn if the parent
    # window is withdrawn or iconified.  Combined with the grab we put on the

Changes to library/dialog.tcl.

1
2
3
4
5
6
7
8
9
10
11
12
13
# dialog.tcl --
#
# This file defines the procedure tk_dialog, which creates a dialog
# box containing a bitmap, a message, and one or more buttons.
#
# RCS: @(#) $Id: dialog.tcl,v 1.14.2.5 2007/05/30 06:37:03 das Exp $
#
# Copyright (c) 1992-1993 The Regents of the University of California.
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#





|







1
2
3
4
5
6
7
8
9
10
11
12
13
# dialog.tcl --
#
# This file defines the procedure tk_dialog, which creates a dialog
# box containing a bitmap, a message, and one or more buttons.
#
# RCS: @(#) $Id: dialog.tcl,v 1.14.2.6 2010/01/23 01:36:03 patthoyts Exp $
#
# Copyright (c) 1992-1993 The Regents of the University of California.
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
71
72
73
74
75
76
77


78
79
80
81
82
83
84
    #
    if {[winfo viewable [winfo toplevel [winfo parent $w]]] } {
	wm transient $w [winfo toplevel [winfo parent $w]]
    }

    if {$tcl_platform(platform) eq "macintosh" || $windowingsystem eq "aqua"} {
	::tk::unsupported::MacWindowStyle style $w moveableModal {}


    }

    frame $w.bot
    frame $w.top
    if {$windowingsystem eq "x11"} {
	$w.bot configure -relief raised -bd 1
	$w.top configure -relief raised -bd 1







>
>







71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
    #
    if {[winfo viewable [winfo toplevel [winfo parent $w]]] } {
	wm transient $w [winfo toplevel [winfo parent $w]]
    }

    if {$tcl_platform(platform) eq "macintosh" || $windowingsystem eq "aqua"} {
	::tk::unsupported::MacWindowStyle style $w moveableModal {}
    } elseif {$windowingsystem eq "x11"} {
	wm attributes $w -type dialog
    }

    frame $w.bot
    frame $w.top
    if {$windowingsystem eq "x11"} {
	$w.bot configure -relief raised -bd 1
	$w.top configure -relief raised -bd 1

Changes to library/msgbox.tcl.

1
2
3
4
5
6
7
8
9
10
11
12
13
# msgbox.tcl --
#
#	Implements messageboxes for platforms that do not have native
#	messagebox support.
#
# RCS: @(#) $Id: msgbox.tcl,v 1.24.2.4 2007/05/30 06:37:03 das Exp $
#
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#






|







1
2
3
4
5
6
7
8
9
10
11
12
13
# msgbox.tcl --
#
#	Implements messageboxes for platforms that do not have native
#	messagebox support.
#
# RCS: @(#) $Id: msgbox.tcl,v 1.24.2.5 2010/01/23 01:36:03 patthoyts Exp $
#
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#

259
260
261
262
263
264
265


266
267
268
269
270
271
272
    #
    if {[winfo viewable [winfo toplevel $data(-parent)]] } {
	wm transient $w $data(-parent)
    }    

    if {$windowingsystem eq "classic" || $windowingsystem eq "aqua"} {
	::tk::unsupported::MacWindowStyle style $w moveableModal {}


    }

    frame $w.bot -background $bg
    pack $w.bot -side bottom -fill both
    frame $w.top -background $bg
    pack $w.top -side top -fill both -expand 1
    if {$windowingsystem ne "classic" && $windowingsystem ne "aqua"} {







>
>







259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
    #
    if {[winfo viewable [winfo toplevel $data(-parent)]] } {
	wm transient $w $data(-parent)
    }    

    if {$windowingsystem eq "classic" || $windowingsystem eq "aqua"} {
	::tk::unsupported::MacWindowStyle style $w moveableModal {}
    } elseif {$windowingsystem eq "x11"} {
        wm attributes $w -type dialog
    }

    frame $w.bot -background $bg
    pack $w.bot -side bottom -fill both
    frame $w.top -background $bg
    pack $w.top -side top -fill both -expand 1
    if {$windowingsystem ne "classic" && $windowingsystem ne "aqua"} {

Changes to library/tkfbox.tcl.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# tkfbox.tcl --
#
#	Implements the "TK" standard file selection dialog box. This
#	dialog box is used on the Unix platforms whenever the tk_strictMotif
#	flag is not set.
#
#	The "TK" standard file selection dialog box is similar to the
#	file selection dialog box on Win95(TM). The user can navigate
#	the directories by clicking on the folder icons or by
#	selecting the "Directory" option menu. The user can select
#	files by clicking on the file icons or by entering a filename
#	in the "Filename:" entry.
#
# RCS: @(#) $Id: tkfbox.tcl,v 1.38.2.13 2007/02/19 23:53:36 hobbs Exp $
#
# Copyright (c) 1994-1998 Sun Microsystems, Inc.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#














|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# tkfbox.tcl --
#
#	Implements the "TK" standard file selection dialog box. This
#	dialog box is used on the Unix platforms whenever the tk_strictMotif
#	flag is not set.
#
#	The "TK" standard file selection dialog box is similar to the
#	file selection dialog box on Win95(TM). The user can navigate
#	the directories by clicking on the folder icons or by
#	selecting the "Directory" option menu. The user can select
#	files by clicking on the file icons or by entering a filename
#	in the "Filename:" entry.
#
# RCS: @(#) $Id: tkfbox.tcl,v 1.38.2.14 2010/01/23 01:36:03 patthoyts Exp $
#
# Copyright (c) 1994-1998 Sun Microsystems, Inc.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#

997
998
999
1000
1001
1002
1003

1004
1005
1006
1007
1008
1009
1010
proc ::tk::dialog::file::Create {w class} {
    set dataName [lindex [split $w .] end]
    upvar ::tk::dialog::file::$dataName data
    variable ::tk::Priv
    global tk_library

    toplevel $w -class $class


    # f1: the frame with the directory option menu
    #
    set f1 [frame $w.f1]
    bind [::tk::AmpWidget label $f1.lab -text "[mc "&Directory:"]" ] \
	<<AltUnderlined>> [list focus $f1.menu]
    







>







997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
proc ::tk::dialog::file::Create {w class} {
    set dataName [lindex [split $w .] end]
    upvar ::tk::dialog::file::$dataName data
    variable ::tk::Priv
    global tk_library

    toplevel $w -class $class
    if {[tk windowingsystem] eq "x11"} {wm attributes $w -type dialog}

    # f1: the frame with the directory option menu
    #
    set f1 [frame $w.f1]
    bind [::tk::AmpWidget label $f1.lab -text "[mc "&Directory:"]" ] \
	<<AltUnderlined>> [list focus $f1.menu]
    

Changes to tests/unixWm.test.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# This file is a Tcl script to test out Tk's interactions with
# the window manager, including the "wm" command.  It is organized
# in the standard fashion for Tcl tests.
#
# Copyright (c) 1992-1994 The Regents of the University of California.
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
# RCS: @(#) $Id: unixWm.test,v 1.29.2.4 2005/01/14 21:09:47 jenglish Exp $

package require tcltest 2.2
namespace import -force tcltest::configure
namespace import -force tcltest::testsDirectory
configure -testdir [file join [pwd] [file dirname [info script]]]
configure -loadfile [file join [testsDirectory] constraints.tcl]
tcltest::loadTestedCommands









|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# This file is a Tcl script to test out Tk's interactions with
# the window manager, including the "wm" command.  It is organized
# in the standard fashion for Tcl tests.
#
# Copyright (c) 1992-1994 The Regents of the University of California.
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
# RCS: @(#) $Id: unixWm.test,v 1.29.2.5 2010/01/23 01:36:03 patthoyts Exp $

package require tcltest 2.2
namespace import -force tcltest::configure
namespace import -force tcltest::testsDirectory
configure -testdir [file join [pwd] [file dirname [info script]]]
configure -loadfile [file join [testsDirectory] constraints.tcl]
tcltest::loadTestedCommands
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418






































2419
2420
2421
2422
2423
    list $error $msg
} {0 {}}

test unixWm-60.1 {wm attributes} unix {
    destroy .t
    toplevel .t
    wm attributes .t
} {}
test unixWm-60.2 {wm attributes} unix {
    destroy .t
    toplevel .t
    list [catch {wm attributes .t -foo} msg] $msg
} {1 {wrong # args: should be "wm attributes window"}}

test unixWm-61.1 {Tk_WmCmd procedure, "iconphoto" option} unix {
    list [catch {wm iconph .} msg] $msg
} {1 {wrong # args: should be "wm iconphoto window ?-default? image1 ?image2 ...?"}}
test unixWm-61.2 {Tk_WmCmd procedure, "iconphoto" option} unix {
    destroy .t
    toplevel .t
    image create photo blank16 -width 16 -height 16
    image create photo blank32 -width 32 -height 32
    # This should just make blank icons for the window
    wm iconphoto .t blank16 blank32
    image delete blank16 blank32
} {}







































# cleanup
catch {destroy .t}
::tcltest::cleanupTests
return







|




|













>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>





2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
    list $error $msg
} {0 {}}

test unixWm-60.1 {wm attributes} unix {
    destroy .t
    toplevel .t
    wm attributes .t
} {-type {}}
test unixWm-60.2 {wm attributes} unix {
    destroy .t
    toplevel .t
    list [catch {wm attributes .t -foo} msg] $msg
} {1 {wrong # args: should be "wm attributes window ?-type list?"}}

test unixWm-61.1 {Tk_WmCmd procedure, "iconphoto" option} unix {
    list [catch {wm iconph .} msg] $msg
} {1 {wrong # args: should be "wm iconphoto window ?-default? image1 ?image2 ...?"}}
test unixWm-61.2 {Tk_WmCmd procedure, "iconphoto" option} unix {
    destroy .t
    toplevel .t
    image create photo blank16 -width 16 -height 16
    image create photo blank32 -width 32 -height 32
    # This should just make blank icons for the window
    wm iconphoto .t blank16 blank32
    image delete blank16 blank32
} {}

test unixWm-62.0 {wm attributes -type void} unix {
    destroy .t
    toplevel .t
    set r [list [catch {wm attributes .t -type {}} err] $err]
    destroy .t
    set r
} {0 {}}
test unixWm-62.1 {wm attributes -type name} unix {
    destroy .t
    toplevel .t
    set r [list [catch {wm attributes .t -type dialog} err] $err]
    destroy .t
    set r
} {0 {}}
test unixWm-62.1 {wm attributes -type name} unix {
    destroy .t
    toplevel .t
    tkwait visibility .t
    set r [list [catch {wm attributes .t -type dialog} err] $err]
    destroy .t
    set r
} {0 {}}
test unixWm-62.2 {wm attributes -type list} unix {
    destroy .t
    toplevel .t
    set r [list [catch {wm attributes .t -type {xyzzy dialog}} err] $err]
    destroy .t
    set r
} {0 {}}
test unixWm-62.2 {wm attributes -type list} unix {
    destroy .t
    toplevel .t
    tkwait visibility .t
    set r [list [catch {wm attributes .t -type {xyzzy dialog}} err] $err]
    destroy .t
    set r
} {0 {}}

# cleanup
catch {destroy .t}
::tcltest::cleanupTests
return

Changes to unix/tkUnixWm.c.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 *
 * Copyright (c) 1991-1994 The Regents of the University of California.
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tkUnixWm.c,v 1.36.2.7 2006/04/11 20:23:45 hobbs Exp $
 */

#include "tkPort.h"
#include "tkInt.h"
#include "tkUnixInt.h"

/*







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 *
 * Copyright (c) 1991-1994 The Regents of the University of California.
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tkUnixWm.c,v 1.36.2.8 2010/01/23 01:36:03 patthoyts Exp $
 */

#include "tkPort.h"
#include "tkInt.h"
#include "tkUnixInt.h"

/*
320
321
322
323
324
325
326





327
328
329
330
331
332
333
			    int *maxWidthPtr, int *maxHeightPtr));
static void		MenubarDestroyProc _ANSI_ARGS_((ClientData clientData,
			    XEvent *eventPtr));
static int		ParseGeometry _ANSI_ARGS_((Tcl_Interp *interp,
			    char *string, TkWindow *winPtr));
static void		ReparentEvent _ANSI_ARGS_((WmInfo *wmPtr,
			    XReparentEvent *eventPtr));





static void		TkWmStackorderToplevelWrapperMap _ANSI_ARGS_((
			    TkWindow *winPtr,
			    Display *display,
			    Tcl_HashTable *reparentTable));
static void		TopLevelReqProc _ANSI_ARGS_((ClientData dummy,
			    Tk_Window tkwin));
static void		UpdateCommand _ANSI_ARGS_((TkWindow *winPtr));







>
>
>
>
>







320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
			    int *maxWidthPtr, int *maxHeightPtr));
static void		MenubarDestroyProc _ANSI_ARGS_((ClientData clientData,
			    XEvent *eventPtr));
static int		ParseGeometry _ANSI_ARGS_((Tcl_Interp *interp,
			    char *string, TkWindow *winPtr));
static void		ReparentEvent _ANSI_ARGS_((WmInfo *wmPtr,
			    XReparentEvent *eventPtr));
static int		SetNetWmType _ANSI_ARGS_((TkWindow *winPtr,
			    Tcl_Obj *typePtr));
static Tcl_Obj *	GetNetWmType _ANSI_ARGS_((TkWindow *winPtr));
static void		TkSetTransientFor _ANSI_ARGS_((Tk_Window tkwin,
			    Tk_Window parent));
static void		TkWmStackorderToplevelWrapperMap _ANSI_ARGS_((
			    TkWindow *winPtr,
			    Display *display,
			    Tcl_HashTable *reparentTable));
static void		TopLevelReqProc _ANSI_ARGS_((ClientData dummy,
			    Tk_Window tkwin));
static void		UpdateCommand _ANSI_ARGS_((TkWindow *winPtr));
1202
1203
1204
1205
1206
1207
1208
1209








1210
1211
1212


1213


1214
1215
1216
1217
1218
1219
1220
WmAttributesCmd(tkwin, winPtr, interp, objc, objv)
    Tk_Window tkwin;		/* Main window of the application. */
    TkWindow *winPtr;           /* Toplevel to work with */
    Tcl_Interp *interp;		/* Current interpreter. */
    int objc;			/* Number of arguments. */
    Tcl_Obj *CONST objv[];	/* Argument objects. */
{
    if (objc != 3) {








	Tcl_WrongNumArgs(interp, 2, objv, "window");
	return TCL_ERROR;
    }


    return TCL_OK;


}

/*
 *----------------------------------------------------------------------
 *
 * WmClientCmd --
 *







|
>
>
>
>
>
>
>
>
|


>
>
|
>
>







1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
WmAttributesCmd(tkwin, winPtr, interp, objc, objv)
    Tk_Window tkwin;		/* Main window of the application. */
    TkWindow *winPtr;           /* Toplevel to work with */
    Tcl_Interp *interp;		/* Current interpreter. */
    int objc;			/* Number of arguments. */
    Tcl_Obj *CONST objv[];	/* Argument objects. */
{
    if (objc < 4) {
	Tcl_Obj *listObj = Tcl_NewListObj(0, NULL);
	Tcl_ListObjAppendElement(interp, listObj,
		Tcl_NewStringObj("-type", -1));
	Tcl_ListObjAppendElement(interp, listObj, GetNetWmType(winPtr));
	Tcl_SetObjResult(interp, listObj);
	return TCL_OK;
    }	
    if (objc > 5 || strcmp("-type", Tcl_GetString(objv[3]))) {
	Tcl_WrongNumArgs(interp, 2, objv, "window ?-type list?");
	return TCL_ERROR;
    }
    if (objc == 4) {
	Tcl_SetObjResult(interp, GetNetWmType(winPtr));
	return TCL_OK;
    }
    return SetNetWmType(winPtr, objv[4]);
}

/*
 *----------------------------------------------------------------------
 *
 * WmClientCmd --
 *
4838
4839
4840
4841
4842
4843
4844































































































































4845
4846
4847
4848
4849
4850
4851
    WmInfo *wmPtr = winPtr->wmInfoPtr;

    if (wmPtr->flags & WM_NEVER_MAPPED) {
	return;
    }
    XSetWMHints(winPtr->display, wmPtr->wrapperPtr->window, &wmPtr->hints);
}
































































































































/*
 *--------------------------------------------------------------
 *
 * ParseGeometry --
 *
 *	This procedure parses a geometry string and updates







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
    WmInfo *wmPtr = winPtr->wmInfoPtr;

    if (wmPtr->flags & WM_NEVER_MAPPED) {
	return;
    }
    XSetWMHints(winPtr->display, wmPtr->wrapperPtr->window, &wmPtr->hints);
}

/*
 *----------------------------------------------------------------------
 *
 * SetNetWmType --
 *
 *	Set the extended window manager hints for a toplevel window
 *	to the types provided. The specification states that this
 *	may be a list of window types in preferred order. To permit
 *	for future type definitions, the set of names is unconstrained
 *	and names are converted to upper-case and appended to
 *	"_NET_WM_WINDOW_TYPE_" before being converted to an Atom.
 *
 *----------------------------------------------------------------------
 */

static int
SetNetWmType(winPtr, typePtr)
    TkWindow *winPtr;
    Tcl_Obj *typePtr;
{
    Atom typeAtom, *atoms = NULL;
    WmInfo *wmPtr;
    TkWindow *wrapperPtr;
    Tcl_Obj **objv;
    int objc, n;
    Tk_Window tkwin = (Tk_Window)winPtr;
    Tcl_Interp *interp = winPtr->mainPtr->interp;

    if (TCL_OK != Tcl_ListObjGetElements(interp, typePtr, &objc, &objv)) {
	return TCL_ERROR;
    }

    if (!Tk_HasWrapper(tkwin)) {
	return TCL_OK; /* error?? */
    }

    if (objc > 0) {
	atoms = (Atom *)ckalloc(sizeof(Atom) * objc);
    }

    for (n = 0; n < objc; ++n) {
	Tcl_DString ds, dsName;
	int len;
	char *name = Tcl_GetStringFromObj(objv[n], &len);
	Tcl_UtfToUpper(name);
	Tcl_UtfToExternalDString(NULL, name, len, &dsName);
	Tcl_DStringInit(&ds);
	Tcl_DStringAppend(&ds, "_NET_WM_WINDOW_TYPE_", 20);
	Tcl_DStringAppend(&ds, Tcl_DStringValue(&dsName),
		Tcl_DStringLength(&dsName));
	Tcl_DStringFree(&dsName);
	atoms[n] = Tk_InternAtom(tkwin, Tcl_DStringValue(&ds));
	Tcl_DStringFree(&ds);
    }

    wmPtr = winPtr->wmInfoPtr;
    if (wmPtr->wrapperPtr == NULL) {
	CreateWrapper(wmPtr);
    }
    wrapperPtr = wmPtr->wrapperPtr;

    typeAtom = Tk_InternAtom(tkwin, "_NET_WM_WINDOW_TYPE");
    XChangeProperty(Tk_Display(tkwin), wrapperPtr->window, typeAtom,
	XA_ATOM, 32, PropModeReplace, (unsigned char *) atoms, objc);

    ckfree((char *)atoms);
    return TCL_OK;
}

/*
 *----------------------------------------------------------------------
 *
 * GetNetWmType --
 *
 *	Read the extended window manager type hint from a window
 *	and return as a list of names suitable for use with 
 *	SetNetWmType.
 *
 *----------------------------------------------------------------------
 */

static Tcl_Obj *
GetNetWmType(winPtr)
    TkWindow *winPtr;
{
    Atom typeAtom, actualType, *atoms;
    int actualFormat;
    unsigned long n, count, bytesAfter;
    unsigned char *propertyValue = NULL;
    long maxLength = 1024;
    Tk_Window tkwin = (Tk_Window)winPtr;
    TkWindow *wrapperPtr;
    Tcl_Obj *typePtr;
    Tcl_Interp *interp;
    Tcl_DString ds;

    interp = winPtr->mainPtr->interp;
    typePtr = Tcl_NewListObj(0, NULL);

    if (winPtr->wmInfoPtr->wrapperPtr == NULL) {
	CreateWrapper(winPtr->wmInfoPtr);
    }
    wrapperPtr = winPtr->wmInfoPtr->wrapperPtr;

    typeAtom = Tk_InternAtom(tkwin, "_NET_WM_WINDOW_TYPE");
    if (Success == XGetWindowProperty(wrapperPtr->display,
	    wrapperPtr->window, typeAtom, 0L, maxLength, False,
	    XA_ATOM, &actualType, &actualFormat, &count,
	    &bytesAfter, &propertyValue)) {
	atoms = (Atom *)propertyValue;
	for (n = 0; n < count; ++n) {
	    const char *name = Tk_GetAtomName(tkwin, atoms[n]);
	    if (strncmp("_NET_WM_WINDOW_TYPE_", name, 20) == 0) {
		Tcl_ExternalToUtfDString(NULL, name+20, -1, &ds);
		Tcl_UtfToLower(Tcl_DStringValue(&ds));
		Tcl_ListObjAppendElement(interp, typePtr,
			Tcl_NewStringObj(Tcl_DStringValue(&ds),
				Tcl_DStringLength(&ds)));
		Tcl_DStringFree(&ds);
	    }
	}
	XFree(propertyValue);
    }

    return typePtr;
}

/*
 *--------------------------------------------------------------
 *
 * ParseGeometry --
 *
 *	This procedure parses a geometry string and updates
6112
6113
6114
6115
6116
6117
6118


























6119
6120
6121
6122
6123
6124
6125
	*maxHeightPtr = tmp;
    }
}

/*
 *----------------------------------------------------------------------
 *


























 * TkpMakeMenuWindow --
 *
 *	Configure the window to be either a pull-down (or pop-up)
 *	menu, or as a toplevel (torn-off) menu or palette.
 *
 * Results:
 *	None.







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
	*maxHeightPtr = tmp;
    }
}

/*
 *----------------------------------------------------------------------
 *
 * TkSetTransientFor --
 *
 *	Set a Tk window to be transient with reference to a specified
 *	parent or the toplevel ancestor if None is passed as parent.
 *
 *----------------------------------------------------------------------
 */

static void
TkSetTransientFor(tkwin, parent)
    Tk_Window tkwin;
    Tk_Window parent;
{
    if (parent == None) {
	parent = Tk_Parent(tkwin);
	while (!Tk_IsTopLevel(parent))
	    parent = Tk_Parent(tkwin);
    }
    XSetTransientForHint(Tk_Display(tkwin),
	((TkWindow *)tkwin)->wmInfoPtr->wrapperPtr->window,
	((TkWindow *)parent)->wmInfoPtr->wrapperPtr->window);
}

/*
 *----------------------------------------------------------------------
 *
 * TkpMakeMenuWindow --
 *
 *	Configure the window to be either a pull-down (or pop-up)
 *	menu, or as a toplevel (torn-off) menu or palette.
 *
 * Results:
 *	None.
6138
6139
6140
6141
6142
6143
6144

6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156

6157
6158
6159


6160

6161
6162
6163
6164
6165
6166
6167
				 * menu is always visible, e.g. as a torn-off
				 * menu.  Determines whether save_under and
				 * override_redirect should be set. */
{
    WmInfo *wmPtr;
    XSetWindowAttributes atts;
    TkWindow *wrapperPtr;


    if (!Tk_HasWrapper(tkwin)) {
	return;
    }
    wmPtr = ((TkWindow *) tkwin)->wmInfoPtr;
    if (wmPtr->wrapperPtr == NULL) {
	CreateWrapper(wmPtr);
    }
    wrapperPtr = wmPtr->wrapperPtr;
    if (transient) {
	atts.override_redirect = True;
	atts.save_under = True;

    } else {
	atts.override_redirect = False;
	atts.save_under = False;


    }


    /*
     * The override-redirect and save-under bits must be set on the
     * wrapper window in order to have the desired effect.  However,
     * also set the override-redirect bit on the window itself, so
     * that the "wm overrideredirect" command will see it.
     */







>












>



>
>

>







6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
				 * menu is always visible, e.g. as a torn-off
				 * menu.  Determines whether save_under and
				 * override_redirect should be set. */
{
    WmInfo *wmPtr;
    XSetWindowAttributes atts;
    TkWindow *wrapperPtr;
    Tcl_Obj *typeObj;

    if (!Tk_HasWrapper(tkwin)) {
	return;
    }
    wmPtr = ((TkWindow *) tkwin)->wmInfoPtr;
    if (wmPtr->wrapperPtr == NULL) {
	CreateWrapper(wmPtr);
    }
    wrapperPtr = wmPtr->wrapperPtr;
    if (transient) {
	atts.override_redirect = True;
	atts.save_under = True;
	typeObj = Tcl_NewStringObj("dropdown_menu", -1);
    } else {
	atts.override_redirect = False;
	atts.save_under = False;
	typeObj = Tcl_NewStringObj("menu", -1);
	TkSetTransientFor(tkwin, None);
    }
    SetNetWmType((TkWindow *)tkwin, typeObj);

    /*
     * The override-redirect and save-under bits must be set on the
     * wrapper window in order to have the desired effect.  However,
     * also set the override-redirect bit on the window itself, so
     * that the "wm overrideredirect" command will see it.
     */