|
|
|
|
|
Re: Getting / Setting Monitor for SWT Application? [message #440223 is a reply to message #440221] |
Mon, 26 July 2004 19:37 |
Brion Vibber Messages: 21 Registered: July 2009 |
Junior Member |
|
|
Benjamin Pasero wrote:
> Brion Vibber wrote:
>>Benjamin Pasero wrote:
>>>thanks for this way to get out on which Monitor the SWT App is running.
>>>But one big problem is still, that SWT does not seem to provide any method
>>>like "setMonitor". I just looked through Display and Shell widget. I am
>>>going to open a feature request on this item.
>
>>What do you need that Shell.setLocation() doesn't do?
>
> Hm, but how is the location calculated when two monitors are used? Will
> the max location be the two monitor's sizes added?
Normally there is a global coordinate space; each monitor occupies some
portion of that space. See the other posting which gave an example of
using Monitor.getBounds(), this should let you know where each monitor
is located in the coordinate space and how big it is.
As an example; if I have my PowerBook connected to an external monitor,
and have the internal screen also active, my screens will be laid out
something like this:
+------+
+----+ 1 |
| 2 | |
+----+------+
monitor 1: position (0,0) size 1280x1024
monitor 2: position (-1024, 256) size 1024x768
So if I left a window at (-800, 400) size 500x350, I'll save those
coordinates and restore it at (-800, 400) with size 500x350. I'd be
really surprised if that doesn't work.
You should also check that there is actually a monitor covering that
space, though: laptops in particular may frequently change monitor
configuration, and a window that's created offscreen can be hard to work
with.
> And there is a situation where setLocation() does not seem to work. A user
> maximized the shell on the second monitor, closed the application and
> restarted it. The Shell was then placed maximized on the first monitor
> (although I am saving the location on exit and resetting it on startup).
> Maybe that is only working with non maximized Shells.
Maximizing can do funny things, particularly on Windows. Usually you
can't change the position of a maximized window... also maximized
windows on Windows have coordinates which extend a few pixels off the
screen, which may confuse things when you then maximize it. Are you
setting the position first, then maximizing, or the other way around?
-- brion vibber (brion @ pobox.com)
|
|
|
Re: Getting / Setting Monitor for SWT Application? [message #440225 is a reply to message #440223] |
Mon, 26 July 2004 20:13 |
Benjamin Pasero Messages: 337 Registered: July 2009 |
Senior Member |
|
|
Thanks for this detailed explanation. I must admit, that the problem with
a Shell being maximized is not a real problem ^^. I was simply not storing
the location of the Shell in the settings file, because on a
single-monitor its pretty useless, whereas on a dual-monitor the Shell may
be maximized on the second Monitor and the location is not (0, 0).
Tomorrow I am going to play around with it, connecting a second Monitor to
my notebook. Using setLocation should do it.
Ben
> Benjamin Pasero wrote:
> > Brion Vibber wrote:
> >>Benjamin Pasero wrote:
> >>>thanks for this way to get out on which Monitor the SWT App is running.
> >>>But one big problem is still, that SWT does not seem to provide any method
> >>>like "setMonitor". I just looked through Display and Shell widget. I am
> >>>going to open a feature request on this item.
> >
> >>What do you need that Shell.setLocation() doesn't do?
> >
> > Hm, but how is the location calculated when two monitors are used? Will
> > the max location be the two monitor's sizes added?
> Normally there is a global coordinate space; each monitor occupies some
> portion of that space. See the other posting which gave an example of
> using Monitor.getBounds(), this should let you know where each monitor
> is located in the coordinate space and how big it is.
> As an example; if I have my PowerBook connected to an external monitor,
> and have the internal screen also active, my screens will be laid out
> something like this:
> +------+
> +----+ 1 |
> | 2 | |
> +----+------+
> monitor 1: position (0,0) size 1280x1024
> monitor 2: position (-1024, 256) size 1024x768
> So if I left a window at (-800, 400) size 500x350, I'll save those
> coordinates and restore it at (-800, 400) with size 500x350. I'd be
> really surprised if that doesn't work.
> You should also check that there is actually a monitor covering that
> space, though: laptops in particular may frequently change monitor
> configuration, and a window that's created offscreen can be hard to work
> with.
> > And there is a situation where setLocation() does not seem to work. A user
> > maximized the shell on the second monitor, closed the application and
> > restarted it. The Shell was then placed maximized on the first monitor
> > (although I am saving the location on exit and resetting it on startup).
> > Maybe that is only working with non maximized Shells.
> Maximizing can do funny things, particularly on Windows. Usually you
> can't change the position of a maximized window... also maximized
> windows on Windows have coordinates which extend a few pixels off the
> screen, which may confuse things when you then maximize it. Are you
> setting the position first, then maximizing, or the other way around?
> -- brion vibber (brion @ pobox.com)
|
|
|
Powered by
FUDForum. Page generated in 0.03529 seconds