Operating System - HP-UX
1752675 Members
5700 Online
108789 Solutions
New Discussion

XRaiseWindow XDoesntWork XAsExpected

 
Ken Goeppner_1
Occasional Contributor

XRaiseWindow XDoesntWork XAsExpected

Hello again,

This is a follow up to a closed thread on the subject of shell conltrol of X windows. My original post asked for a way to raise a window from a shell script and Mike Stroyan provided the correct method to do so as follows:

#!/usr/dt/bin/dtksh
XtInitialize TOPLEVEL raise Raise "$0" "$@"
XtDisplay DISPLAY $TOPLEVEL
if [ $# -gt 0 ]
then
for W in "$@"
do
XRaiseWindow $DISPLAY $W
done
else
XRaiseWindow $DISPLAY $WINDOWID
fi
XFlush $DISPLAY

This script performs perfectly and I end up with window from where the script was executed being raised. The problem now is that I also want to have the keyboard input focus set for that same window and I thought I had that solved but I was mistaken. I tried adding the following command to the script:

XRealizeWidget $TOPLEVEL

but it turned out not to work as I expected. Is there a dtksh built-in or another method that will do what I need??

Thanks in advance for your help,

Ken
Imagine if there were no hypothetical situations
1 REPLY 1
Mike Stroyan
Honored Contributor

Re: XRaiseWindow XDoesntWork XAsExpected

The keyboard focus is affected by the window manager used and the settings of several window manager resources. If you are using dtwm with the default resource values keyboardFocusPolicy:explicit and startupKeyFocus:true, then you can cause focus to go to a window by unmapping and then popping up the window. There is no XUnmapWindow in dtksh, but you can do it with xwit.
xwit -unmap -id $WINDOWID
xwit -pop -id $WINDOWID