Menu

#40 Win32: plot window steals focus

closed
5
2015-03-23
2002-01-02
legalize
No

When you issue the plot command on the Win32 version
of gnuplot (3.7 PL 0), the plot window steals the
focus. Bringing the plot window to the top of the Z-
order stack is reasonable, but since gnuplot is a
command line oriented program with its own 'command
shell' in the Win32 version, it shouldn't steal the
keyboard focus when you plot a new graph. To avoid
this problem, call ::SetWindowPos instead
of ::BringWindowToTop. The former changes only the Z-
order of the window, while the latter changes the Z-
order -and- activates the window. Its the activation
of the window that's stealing the keyboard focus.

Discussion

  • Hans-Bernhard Broeker

    Logged In: YES
    user_id=27517

    Again: 3.7patchlevel 0 is outdated.

    And if you don't like the focus change, you can always
    deactivate the bring-to-top feature altogether (Uncheck
    "Bring To Top" in the graph window's context menu).

    I'll look up SetWindowPos to see whether that's a usable
    alternative.
    But note that gnuplot (still) tries to be Win16 compatible,
    so Win32-only methods aren't usable. And we're coding raw C
    API, not C++/MFC, so there is no "::BringWindowToTop" method
    anyway ;-)

     
  • Hans-Bernhard Broeker

    • assigned_to: nobody --> broeker
     
  • legalize

    legalize - 2002-01-02

    Logged In: YES
    user_id=36316

    I didn't know about the context menu option. Yes, that
    stops the window from going to the front -and- stealing the
    focus, but the bug is that it steals the focus, not that it
    brings the window to the top.

    In my opinion, bringing the window to the top is useful,
    but stealing the keyboard focus is not.

    Both ::SetWindowPos and ::BringWindowToFront -are- raw C
    API functions. They are not MFC and they are not C++. I
    prefixed them with "::" on the front to emphasize that they
    are global functions. Both of these functions have been
    present in Windows since version 2.0.

     
  • Hans-Bernhard Broeker

    Logged In: YES
    user_id=27517

    I've tried it out yesterday evening, and I think I have a
    patch that can go in. There's one further complication,
    though: non-critical patches are now only made to the
    development version, which does have a valid reason for
    transferring the focus over to the graph window: mouse
    interaction, and the keyboard shortcuts that go with it. So
    I did it like this:

    if (mouse mode is active)
    BringWindowToTop();
    else
    SetWindowPos(hwnd, HWND_TOP, 0,0,0,0,
    SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);

    If you don't see any reasons against this, I'll commit that
    patch tomorrow, I think.

     
  • legalize

    legalize - 2002-01-03

    Logged In: YES
    user_id=36316

    What's "mouse mode"? Is that in 3.7 PL 0?

     
  • Hans-Bernhard Broeker

    Logged In: YES
    user_id=27517

    As I wrote: mouse mode is a new feature of the development
    version (in the CVS here at SourceForge). It's in none of
    the 3.7.something versions. But it'll be part of the next
    public release, whenever that may happen.

     
  • legalize

    legalize - 2002-01-03

    Logged In: YES
    user_id=36316

    Yeah, that's twice you've told me that its a new feature,
    but I still don't know what it is or what it does. Care to
    elaborate?

     
  • Hans-Bernhard Broeker

    Logged In: YES
    user_id=27517

    Mouse-able zooming in 2D, indicates mouse position in plot
    coordinates, lets you toggle some graph features by single
    keypress, and other things like that. In short: all those
    things you would always have liked to use a mouse for, in
    the graph window, but never could. For more insight, compile
    the CVS version and see for yourself.

     
  • legalize

    legalize - 2002-01-03

    Logged In: YES
    user_id=36316

    Alright, given that description I would agree that
    BringWindowToTop is what you want if you've got mouse mode
    enabled.

     
  • Hans-Bernhard Broeker

    • summary: plot window steals focus --> Win32: plot window steals focus
     
  • Hans-Bernhard Broeker

    • milestone: --> release_critical
     
  • Hans-Bernhard Broeker

    Logged In: YES
    user_id=27517

    A fix along the lines discussed is in CVS as of 3.8k patchlevel 1.

     
  • Hans-Bernhard Broeker

    • status: open --> closed
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.