org.gnome.gdk

## Class Window

- Object
- - org.freedesktop.bindings.Pointer
  - - org.freedesktop.bindings.Proxy
    - - org.gnome.glib.Object
      - - org.gnome.gdk.Window

-     public class Window
      extends Object

  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

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `ensureNative()` Force GDK to use the old X Window allocation behaviour for this Window.
    `int` | `getHeight()` Get the height of 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).
    `int` | `getWidth()` Get the width of this Window.
    `void` | `invalidate(Rectangle area, boolean recursive)` Mark the given area as damaged and needing redrawing.
    `boolean` | `isViewable()` Has this underlying resouce been mapped?
    `void` | `setCursor(Cursor cursor)` Set the Cursor that will be shown when the pointer hovers over this Window.

    - ### 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

    - #### getHeight

          public int getHeight()

      Get the height of this Window.
      Since:
        4.1.1

    - #### 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

    - #### getWidth

          public int getWidth()

      Get the width of this Window.
      Since:
        4.1.1

    - #### 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.Draw` 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

    - #### setCursor

          public void setCursor(Cursor cursor)

      Set the Cursor that will be shown when the pointer hovers over this Window.
      Parameters:
        `cursor` - Passing `null` will cause this Window to [revert to] using the Cursor default inherited from its parent.
      Since:
        4.0.6