| Ticket UUID: | 572995 | |||
| Title: | Fix/test wm geom command | |||
| Type: | Patch | Version: | None | |
| Submitter: | mdejong | Created on: | 2002-06-24 07:26:00 | |
| Subsystem: | 65. Generic Window Operations | Assigned To: | hobbs | |
| Priority: | 5 Medium | Severity: | ||
| Status: | Pending | Last Modified: | 2026-10-04 07:56:20 | |
| Resolution: | None | Closed By: | ||
| Closed on: | ||||
| Description: |
This patch adds tests to the cross platform wm.test file while removing them from unixWm.test. These tests would have made it easier to catch bug 571600, for example. This patch does make one change, in the sense that something that did not raise an error in the past will raise an error in 8.4. A geom command like: wm geom . +1+-10 Is not valid. The implementation of ParseGeometry would incorrectly parse this y coord as a negative number even though the y coord sign (saved in the wmPtr->flags as WM_NEGATIVE_Y) would not be set. There were other variations like "+1--10" that would not raise an error while parsing but would not act correctly either. The docs for the geom command state that only a single - or + character can come before a x or y value. | |||
| User Comments: |
serhiy.storchaka added on 2026-10-04 07:56:20:
XParseGeometry accepts the same syntax: the offset after + or - can itself be signed, as in +1+-10 or +1--10, with the same meaning as in Tk. It also accepts + as the sign of the offset (+1++10) and X as the size separator, which Tk rejects. The wm manual page does not document signed offsets. dkf added on 2002-06-24 19:19:58: Logged In: YES
user_id=79902
With experience, [wm geom . +1+-10] is necessary for those
(hopefully rare) times when a window needs to be placed off
one of the edges. The problem comes when you have some code
to center a window, and the window is wider (or taller) than
the screen; the obvious way of doing it (see below) fails.
set x [expr {([winfo screenwidth .]-[winfo width .])/2}]
# Ditto for y...
wm geometry . [format {+%d+%d} $x $y]
I've had applications that failed on laptops (embarrasingly,
in front of a demo to my boss) because Tk threw an error,
and I don't want to go through *that* loop again.
mdejong added on 2002-06-24 15:18:24: Logged In: YES user_id=90858 Here is what the current docs have to say about it: wm geometry window ?newGeometry? If newGeometry is specified, then the geometry of window is changed and an empty string is returned. Otherwise the current geometry for window is returned (this is the most recent geometry speci- fied either by manual resizing or in a wm geometry command). NewGeometry has the form =widthx- height+-x+-y, where any of =, widthxheight, or +-x+-y may be omitted. Width and height are positive integers specifying the desired dimensions of window. The older docs read "±x±y" (I don't know how that will show up on your machine, but on mine it looks like a plus above a minus). At any rate, the point is that the x and y values should be positive. If you want to declare a negative y value it means start from the bottom of the screen (as in "-10-10"). The code in ParseGeometry was parsing off the initial + or - and then sending the rest to strtoul on unix and strtol on Win and Mac. That is not correct. Only a single + or - char should be allowed. The old code let junk like "+1--2" through. That contridicts the docs and I can't figure what it would be good for. hobbs added on 2002-06-24 14:34:56: Logged In: YES user_id=72656 In what way is +1+-10 invalid? It seems to do the expected thing (10 pixels about the top border), although I'm not sure what that is worth. mdejong added on 2002-06-24 14:26:00: File Added - 25684: wmgeom.patch2 | |||
Attachments:
- wmgeom.patch2 [download] added by mdejong on 2002-06-24 14:26:00. [details]
