java-gnome version 4.0.19

org.gnome.gdk
Class Window

Object
  extended by org.freedesktop.bindings.Pointer
      extended by org.freedesktop.bindings.Proxy
          extended by org.gnome.glib.Object
              extended by org.gnome.gdk.Drawable
                  extended by org.gnome.gdk.Window

public class Window
extends Drawable

The underlying native resource driving a rectangular region on a screen. These are notable as being what powers the display of Widgets, being both that upon which drawing is done, and that to which user actions are delivered.

In theory, some, but not all, Widgets have their own native windows to draw upon and from whence events originate. Thus Widgets such as Buttons have their own underlying native resource, whereas Labels and various Containers do not. In practise, this distinction is blurred and newer versions of GTK do all sorts of strange things under the hood for greater efficiency. You don't need to worry about any of this.

These are wrappers around Xlib's Window object. They can be arranged in tree structures, wrapping and overlapping one another, with parents cropping children, etc. You don't need to worry about any of this either.

What this is useful for is as a way to get to the state of top level windows and various low level drawing functions.

Since the C name of this class is GdkWindow, the unavoidable consequence of the java-gnome mapping algorithm is that the name of this class Java is Window. This can be a bit of a pain if you're working in a piece of code where org.gnome.gtk.Window is already imported, but c'est la vie.

Since:
4.0.4
Author:
Andrew Cowie

Method Summary
 boolean ensureNative()
          Force GDK to use the old X Window allocation behaviour for this Window.
 int getOriginX()
          Get the horizontal position of this Window in terms of the root Window's co-ordinates.
 int getOriginY()
          Get the vertical position of this Window in terms of the root Window's co-ordinates.
 int getPositionX()
          Get the horizontal position of this Window relative to its parent Window.
 int getPositionY()
          Get the vertical position of this Window relative to its parent Window.
 WindowState getState()
          Return a flags object representing the current state of the Window (maximized, iconified, etc).
 void invalidate(Rectangle area, boolean recursive)
          Mark the given area as damaged and needing redrawing.
 boolean isViewable()
          Has this underlying resouce been mapped?
 void setBackingPixmap(Pixmap pixmap, boolean relative)
          Change the background of the Window.
 void setCursor(Cursor cursor)
          Set the Cursor that will be shown when the pointer hovers over this Drawable Window.
 
Methods inherited from class org.gnome.gdk.Drawable
getDepth, getHeight, getWidth
 
Methods inherited from class org.freedesktop.bindings.Pointer
toString
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

ensureNative

public boolean ensureNative()
Force GDK to use the old X Window allocation behaviour for this Window. This reverts the GDK Window backing a GTK Widget to the pre-2.18 behaviour, analogous to setting the GDK_NATIVE_WINDOW environment variable but not nearly as invasive.

Theoretically you should not need to use this; the whole idea of the "client-side windows" patch to GTK was to avoid having to use unnecesssary intermediate X Windows, and calling this method circumvents this optimization. Most GTK Widgets should perform just fine without reverting to the old behaviour, but in isolated corner cases it may be necessary to workaround obscure bugs.

Returns:
This will return false should GDK be unable to allocate native resources as requested. The consequences of that are unclear.
Since:
4.0.16

getOriginX

public int getOriginX()
Get the horizontal position of this Window in terms of the root Window's co-ordinates. The root window is what you might think of as the desktop background, although in X terms it really is the parent of all windows.

Since:
4.0.6

getOriginY

public int getOriginY()
Get the vertical position of this Window in terms of the root Window's co-ordinates.

Since:
4.0.6

getPositionX

public int getPositionX()
Get the horizontal position of this Window relative to its parent Window. Given that many Widgets draw directly on their parent's org.gnome.gdk Window, you may at times be surprised at what this reports.

Since:
4.0.6

getPositionY

public int getPositionY()
Get the vertical position of this Window relative to its parent Window.

Since:
4.0.6

getState

public WindowState getState()
Return a flags object representing the current state of the Window (maximized, iconified, etc). See WindowState for the individual constants, obviously, but be aware that an unmapped Window will have no WindowState bits set.

Since:
4.0.4

invalidate

public void invalidate(Rectangle area,
                       boolean recursive)
Mark the given area as damaged and needing redrawing. Calling this method will ultimately result in Widget.ExposeEvent being emitted on Widgets that are present in the area being invalidated.

Parameters:
recursive - If true, calling this method will invalidate not only the described area in this [org.gnome.gdk] Window, but also the corresponding areas of any child [org.gnome.gdk] Windows that overlap it. This is mostly an implementation detail, but occasionally you need to find tune the control. We tend to use true.
Since:
4.0.8

isViewable

public boolean isViewable()
Has this underlying resouce been mapped? This will return true if show() has been called on the Widget that draws on this [org.gnome.gdk] Window and on all its parents, if this Window happens to be a sub-Window.

Since:
4.0.10

setBackingPixmap

public void setBackingPixmap(Pixmap pixmap,
                             boolean relative)
Change the background of the Window.

TODO describe relative parameter.

This really is only necessary if trying to do irregularly shaped user interfaces (ie, not standard rectangular applications) and need a transparent background. You get that via:

 underlying.setBackingPixmap(null, false);
 
but transparency is a complex topic and requres other measures as well. TODO describe or link!

Since:
unstable

setCursor

public void setCursor(Cursor cursor)
Set the Cursor that will be shown when the pointer hovers over this Drawable Window.

Parameters:
cursor - Passing null will cause this Window to [revert to] using the Cursor default inherited from its parent.
Since:
4.0.6


java-gnome