From: archer@frmug.fr.mugnet.org (Vincent Archer)
Newsgroups: fj.mail-lists.x-window
Subject: Awful behaviour of SynergyII
Date: 10 Sep 92 13:52:07 GMT
Distribution: fj
Organization: Alcatel CIT - ATC

Date: 9 Sep 92 11:36:12 GMT
Message-Id: <1992Sep9.113612.6806@tcvr65.alcatel-alsthom.fr>
Newsgroups: comp.sys.sun.apps,comp.windows.x

[Note the followup to comp.sys.sun.apps. Please make sure this group is
 included in all replies to this message]

I'm working on an application that use Synergy, a 386 card, to emulate a PC
on a Sparc2. One major problem, when starting the application, is that the
screen is displayed roughly in the middle of the screen. However, when the
"PC" goes into Super-VGA mode for Windows3, the window grows to the left
and the bottom, thus falling outside of the limits of the Sparc2 screen.

"No problem there!", I said, I'll just relocate the initial screen to the
top left corner, and there will be no hidden parts.

Then came the bad things:

* I tried to use XView's option -Wp to set up the 10/30 position of the
  window. Not so fast, my friend... Neither the starting window nor the
  emulation window obey the command switch.
* I then tried to set my .Xdefaults resource file to specify
  Synergy.Windows.X and .Y values. Guess what... The app still uses its
  own run-time computed positions to center the window on the screen.
* I therefore dug into XLib manuals, and wrote a small program that
  searches for the Synergy window, and calls XReconfigureWMWindow (or
  XMoveWindow, I've tried both) when the window is created and becomes
  mapped (the source is included below).

Now comes the bad part. This program (test on shelltools/cmdtools and
other standard windows) failed to do the correct thing:

- Used before the window is mapped (no code to wait for window map), the
  window still appears at its old place.
- Used once the window is on the screen, no movement takes place...
And now the winner is...
- Used once the window is on the screen, but with any other window, no
  matter how small or whether iconified or not, is above and overlaps
  part of the Synergy window, the window correctly jumps to its intended
  place!!!

The standard Sun apps, of course, do not manifest this behaviour; they
appily jump to the requested location on screen.

So, does anybody has any insight on how this is possible, why it is so,
and how I could circumvent the problem (other than the easy solution,
create a window on top, relocate the synergy screen, destroy the window).

I'm specially most interested in knowing why this simple task can fail;
what arcane and undocumented (at least in the XReconfigureWMWindow man
page) feature blocks any of my attemps to do relocate.

Of course, If somebody has an easier way of opening SynergyII at a fixed
place on the screen without using the program below, I'd be even happier
:-)

-- Begin included source --
#include <X11/Xlib.h>

Display *colon_0_dot_0;

recurse(w)
Window w;
{
Window trash;
Window *wlist;
unsigned int wsize;
Window *l;
char *name;
XWindowAttributes attrs;
XWindowChanges changes;
int s;

  XFetchName(colon_0_dot_0, w, &name);
  if (name) {
	if (strcmp(name, "  Synergy II") == 0) {
		printf("Window 0x%08x for SynergyII found\n", w);
		attrs.map_state = IsUnmapped;
		while (attrs.map_state != IsViewable) {
			sleep(1);
			XGetWindowAttributes(colon_0_dot_0, w, &attrs);
		}
		changes.x = 10;
		changes.y = 30;
		XReconfigureWMWindow(colon_0_dot_0, w, 0, CWX|CWY, &changes);
		/*XMoveWindow(colon_0_dot_0, w, 10, 30); Doesn't work either*/
		XFree(name);
		return 1;
	}
	XFree(name);
  }
  XQueryTree(colon_0_dot_0, w, &trash, &trash, &wlist, &wsize);
  s = 0;
  for (l=wlist; wsize; wsize--)
	s |= recurse(*l++);
  XFree(wlist);
  return s;
}


main()
{
  colon_0_dot_0 = XOpenDisplay(":0.0");
  while (!recurse(RootWindow(colon_0_dot_0, 0)))
	sleep(1);
}
-- End included source --

--
Vincent Archer			Email:	archer@frmug.fr.mugnet.org
Minix User Group France