Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Contraining a window position (x,y) in X.

39 views
Skip to first unread message

bou...@gmail.com

unread,
Mar 15, 2012, 10:06:56 AM3/15/12
to
Hello Xers,

Got a simple problem for which I'm trying to find a good solution. I have two applications running on 1 workstation. This workstation is configured with two displays. What I'm trying to accomplish is to constrain the positions of the windows from one of my apps to one of the displays. No problem figuring out the displayable area, the problem I'm having is enforcing it.

Currently the windows are all top level shells (need the ability to iconify windows). I am using MWM as my window manager and I'm running Motif 1.2.

So right now I have an event handler which subscribes to the StuctureNotifyMask and I get configureNotify eventS on the windowS. Seeing how I am using a window manager I cannot preemptively stop a window from moving outside the viewable area (wish there was a XmNminX and XmNminY resource). So I'm stuck with having to move the window post the window manager actually moving the window. This is OK for the most part, but because I have the Mwm*moveOpaque value set I receive several configureNotify events when the window is being moved by the user. When it begins to move outside the acceptable area (user dragging the window), I start to try and move it to the proper area and then things go bad in a hurry (my app setting calculating correct positions and the user is still moving the window).

I'm I missing something here? It is difficult to figure out when the drag move starts and stops (add button handlers (but don't get notified of MB1 clicks on the window titlebar), motionnotify events and try and set global window states) and the configureNotify events don't contain that information. Things are compounded when the user resizes the window outside of the viewing area...

I've searched online and have found a couple of threads where people were trying to do the same thing, but never any concrete solution.

Please, if you've done this in the past or have some ideas for me I would be very appreciative.

Thanks (sorry for the multiple posts),
Keith.

Aaron W. Hsu

unread,
Mar 15, 2012, 3:33:17 PM3/15/12
to
On Thu, 15 Mar 2012 07:06:56 -0700, bourdox wrote:

> Got a simple problem for which I'm trying to find a good solution. I
> have two applications running on 1 workstation. This workstation is
> configured with two displays. What I'm trying to accomplish is to
> constrain the positions of the windows from one of my apps to one of the
> displays. No problem figuring out the displayable area, the problem I'm
> having is enforcing it.

From your description, it sounds like you not only want to restrict the
window creation to be on one display, but also to restrict that window
from ever leaving that display. Is this correct?

--
Aaron W. Hsu | arc...@sacrideo.us | http://www.sacrideo.us
Programming is just another word for the lost art of thinking.

bou...@gmail.com

unread,
Mar 15, 2012, 3:59:44 PM3/15/12
to
Yup, that's correct. The creation and mapped/unmapped is easy as I can easily set the XmNx and XmNy coordinates of the shell widget prior to popping them up.

The real pain is trying to "correct" user actions as they happen...

Aaron W. Hsu

unread,
Mar 15, 2012, 9:38:44 PM3/15/12
to
On Thu, 15 Mar 2012 12:59:44 -0700, bourdox wrote:

> The real pain is trying to "correct" user actions as they happen...

Given that you are using a window manager, I do not think that there is
any way to do this with normal Motif or X programming. As I understand
the programming model, these Window managers are what actually controls
what and how a window is moved, not the application itself. You can
create a Window with certain constraints of course, but I do not think
you can reliably prevent windows from moving "too far" if you allow
movement at all. I think you can prevent movement at all....

I suppose that you can catch the movement action as you are doing and try
to "correct" it as you have been trying. Of course, that is likely to
lead to problems as you have seen. I am not familiar with the 1.2 Motif,
only 2.1, but maybe you can somehow ensure that movement operations do
not overlap somehow with timestamps? I know that there are some actions
in Motif that can be done with these timestamps, like some of the text
widget actions, but I am not familiar with what you can get done with the
1.2 callbacks on windows.

Maybe there is another way to setup your application so that you do not
have to rely on having moveable top-level windows?
0 new messages