Skip to content

Windows' drivers have a focus problem. #872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
maynardGK opened this issue Jan 19, 2021 · 11 comments
Closed

Windows' drivers have a focus problem. #872

maynardGK opened this issue Jan 19, 2021 · 11 comments

Comments

@maynardGK
Copy link
Contributor

maynardGK commented Jan 19, 2021

With new coding in GDL it has been possible to nearly replicate the desirable behavior of
keyboard focus without patching the plplot drivers, wingcc,c or wingdi.c.
Previously, keyboard focus was controlled solely by returning focus to the foreground
window. The foreground window was however changed in the original wingcc driver and so
un-doing this change via a patch in plplot allowed for a correct behavior:

--- /f/plplot/plplot-5.13.0/drivers/wingcc.c	Fri Aug 25 19:43:25 2017
+++ /f/tarball/plplot-5.13.0/drivers/wingcc.c	Sat Jun 09 12:44:28 2018
@@ -636,7 +634,7 @@
     // sort of thing).
     //
     ShowWindow( dev->hwnd, SW_SHOWDEFAULT );
-    SetForegroundWindow( dev->hwnd );
+    BringWindowToTop( dev->hwnd );

(this patch was proposed and rejected by the plplot group)

The new interface to wingcc #864 works around this but it is somehow inadequate, failing the following test with multiple windows (can be .RUN or just executed with "@").

fs=findgen(40) & !prompt="" & iw=-1
iw++&window,iw,xs=512,ys=512,xp=128*iw,yp=128*iw&plot,fs,chars=iw,thi=iw
iw++&window,iw,xs=512,ys=512,xp=128*iw,yp=128*iw&plot,fs,chars=iw,thi=iw
iw++&window,iw,xs=512,ys=512,xp=128*iw,yp=128*iw&plot,fs,chars=iw,thi=iw
iw++&window,iw,xs=512,ys=512,xp=128*iw,yp=128*iw&plot,fs,chars=iw,thi=iw
iw++&window,iw,xs=512,ys=512,xp=128*iw,yp=128*iw&plot,fs,chars=iw,thi=iw
iw++&window,iw,xs=512,ys=512,xp=128*iw,yp=128*iw&plot,fs,chars=iw,thi=iw
wshow,iw,0
wshow,iw-1,0
wshow,iw-2,0
wshow,iw-2,/icon
wshow,iw-2,0
wshow,iw-3,0
wshow,0,0,/icon
wshow,0
end
@pjb7687
Copy link
Member

pjb7687 commented Jan 20, 2021

I suspect below picks up a wrong handle.

refocus = GetForegroundWindow();

This is okay.

@pjb7687
Copy link
Member

pjb7687 commented Jan 20, 2021

Also, this seems to be raising the previous plot:

Raise(); // Brings again the plot window on top, but not focused

@pjb7687
Copy link
Member

pjb7687 commented Jan 20, 2021

Tried to fix it: 3eb16a4
Two things are fixed:

  1. The plot is not properly repainted when I run the suggested code using GDL Workbench.
  2. The code works when I replace the third argument of wshow function (show) to be 1.

I simply removed the UnsetFocus function from devicewin. I have searched for how IDL behaves on Windows on Youtube, seems like the Windows IDL also doesn't do this...

I found that when the third argument (show) is 0, then actually the window should be hidden, according to this:
https://www.l3harrisgeospatial.com/docs/WSHOW_Procedure.html

But instead, it seems like the current implementation tries to bring the window bottom (in the z-order). I don't know which one is the right behavior of IDL, so postponed fixing it...

@pjb7687
Copy link
Member

pjb7687 commented Jan 24, 2021

When the third argument is 1:
image

@pjb7687
Copy link
Member

pjb7687 commented Jan 24, 2021

Having no ideas about IDL behavior, I'll make it behave the same as ubuntu GDL... Makes sense?

@pjb7687
Copy link
Member

pjb7687 commented Jan 24, 2021

Another fix: 77c3f03
This is when the third argument is 0:
image

@pjb7687
Copy link
Member

pjb7687 commented Jan 24, 2021

Is this okay now?

@GillesDuvert
Copy link
Contributor

wshow,3,0 puts window 3 below all others.
wshow,3,1 put it above.
wshow,3,/icon iconize the window. It cannot be shown again unless a wshow,3,icon=0 is issued, and the window appears above all the others, even after a command like 'wshow,3,0,icon=0 .
GDL is apparently not completely OK with this with the X11 driver on unix.
Concerning the focus, IDL always disable passing the focus to a plot window, which is IMHO more than clever, but the plplot windows (so, the GDL ones, example: the X11 window) somehow obey the desktop behaviour on 'focus stealing' and are not declared 'no focus at all'. One can instruct the window manager (KDE in my case) to disable focus always on windows named 'GDL*' but this is too system dependent. There must be a magic call to have all plplot windows to never get focus.

@pjb7687
Copy link
Member

pjb7687 commented Jan 26, 2021

@GillesDuvert Thank you so much for clarifying this! Then the patched Windows driver behaves correctly. It never steals the focus from the GDL command line.

@pjb7687
Copy link
Member

pjb7687 commented Jan 26, 2021

One exception is when you fire up a new plot window using 'plot'. However at least wshow seems to work okay.. I will further investigate it.

@GillesDuvert
Copy link
Contributor

obsolete since #882 has been merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants