Maximizing a window

This forum is read only. No new submissions are accepted.

Questions about motif? Contact us

15 posts / 0 new
Last post
Maximizing a window

Submitted by machnone on Thu, 11/30/2000 - 02:51. Developers
I want to have a window (application) come up to be the full size of the screen, regardless of resolution. Is there a call that will maximize a window?

Anonymous

Try this

/* Get the root window of the window */

hRootWin = DefaultRootWindow(XtDisplay(wWindow));

/*Get the size of that root window */
wRoot = XtWindowToWidget( pDisplay, hRootWin);

XGetGeometry ( pDisplay, wRoot, &wUnused, &nX, &nY,
&uWidth, &uHeight, NULL, NULL );

/* Use these values to set your window`s size */
/* Use XtSetArg with
XmNleftOffset = 0
XmNtopOffset = 0
XmNwidth, uWidht
XmNheight, uHeight
*/

Good luck

Steve

ICS_support

The concept of "maximizing" the window is peculiar to mwm and doesn`t match the standard X notions of what can be done to a window -- iconifying it, deiconifying it, withdrawing it, etc. Maximizing may also maximize the window in one direction, not both; and, even maximized, the window titlebar, if present, is displayed. You may or may not want the titlebar displayed.

In any case, mwm doesn`t provide a programmatic means of making this happen, either, so the best that you can do is this 1) assume that you`re using mwm, which is a dangerous enough assumption, given all the window managers out there. 2) after the window is mapped, resize it. 3) hope that mwm honors this request and doesn`t add an additional space for the titlebar, which it can do, depending on the user`s settings.

In general, questions of this sort that require the window manager`s cooperation are difficult to answer. If you assume a particular window manager`s features, you`re really heading in the wrong direction. Ideally, you`d stick to the ICCCM features and assume nothing other than that you have an ICCCM-compliant window manager; you can then add special features for other window managers as "icing on the cake". But assuming particular features means that what you really need to do is to provide a turnkey system in which you can provide the window manager -- and you can then offer one which understands this "full screen application" concept, as, I believe, various flavors of fvwm do.

ICS_support

You should also be able to use XtGetValues on the shell itself. Note that the window manager is free to ignore these "suggestions" -- the values which it pays most attention to come from the user, via interactive placement or via resources, and application self-movements can be ignored.

machnone

Steve,

In your example, what exactly should be the first argument to XtWindowToWidget? How should it be cast?

Thanks.
Nick

Anonymous

Do a man XtWindowToWidget.

Widget XtWindowToWidget(display, window)
Display *display;
Window window;

You can retrieve it by using either

Display *XtDisplay(w)
Widget w;

Display *XtDisplayOfObject(object)
Widget object;

Steve

machnone

I keep getting 0 returned from the XtWindowToWidget function. I am passing it in the form

wRoot = XtWindowToWidget(XtDisplay(main_display), root_window)

Where root_window is retrieved from DefaultRootWindow(XtDisplay(main_display))

main_display is the main display shell, application for my program. I get a valid root_window, but not widget.

Thanks for any help.

machnone

I keep getting 0 returned from the XtWindowToWidget function. I am passing it in the form

wRoot = XtWindowToWidget(XtDisplay(main_display), root_window)

Where root_window is retrieved from DefaultRootWindow(XtDisplay(main_display))

main_display is the main display shell, application for my program. I get a valid root_window, but not widget.

Thanks for any help.

Anonymous

The root window is a window, _not_ a widget.

ICS_support

The confusion is in the original code, in which XtWindowToWidget is called on the root window. The result will be None (value 0), as there is no widget corresponding to root. What the code should have done was to use the XtWindow() corresponding to the top-level shell of the application. That code brings a caveat, though -- it must be called only after the widget is realized.

Anonymous

Right, my fault ... The XtWindow() called is not correct.

Do you know any to retreive this information before the widgets are realized?

machnone

That makes sense, but how is the size of the root window being determined?
The RootWindowOfScreen function works fine, but what is passed to XGetGeometry?
I just want the size of the root window.

Thanks for all your help.

Anonymous

Like mentionned before, this works once the window is popped up.

To get the size of the root window use

XGetWindowAttributes( XtDisplay( wYourWindow ), hRootWindow,
&sAttrib);

The sAttrib structure will contains the correct information.

machnone

That did it! It works great now. Thanks a lot for all your help, I really appreciate it.

ICS_support

Note that the size of the root window (that is,
the root window of the current screen) is a
*constant* and can be pre-calculated without regard to when the application is realized or mapped or whatever. See the Xlib macros or quick routines for doing this; there are man pages for these at http//www.motifzone.com/resources/man . Look for "DisplayWidth()" and such.

More generally, other windows are not constant in this way and can be calculated only when they exist, which should be immediately after their creation. But widgets, which generally correspond to windows, exist as data structures without windows until they are realized; until they are realized, you can really do quite a bit just using
the resources XtNx, XtNy, XtNwidth, and XtNheight, and after they are realized, you can use XtWindow() and then manipulate the window ID directly (which is appropriate only for the shell window, and barely appropriate even then). Usually, it`s better to use Xt calls (XtSetValues) on these resources so that the Xt data structures are maintained correctly and reflect the actual on-screen values. If you find yourself needing to manipulate the windows, you`re probably solving a problem in the wrong way.