Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How does grab work on windows?

77 views
Skip to first unread message

Dave

unread,
Feb 15, 2017, 4:06:01 PM2/15/17
to
Win7x64 Tcl 8.6.6 (compiled w/ msys2 x64)

I've got a toplevel that's a "splash" window. From the grab docs, I got
the impression that a global grab would lock out >everything< except the
splash.

Currently, I create the splash toplevel and:

bind .splash <Button-1> {drag1 %w}; # Let user move splash window
proc drag1 {w} {
focus -force $w; # Added this so .splash gets keyboard events
:
}
bind .splash <Key-Escape> {
:
grab release .splash
after 0 [list destroy .splash]
}

wm deiconify .splash
focus -force .splash
grab -global .splash

This works as I expected until I click on another app's window -- then
that app gets control although the splash toplevel remains on top. The
now-active app responds to keyboard/mouse events. When I clicked on the
splash toplevel I found that I had to put a 'focus .splash' in the B1
binding or else it would not even receive keypress events.

Actually the only thing I noticed when using grab is that the Tk console
window could not be used. All other windows apps work as before.

Perhaps this is a windows thing...? Or more probable, I don't understand
grab.

--
computerjock AT mail DOT com

Kevin Walzer

unread,
Feb 15, 2017, 9:56:13 PM2/15/17
to
On 2/15/17 4:05 PM, Dave wrote:
> Perhaps this is a windows thing...? Or more probable, I don't understand
> grab.

"grab" only works as advertised on X11 because it's based on those
API's. These don't translate very well to Windows or Mac. On those
platforms it will force focus within the Tk application, but has no
effect on other windows.

--
Kevin Walzer
Code by Kevin/Mobile Code by Kevin
http://www.codebykevin.com
http://www.wtmobilesoftware.com

Mike Griffiths

unread,
Feb 16, 2017, 3:40:29 PM2/16/17
to
I'd suggest opening a ticket for this as a documentation bug, then, as the docs (http://www.tcl.tk/man/tcl/TkCmd/grab.htm) make no mention of differing behaviour. (At least on Win 7, it looks like it also disables (though doesn't hide) the WM stuff (move/resize/minimize, etc) for the grabbed window, and that should probably also be documented.)

Dave

unread,
Feb 18, 2017, 2:02:44 AM2/18/17
to
On 2/16/2017 2:40 PM, Mike Griffiths wrote:
>
> I'd suggest opening a ticket for this as a documentation bug, then, as the docs (http://www.tcl.tk/man/tcl/TkCmd/grab.htm) make no mention of differing behaviour. (At least on Win 7, it looks like it also disables (though doesn't hide) the WM stuff (move/resize/minimize, etc) for the grabbed window, and that should probably also be documented.)
>

Done (although I saw no category for documentation bug... I'm probably
blind).

Kevin Walzer

unread,
Feb 18, 2017, 11:49:49 AM2/18/17
to
It's global grab that doesn't work on Windows or Mac. That API is also
strongly discouraged as a Very Bad Thing on Linux because of its
potential to lock your machine. What's the rationale for using it?

--Kevin

Dave

unread,
Feb 18, 2017, 12:24:30 PM2/18/17
to
On 2/18/2017 10:49 AM, Kevin Walzer wrote:
>
> It's global grab that doesn't work on Windows or Mac. That API is also
> strongly discouraged as a Very Bad Thing on Linux because of its
> potential to lock your machine. What's the rationale for using it?
>
> --Kevin
>

Because at the time I thought it might be a good way to keep a "splash"
screen "on top". I've abandoned the idea.

Kevin Walzer

unread,
Feb 18, 2017, 12:33:59 PM2/18/17
to
wm atttributes .splash -topmost 1

Rich

unread,
Feb 18, 2017, 1:06:20 PM2/18/17
to
Dave <nor...@nohost.com> wrote:
> On 2/18/2017 10:49 AM, Kevin Walzer wrote:
>>
>> It's global grab that doesn't work on Windows or Mac. That API is
>> also strongly discouraged as a Very Bad Thing on Linux because of
>> its potential to lock your machine. What's the rationale for using
>> it?
>
> Because at the time I thought it might be a good way to keep a
> "splash" screen "on top". I've abandoned the idea.

But "grab" is not a "keep on top" attribute. It is a "prevent the user
from interacting with anything else" attribute.

Which is why global grab is frowned upon greatly, the user is stuck
waiting for whatever has grabbed everything to finally release the grab
before they can do anything. And if the task that did the grab hangs,
the user is left with rebooting as often their only option to get out
of the mess.

Donald Arseneau

unread,
Feb 21, 2017, 5:30:48 AM2/21/17
to
Kevin Walzer <k...@codebykevin.com> writes:

> On 2/15/17 4:05 PM, Dave wrote:
> > Perhaps this is a windows thing...? Or more probable, I don't understand
> > grab.
>
> "grab" only works as advertised on X11 because it's based on those
> API's.

global grab may not work on Linux either, as window manager or
desktop preferences can reject it. It is the presence of global
grab (and such) in Tk that may require "trusted" ssh to run
a tcl/tk program remotely
ssh -Y remote: gui.tcl

--
Donald Arseneau as...@triumf.ca
0 new messages