Windows

Windows — Onscreen display areas in the target window system

Synopsis


#include <gdk/gdk.h>


struct              GdkWindow;
enum                GdkWindowType;
enum                GdkWindowClass;
enum                GdkWindowHints;
                    GdkGeometry;
enum                GdkGravity;
enum                GdkWindowEdge;
enum                GdkWindowTypeHint;
                    GdkWindowAttr;
enum                GdkWindowAttributesType;
GdkWindow*          gdk_window_new                      (GdkWindow *parent,
                                                         GdkWindowAttr *attributes,
                                                         gint attributes_mask);
void                gdk_window_destroy                  (GdkWindow *window);
#define             gdk_window_ref
#define             gdk_window_unref
GdkWindowType       gdk_window_get_window_type          (GdkWindow *window);
GdkWindow*          gdk_window_at_pointer               (gint *win_x,
                                                         gint *win_y);
void                gdk_window_show                     (GdkWindow *window);
void                gdk_window_show_unraised            (GdkWindow *window);
void                gdk_window_hide                     (GdkWindow *window);
gboolean            gdk_window_is_visible               (GdkWindow *window);
gboolean            gdk_window_is_viewable              (GdkWindow *window);
GdkWindowState      gdk_window_get_state                (GdkWindow *window);
void                gdk_window_withdraw                 (GdkWindow *window);
void                gdk_window_iconify                  (GdkWindow *window);
void                gdk_window_deiconify                (GdkWindow *window);
void                gdk_window_stick                    (GdkWindow *window);
void                gdk_window_unstick                  (GdkWindow *window);
void                gdk_window_maximize                 (GdkWindow *window);
void                gdk_window_unmaximize               (GdkWindow *window);
void                gdk_window_fullscreen               (GdkWindow *window);
void                gdk_window_unfullscreen             (GdkWindow *window);
void                gdk_window_set_keep_above           (GdkWindow *window,
                                                         gboolean setting);
void                gdk_window_set_keep_below           (GdkWindow *window,
                                                         gboolean setting);
void                gdk_window_set_opacity              (GdkWindow *window,
                                                         gdouble opacity);
void                gdk_window_set_composited           (GdkWindow *window,
                                                         gboolean composited);
void                gdk_window_move                     (GdkWindow *window,
                                                         gint x,
                                                         gint y);
void                gdk_window_resize                   (GdkWindow *window,
                                                         gint width,
                                                         gint height);
void                gdk_window_move_resize              (GdkWindow *window,
                                                         gint x,
                                                         gint y,
                                                         gint width,
                                                         gint height);
void                gdk_window_scroll                   (GdkWindow *window,
                                                         gint dx,
                                                         gint dy);
void                gdk_window_move_region              (GdkWindow *window,
                                                         GdkRegion *region,
                                                         gint dx,
                                                         gint dy);
void                gdk_window_reparent                 (GdkWindow *window,
                                                         GdkWindow *new_parent,
                                                         gint x,
                                                         gint y);
void                gdk_window_clear                    (GdkWindow *window);
void                gdk_window_clear_area               (GdkWindow *window,
                                                         gint x,
                                                         gint y,
                                                         gint width,
                                                         gint height);
void                gdk_window_clear_area_e             (GdkWindow *window,
                                                         gint x,
                                                         gint y,
                                                         gint width,
                                                         gint height);
#define             gdk_window_copy_area                (drawable,gc,x,y,source_drawable,source_x,source_y,width,height)
void                gdk_window_raise                    (GdkWindow *window);
void                gdk_window_lower                    (GdkWindow *window);
void                gdk_window_focus                    (GdkWindow *window,
                                                         guint32 timestamp);
void                gdk_window_register_dnd             (GdkWindow *window);
void                gdk_window_begin_resize_drag        (GdkWindow *window,
                                                         GdkWindowEdge edge,
                                                         gint button,
                                                         gint root_x,
                                                         gint root_y,
                                                         guint32 timestamp);
void                gdk_window_begin_move_drag          (GdkWindow *window,
                                                         gint button,
                                                         gint root_x,
                                                         gint root_y,
                                                         guint32 timestamp);
void                gdk_window_constrain_size           (GdkGeometry *geometry,
                                                         guint flags,
                                                         gint width,
                                                         gint height,
                                                         gint *new_width,
                                                         gint *new_height);
void                gdk_window_beep                     (GdkWindow *window);

void                gdk_window_begin_paint_rect         (GdkWindow *window,
                                                         GdkRectangle *rectangle);
void                gdk_window_begin_paint_region       (GdkWindow *window,
                                                         GdkRegion *region);
void                gdk_window_end_paint                (GdkWindow *window);

void                gdk_window_invalidate_rect          (GdkWindow *window,
                                                         GdkRectangle *rect,
                                                         gboolean invalidate_children);
void                gdk_window_invalidate_region        (GdkWindow *window,
                                                         GdkRegion *region,
                                                         gboolean invalidate_children);
void                gdk_window_invalidate_maybe_recurse (GdkWindow *window,
                                                         GdkRegion *region,
                                                         gboolean (child_funcGdkWindow *, gpointer) (),
                                                         gpointer user_data);
GdkRegion*          gdk_window_get_update_area          (GdkWindow *window);
void                gdk_window_freeze_updates           (GdkWindow *window);
void                gdk_window_thaw_updates             (GdkWindow *window);
void                gdk_window_process_all_updates      (void);
void                gdk_window_process_updates          (GdkWindow *window,
                                                         gboolean update_children);
void                gdk_window_set_debug_updates        (gboolean setting);
void                gdk_window_get_internal_paint_info  (GdkWindow *window,
                                                         GdkDrawable **real_drawable,
                                                         gint *x_offset,
                                                         gint *y_offset);
void                gdk_window_enable_synchronized_configure
                                                        (GdkWindow *window);
void                gdk_window_configure_finished       (GdkWindow *window);

void                gdk_window_set_user_data            (GdkWindow *window,
                                                         gpointer user_data);
void                gdk_window_set_override_redirect    (GdkWindow *window,
                                                         gboolean override_redirect);
void                gdk_window_set_accept_focus         (GdkWindow *window,
                                                         gboolean accept_focus);
void                gdk_window_set_focus_on_map         (GdkWindow *window,
                                                         gboolean focus_on_map);
void                gdk_window_add_filter               (GdkWindow *window,
                                                         GdkFilterFunc function,
                                                         gpointer data);
void                gdk_window_remove_filter            (GdkWindow *window,
                                                         GdkFilterFunc function,
                                                         gpointer data);
GdkFilterReturn     (*GdkFilterFunc)                    (GdkXEvent *xevent,
                                                         GdkEvent *event,
                                                         gpointer data);
enum                GdkFilterReturn;
typedef             GdkXEvent;
void                gdk_window_shape_combine_mask       (GdkWindow *window,
                                                         GdkBitmap *mask,
                                                         gint x,
                                                         gint y);
void                gdk_window_shape_combine_region     (GdkWindow *window,
                                                         GdkRegion *shape_region,
                                                         gint offset_x,
                                                         gint offset_y);
void                gdk_window_set_child_shapes         (GdkWindow *window);
void                gdk_window_merge_child_shapes       (GdkWindow *window);
void                gdk_window_input_shape_combine_mask (GdkWindow *window,
                                                         GdkBitmap *mask,
                                                         gint x,
                                                         gint y);
void                gdk_window_input_shape_combine_region
                                                        (GdkWindow *window,
                                                         GdkRegion *shape_region,
                                                         gint offset_x,
                                                         gint offset_y);
void                gdk_window_set_child_input_shapes   (GdkWindow *window);
void                gdk_window_merge_child_input_shapes (GdkWindow *window);
gboolean            gdk_window_set_static_gravities     (GdkWindow *window,
                                                         gboolean use_static);
void                gdk_window_set_hints                (GdkWindow *window,
                                                         gint x,
                                                         gint y,
                                                         gint min_width,
                                                         gint min_height,
                                                         gint max_width,
                                                         gint max_height,
                                                         gint flags);
void                gdk_window_set_title                (GdkWindow *window,
                                                         const gchar *title);
void                gdk_window_set_background           (GdkWindow *window,
                                                         const GdkColor *color);
void                gdk_window_set_back_pixmap          (GdkWindow *window,
                                                         GdkPixmap *pixmap,
                                                         gboolean parent_relative);
#define             GDK_PARENT_RELATIVE
void                gdk_window_set_cursor               (GdkWindow *window,
                                                         GdkCursor *cursor);
#define             gdk_window_set_colormap
void                gdk_window_get_user_data            (GdkWindow *window,
                                                         gpointer *data);
void                gdk_window_get_geometry             (GdkWindow *window,
                                                         gint *x,
                                                         gint *y,
                                                         gint *width,
                                                         gint *height,
                                                         gint *depth);
void                gdk_window_set_geometry_hints       (GdkWindow *window,
                                                         GdkGeometry *geometry,
                                                         GdkWindowHints geom_mask);
void                gdk_window_set_icon_list            (GdkWindow *window,
                                                         GList *pixbufs);
void                gdk_window_set_modal_hint           (GdkWindow *window,
                                                         gboolean modal);
void                gdk_window_set_type_hint            (GdkWindow *window,
                                                         GdkWindowTypeHint hint);
GdkWindowTypeHint   gdk_window_get_type_hint            (GdkWindow *window);
void                gdk_window_set_skip_taskbar_hint    (GdkWindow *window,
                                                         gboolean skips_taskbar);
void                gdk_window_set_skip_pager_hint      (GdkWindow *window,
                                                         gboolean skips_pager);
void                gdk_window_set_urgency_hint         (GdkWindow *window,
                                                         gboolean urgent);
void                gdk_window_get_position             (GdkWindow *window,
                                                         gint *x,
                                                         gint *y);
void                gdk_window_get_root_origin          (GdkWindow *window,
                                                         gint *x,
                                                         gint *y);
void                gdk_window_get_frame_extents        (GdkWindow *window,
                                                         GdkRectangle *rect);
#define             gdk_window_get_size
#define             gdk_window_get_visual
#define             gdk_window_get_colormap
#define             gdk_window_get_type
gint                gdk_window_get_origin               (GdkWindow *window,
                                                         gint *x,
                                                         gint *y);
gboolean            gdk_window_get_deskrelative_origin  (GdkWindow *window,
                                                         gint *x,
                                                         gint *y);
GdkWindow*          gdk_window_get_pointer              (GdkWindow *window,
                                                         gint *x,
                                                         gint *y,
                                                         GdkModifierType *mask);
enum                GdkModifierType;
GdkWindow*          gdk_window_get_parent               (GdkWindow *window);
GdkWindow*          gdk_window_get_toplevel             (GdkWindow *window);
GList*              gdk_window_get_children             (GdkWindow *window);
GList*              gdk_window_peek_children            (GdkWindow *window);
GdkEventMask        gdk_window_get_events               (GdkWindow *window);
void                gdk_window_set_events               (GdkWindow *window,
                                                         GdkEventMask event_mask);
void                gdk_window_set_icon                 (GdkWindow *window,
                                                         GdkWindow *icon_window,
                                                         GdkPixmap *pixmap,
                                                         GdkBitmap *mask);
void                gdk_window_set_icon_name            (GdkWindow *window,
                                                         const gchar *name);
void                gdk_window_set_transient_for        (GdkWindow *window,
                                                         GdkWindow *parent);
void                gdk_window_set_role                 (GdkWindow *window,
                                                         const gchar *role);
void                gdk_window_set_startup_id           (GdkWindow *window,
                                                         const gchar *startup_id);
void                gdk_window_set_group                (GdkWindow *window,
                                                         GdkWindow *leader);
GdkWindow*          gdk_window_get_group                (GdkWindow *window);
void                gdk_window_set_decorations          (GdkWindow *window,
                                                         GdkWMDecoration decorations);
gboolean            gdk_window_get_decorations          (GdkWindow *window,
                                                         GdkWMDecoration *decorations);
enum                GdkWMDecoration;
void                gdk_window_set_functions            (GdkWindow *window,
                                                         GdkWMFunction functions);
enum                GdkWMFunction;
GList*              gdk_window_get_toplevels            (void);
GdkWindow*          gdk_get_default_root_window         (void);

                    GdkPointerHooks;
GdkPointerHooks*    gdk_set_pointer_hooks               (const GdkPointerHooks *new_hooks);


Object Hierarchy


  GObject
   +----GdkDrawable
         +----GdkWindow

Description

A GdkWindow is a rectangular region on the screen. It's a low-level object, used to implement high-level objects such as GtkWidget and GtkWindow on the GTK+ level. A GtkWindow is a toplevel window, the thing a user might think of as a "window" with a titlebar and so on; a GtkWindow may contain many GdkWindow. For example, each GtkButton has a GdkWindow associated with it.

Example 7. Composited windows

#include <gtk/gtk.h>

/* The expose event handler for the event box.
 *
 * This function simply draws a transparency onto a widget on the area
 * for which it receives expose events.  This is intended to give the
 * event box a "transparent" background.
 *
 * In order for this to work properly, the widget must have an RGBA
 * colourmap.  The widget should also be set as app-paintable since it
 * doesn't make sense for GTK+ to draw a background if we are drawing it
 * (and because GTK+ might actually replace our transparency with its
 * default background colour).
 */
static gboolean
transparent_expose (GtkWidget      *widget,
                    GdkEventExpose *event)
{
  cairo_t *cr;

  cr = gdk_cairo_create (widget->window);
  cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
  gdk_cairo_region (cr, event->region);
  cairo_fill (cr);
  cairo_destroy (cr);

  return FALSE;
}

/* The expose event handler for the window.
 *
 * This function performs the actual compositing of the event box onto
 * the already-existing background of the window at 50% normal opacity.
 *
 * In this case we do not want app-paintable to be set on the widget
 * since we want it to draw its own (red) background. Because of this,
 * however, we must ensure that we use g_signal_register_after so that
 * this handler is called after the red has been drawn. If it was
 * called before then GTK would just blindly paint over our work.
 *
 * Note: if the child window has children, then you need a cairo 1.16
 * feature to make this work correctly.
 */
static gboolean
window_expose_event (GtkWidget      *widget,
                     GdkEventExpose *event)
{
  GdkRegion *region;
  GtkWidget *child;
  cairo_t *cr;

  /* get our child (in this case, the event box) */ 
  child = gtk_bin_get_child (GTK_BIN (widget));

  /* create a cairo context to draw to the window */
  cr = gdk_cairo_create (widget->window);

  /* the source data is the (composited) event box */
  gdk_cairo_set_source_pixmap (cr, child->window,
                               child->allocation.x,
                               child->allocation.y);

  /* draw no more than our expose event intersects our child */
  region = gdk_region_rectangle (&child->allocation);
  gdk_region_intersect (region, event->region);
  gdk_cairo_region (cr, region);
  cairo_clip (cr);

  /* composite, with a 50% opacity */
  cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
  cairo_paint_with_alpha (cr, 0.5);

  /* we're done */
  cairo_destroy (cr);

  return FALSE;
}

int
main (int argc, char **argv)
{
  GtkWidget *window, *event, *button;
  GdkScreen *screen;
  GdkColormap *rgba;
  GdkColor red;

  gtk_init (&argc, &argv);

  /* Make the widgets */
  button = gtk_button_new_with_label ("A Button");
  event = gtk_event_box_new ();
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

  /* Put a red background on the window */
  gdk_color_parse ("red", &red);
  gtk_widget_modify_bg (window, GTK_STATE_NORMAL, &red);

  /* Set the colourmap for the event box.
   * Must be done before the event box is realised.
   */
  screen = gtk_widget_get_screen (event);
  rgba = gdk_screen_get_rgba_colormap (screen);
  gtk_widget_set_colormap (event, rgba);

  /* Set our event box to have a fully-transparent background
   * drawn on it. Currently there is no way to simply tell GTK+
   * that "transparency" is the background colour for a widget.
   */
  gtk_widget_set_app_paintable (GTK_WIDGET (event), TRUE);
  g_signal_connect (event, "expose-event",
                    G_CALLBACK (transparent_expose), NULL);

  /* Put them inside one another */
  gtk_container_set_border_width (GTK_CONTAINER (window), 10);
  gtk_container_add (GTK_CONTAINER (window), event);
  gtk_container_add (GTK_CONTAINER (event), button);

  /* Realise and show everything */
  gtk_widget_show_all (window);

  /* Set the event box GdkWindow to be composited.
   * Obviously must be performed after event box is realised.
   */
  gdk_window_set_composited (event->window, TRUE);

  /* Set up the compositing handler.
   * Note that we do _after_ so that the normal (red) background is drawn
   * by gtk before our compositing occurs.
   */
  g_signal_connect_after (window, "expose-event",
                          G_CALLBACK (window_expose_event), NULL);

  gtk_main (<!-- -->);

  return 0;
}


In the example Example 7, “Composited windows”, a button is placed inside of an event box inside of a window. The event box is set as composited and therefore is no longer automatically drawn to the screen.

When the contents of the event box change, an expose event is generated on its parent window (which, in this case, belongs to the toplevel GtkWindow). The expose handler for this widget is responsible for merging the changes back on the screen in the way that it wishes.

In our case, we merge the contents with a 50% transparency. We also set the background colour of the window to red. The effect is that the background shows through the button.

Details

struct GdkWindow

struct GdkWindow;

An opaque structure representing an onscreen drawable. Pointers to structures of type GdkPixmap, GdkBitmap, and GdkWindow, can often be used interchangeably. The type GdkDrawable refers generically to any of these types.


enum GdkWindowType

typedef enum
{
  GDK_WINDOW_ROOT,
  GDK_WINDOW_TOPLEVEL,
  GDK_WINDOW_CHILD,
  GDK_WINDOW_DIALOG,
  GDK_WINDOW_TEMP,
  GDK_WINDOW_FOREIGN
} GdkWindowType;

Describes the kind of window.

GDK_WINDOW_ROOT

root window; this window has no parent, covers the entire screen, and is created by the window system

GDK_WINDOW_TOPLEVEL

toplevel window (used to implement GtkWindow)

GDK_WINDOW_CHILD

child window (used to implement e.g. GtkEntry)

GDK_WINDOW_DIALOG

useless/deprecated compatibility type

GDK_WINDOW_TEMP

override redirect temporary window (used to implement GtkMenu)

GDK_WINDOW_FOREIGN

foreign window (see gdk_window_foreign_new())

enum GdkWindowClass

typedef enum
{
  GDK_INPUT_OUTPUT,
  GDK_INPUT_ONLY
} GdkWindowClass;

GDK_INPUT_OUTPUT windows are the standard kind of window you might expect. GDK_INPUT_ONLY windows are invisible; they are used to trap events, but you can't draw on them.

GDK_INPUT_OUTPUT

window for graphics and events

GDK_INPUT_ONLY

window for events only

enum GdkWindowHints

typedef enum
{
  GDK_HINT_POS	       = 1 << 0,
  GDK_HINT_MIN_SIZE    = 1 << 1,
  GDK_HINT_MAX_SIZE    = 1 << 2,
  GDK_HINT_BASE_SIZE   = 1 << 3,
  GDK_HINT_ASPECT      = 1 << 4,
  GDK_HINT_RESIZE_INC  = 1 << 5,
  GDK_HINT_WIN_GRAVITY = 1 << 6,
  GDK_HINT_USER_POS    = 1 << 7,
  GDK_HINT_USER_SIZE   = 1 << 8
} GdkWindowHints;

Used to indicate which fields of a GdkGeometry struct should be paid attention to. Also, the presence/absence of GDK_HINT_POS, GDK_HINT_USER_POS, and GDK_HINT_USER_SIZE is significant, though they don't directly refer to GdkGeometry fields. GDK_HINT_USER_POS will be set automatically by GtkWindow if you call gtk_window_move(). GDK_HINT_USER_POS and GDK_HINT_USER_SIZE should be set if the user specified a size/position using a --geometry command-line argument; gtk_window_parse_geometry() automatically sets these flags.

GDK_HINT_POS

indicates that the program has positioned the window

GDK_HINT_MIN_SIZE

min size fields are set

GDK_HINT_MAX_SIZE

max size fields are set

GDK_HINT_BASE_SIZE

base size fields are set

GDK_HINT_ASPECT

aspect ratio fields are set

GDK_HINT_RESIZE_INC

resize increment fields are set

GDK_HINT_WIN_GRAVITY

window gravity field is set

GDK_HINT_USER_POS

indicates that the window's position was explicitly set by the user

GDK_HINT_USER_SIZE

indicates that the window's size was explicitly set by the user

GdkGeometry

typedef struct {
  gint min_width;
  gint min_height;
  gint max_width;
  gint max_height;
  gint base_width;
  gint base_height;
  gint width_inc;
  gint height_inc;
  gdouble min_aspect;
  gdouble max_aspect;
  GdkGravity win_gravity;
} GdkGeometry;

The GdkGeometry struct gives the window manager information about a window's geometry constraints. Normally you would set these on the GTK+ level using gtk_window_set_geometry_hints(). GtkWindow then sets the hints on the GdkWindow it creates.

gdk_window_set_geometry_hints() expects the hints to be fully valid already and simply passes them to the window manager; in contrast, gtk_window_set_geometry_hints() performs some interpretation. For example, GtkWindow will apply the hints to the geometry widget instead of the toplevel window, if you set a geometry widget. Also, the min_width/min_height/max_width/max_height fields may be set to -1, and GtkWindow will substitute the size request of the window or geometry widget. If the minimum size hint is not provided, GtkWindow will use its requisition as the minimum size. If the minimum size is provided and a geometry widget is set, GtkWindow will take the minimum size as the minimum size of the geometry widget rather than the entire window. The base size is treated similarly.

The canonical use-case for gtk_window_set_geometry_hints() is to get a terminal widget to resize properly. Here, the terminal text area should be the geometry widget; GtkWindow will then automatically set the base size to the size of other widgets in the terminal window, such as the menubar and scrollbar. Then, the width_inc and height_inc fields should be set to the size of one character in the terminal. Finally, the base size should be set to the size of one character. The net effect is that the minimum size of the terminal will have a 1x1 character terminal area, and only terminal sizes on the "character grid" will be allowed.

Here's an example of how the terminal example would be implemented, assuming a terminal area widget called "terminal" and a toplevel window "toplevel":

	GdkGeometry hints;

	hints.base_width = terminal->char_width;
        hints.base_height = terminal->char_height;
        hints.min_width = terminal->char_width;
        hints.min_height = terminal->char_height;
        hints.width_inc = terminal->char_width;
        hints.height_inc = terminal->char_height;

	gtk_window_set_geometry_hints (GTK_WINDOW (toplevel),
				       GTK_WIDGET (terminal),
 				       &hints,
				       GDK_HINT_RESIZE_INC |
                                       GDK_HINT_MIN_SIZE |
                                       GDK_HINT_BASE_SIZE);

The other useful fields are the min_aspect and max_aspect fields; these contain a width/height ratio as a floating point number. If a geometry widget is set, the aspect applies to the geometry widget rather than the entire window. The most common use of these hints is probably to set min_aspect and max_aspect to the same value, thus forcing the window to keep a constant aspect ratio.

gint min_width;

minimum width of window (or -1 to use requisition, with GtkWindow only)

gint min_height;

minimum height of window (or -1 to use requisition, with GtkWindow only)

gint max_width;

maximum width of window (or -1 to use requisition, with GtkWindow only)

gint max_height;

maximum height of window (or -1 to use requisition, with GtkWindow only)

gint base_width;

allowed window widths are base_width + width_inc * N where N is any integer (-1 allowed with GtkWindow)

gint base_height;

allowed window widths are base_height + height_inc * N where N is any integer (-1 allowed with GtkWindow)

gint width_inc;

width resize increment

gint height_inc;

height resize increment

gdouble min_aspect;

minimum width/height ratio

gdouble max_aspect;

maximum width/height ratio

GdkGravity win_gravity;

window gravity, see gtk_window_set_gravity()

enum GdkGravity

typedef enum
{
  GDK_GRAVITY_NORTH_WEST = 1,
  GDK_GRAVITY_NORTH,
  GDK_GRAVITY_NORTH_EAST,
  GDK_GRAVITY_WEST,
  GDK_GRAVITY_CENTER,
  GDK_GRAVITY_EAST,
  GDK_GRAVITY_SOUTH_WEST,
  GDK_GRAVITY_SOUTH,
  GDK_GRAVITY_SOUTH_EAST,
  GDK_GRAVITY_STATIC
} GdkGravity;

Defines the reference point of a window and the meaning of coordinates passed to gtk_window_move(). See gtk_window_move() and the "implementation notes" section of the Extended Window Manager Hints specification for more details.

GDK_GRAVITY_NORTH_WEST

the reference point is at the top left corner.

GDK_GRAVITY_NORTH

the reference point is in the middle of the top edge.

GDK_GRAVITY_NORTH_EAST

the reference point is at the top right corner.

GDK_GRAVITY_WEST

the reference point is at the middle of the left edge.

GDK_GRAVITY_CENTER

the reference point is at the center of the window.

GDK_GRAVITY_EAST

the reference point is at the middle of the right edge.

GDK_GRAVITY_SOUTH_WEST

the reference point is at the lower left corner.

GDK_GRAVITY_SOUTH

the reference point is at the middle of the lower edge.

GDK_GRAVITY_SOUTH_EAST

the reference point is at the lower right corner.

GDK_GRAVITY_STATIC

the reference point is at the top left corner of the window itself, ignoring window manager decorations.

enum GdkWindowEdge

typedef enum
{
  GDK_WINDOW_EDGE_NORTH_WEST,
  GDK_WINDOW_EDGE_NORTH,
  GDK_WINDOW_EDGE_NORTH_EAST,
  GDK_WINDOW_EDGE_WEST,
  GDK_WINDOW_EDGE_EAST,
  GDK_WINDOW_EDGE_SOUTH_WEST,
  GDK_WINDOW_EDGE_SOUTH,
  GDK_WINDOW_EDGE_SOUTH_EAST  
} GdkWindowEdge;

Determines a window edge or corner.

GDK_WINDOW_EDGE_NORTH_WEST

the top left corner.

GDK_WINDOW_EDGE_NORTH

the top edge.

GDK_WINDOW_EDGE_NORTH_EAST

the top right corner.

GDK_WINDOW_EDGE_WEST

the left edge.

GDK_WINDOW_EDGE_EAST

the right edge.

GDK_WINDOW_EDGE_SOUTH_WEST

the lower left corner.

GDK_WINDOW_EDGE_SOUTH

the lower edge.

GDK_WINDOW_EDGE_SOUTH_EAST

the lower right corner.

enum GdkWindowTypeHint

typedef enum
{
  GDK_WINDOW_TYPE_HINT_NORMAL,
  GDK_WINDOW_TYPE_HINT_DIALOG,
  GDK_WINDOW_TYPE_HINT_MENU,		/* Torn off menu */
  GDK_WINDOW_TYPE_HINT_TOOLBAR,
  GDK_WINDOW_TYPE_HINT_SPLASHSCREEN,
  GDK_WINDOW_TYPE_HINT_UTILITY,
  GDK_WINDOW_TYPE_HINT_DOCK,
  GDK_WINDOW_TYPE_HINT_DESKTOP,
  GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU,	/* A drop down menu (from a menubar) */
  GDK_WINDOW_TYPE_HINT_POPUP_MENU,	/* A popup menu (from right-click) */
  GDK_WINDOW_TYPE_HINT_TOOLTIP,
  GDK_WINDOW_TYPE_HINT_NOTIFICATION,
  GDK_WINDOW_TYPE_HINT_COMBO,
  GDK_WINDOW_TYPE_HINT_DND
} GdkWindowTypeHint;

These are hints for the window manager that indicate what type of function the window has. The window manager can use this when determining decoration and behaviour of the window. The hint must be set before mapping the window.

See the Extended Window Manager Hints specification for more details about window types.

GDK_WINDOW_TYPE_HINT_NORMAL

Normal toplevel window.

GDK_WINDOW_TYPE_HINT_DIALOG

Dialog window.

GDK_WINDOW_TYPE_HINT_MENU

Window used to implement a menu; GTK+ uses this hint only for torn-off menus, see GtkTearoffMenuItem.

GDK_WINDOW_TYPE_HINT_TOOLBAR

Window used to implement toolbars.

GDK_WINDOW_TYPE_HINT_SPLASHSCREEN

Window used to display a splash screen during application startup.

GDK_WINDOW_TYPE_HINT_UTILITY

Utility windows which are not detached toolbars or dialogs.

GDK_WINDOW_TYPE_HINT_DOCK

Used for creating dock or panel windows.

GDK_WINDOW_TYPE_HINT_DESKTOP

Used for creating the desktop background window.

GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU

A menu that belongs to a menubar.

GDK_WINDOW_TYPE_HINT_POPUP_MENU

A menu that does not belong to a menubar, e.g. a context menu.

GDK_WINDOW_TYPE_HINT_TOOLTIP

A tooltip.

GDK_WINDOW_TYPE_HINT_NOTIFICATION

A notification - typically a "bubble" that belongs to a status icon.

GDK_WINDOW_TYPE_HINT_COMBO

A popup from a combo box.

GDK_WINDOW_TYPE_HINT_DND

A window that is used to implement a DND cursor.

GdkWindowAttr

typedef struct {
  gchar *title;
  gint event_mask;
  gint x, y;
  gint width;
  gint height;
  GdkWindowClass wclass;
  GdkVisual *visual;
  GdkColormap *colormap;
  GdkWindowType window_type;
  GdkCursor *cursor;
  gchar *wmclass_name;
  gchar *wmclass_class;
  gboolean override_redirect;
  GdkWindowTypeHint type_hint;
} GdkWindowAttr;

Attributes to use for a newly-created window.

gchar *title;

title of the window (for toplevel windows)

gint event_mask;

event mask (see gdk_window_set_events())

gint x;

X coordinate relative to parent window (see gdk_window_move())

gint y;

Y coordinate relative to parent window (see gdk_window_move())

gint width;

width of window

gint height;

height of window

GdkWindowClass wclass;

GDK_INPUT_OUTPUT (normal window) or GDK_INPUT_ONLY (invisible window that receives events)

GdkVisual *visual;

GdkVisual for window

GdkColormap *colormap;

GdkColormap for window

GdkWindowType window_type;

type of window

GdkCursor *cursor;

cursor for the window (see gdk_window_set_cursor())

gchar *wmclass_name;

don't use (see gtk_window_set_wmclass())

gchar *wmclass_class;

don't use (see gtk_window_set_wmclass())

gboolean override_redirect;

TRUE to bypass the window manager

GdkWindowTypeHint type_hint;

a hint of the function of the window

enum GdkWindowAttributesType

typedef enum
{
  GDK_WA_TITLE	   = 1 << 1,
  GDK_WA_X	   = 1 << 2,
  GDK_WA_Y	   = 1 << 3,
  GDK_WA_CURSOR	   = 1 << 4,
  GDK_WA_COLORMAP  = 1 << 5,
  GDK_WA_VISUAL	   = 1 << 6,
  GDK_WA_WMCLASS   = 1 << 7,
  GDK_WA_NOREDIR   = 1 << 8,
  GDK_WA_TYPE_HINT = 1 << 9
} GdkWindowAttributesType;

Used to indicate which fields in the GdkWindowAttr struct should be honored. For example, if you filled in the "cursor" and "x" fields of GdkWindowAttr, pass "GDK_WA_X | GDK_WA_CURSOR" to gdk_window_new(). Fields in GdkWindowAttr not covered by a bit in this enum are required; for example, the width/height, wclass, and window_type fields are required, they have no corresponding flag in GdkWindowAttributesType.

GDK_WA_TITLE

Honor the title field

GDK_WA_X

Honor the X coordinate field

GDK_WA_Y

Honor the Y coordinate field

GDK_WA_CURSOR

Honor the cursor field

GDK_WA_COLORMAP

Honor the colormap field

GDK_WA_VISUAL

Honor the visual field

GDK_WA_WMCLASS

Honor the wmclass_class and wmclass_name fields

GDK_WA_NOREDIR

Honor the override_redirect field

GDK_WA_TYPE_HINT

Honor the type_hint field

gdk_window_new ()

GdkWindow*          gdk_window_new                      (GdkWindow *parent,
                                                         GdkWindowAttr *attributes,
                                                         gint attributes_mask);

Creates a new GdkWindow using the attributes from attributes. See GdkWindowAttr and GdkWindowAttributesType for more details. Note: to use this on displays other than the default display, parent must be specified.

parent :

a GdkWindow, or NULL to create the window as a child of the default root window for the default display.

attributes :

attributes of the new window

attributes_mask :

mask indicating which fields in attributes are valid

Returns :

the new GdkWindow

gdk_window_destroy ()

void                gdk_window_destroy                  (GdkWindow *window);

Destroys the window system resources associated with window and decrements window's reference count. The window system resources for all children of window are also destroyed, but the children's reference counts are not decremented.

Note that a window will not be destroyed automatically when its reference count reaches zero. You must call this function yourself before that happens.

window :

a GdkWindow

gdk_window_ref

#define gdk_window_ref                 gdk_drawable_ref

Warning

gdk_window_ref is deprecated and should not be used in newly-written code.

Deprecated equivalent of g_object_ref()

Returns :

the window

gdk_window_unref

#define gdk_window_unref               gdk_drawable_unref

Warning

gdk_window_unref is deprecated and should not be used in newly-written code.

Deprecated equivalent of g_object_unref()


gdk_window_get_window_type ()

GdkWindowType       gdk_window_get_window_type          (GdkWindow *window);

Gets the type of the window. See GdkWindowType.

window :

a GdkWindow

Returns :

type of window

gdk_window_at_pointer ()

GdkWindow*          gdk_window_at_pointer               (gint *win_x,
                                                         gint *win_y);

Obtains the window underneath the mouse pointer, returning the location of that window in win_x, win_y. Returns NULL if the window under the mouse pointer is not known to GDK (if the window belongs to another application and a GdkWindow hasn't been created for it with gdk_window_foreign_new())

NOTE: For multihead-aware widgets or applications use gdk_display_get_window_at_pointer() instead.

win_x :

return location for origin of the window under the pointer

win_y :

return location for origin of the window under the pointer

Returns :

window under the mouse pointer

gdk_window_show ()

void                gdk_window_show                     (GdkWindow *window);

Like gdk_window_show_unraised(), but also raises the window to the top of the window stack (moves the window to the front of the Z-order).

This function maps a window so it's visible onscreen. Its opposite is gdk_window_hide().

When implementing a GtkWidget, you should call this function on the widget's GdkWindow as part of the "map" method.

window :

a GdkWindow

gdk_window_show_unraised ()

void                gdk_window_show_unraised            (GdkWindow *window);

Shows a GdkWindow onscreen, but does not modify its stacking order. In contrast, gdk_window_show() will raise the window to the top of the window stack.

On the X11 platform, in Xlib terms, this function calls XMapWindow() (it also updates some internal GDK state, which means that you can't really use XMapWindow() directly on a GDK window).

window :

a GdkWindow

gdk_window_hide ()

void                gdk_window_hide                     (GdkWindow *window);

For toplevel windows, withdraws them, so they will no longer be known to the window manager; for all windows, unmaps them, so they won't be displayed. Normally done automatically as part of gtk_widget_hide().

window :

a GdkWindow

gdk_window_is_visible ()

gboolean            gdk_window_is_visible               (GdkWindow *window);

Checks whether the window has been mapped (with gdk_window_show() or gdk_window_show_unraised()).

window :

a GdkWindow

Returns :

TRUE if the window is mapped

gdk_window_is_viewable ()

gboolean            gdk_window_is_viewable              (GdkWindow *window);

Check if the window and all ancestors of the window are mapped. (This is not necessarily "viewable" in the X sense, since we only check as far as we have GDK window parents, not to the root window.)

window :

a GdkWindow

Returns :

TRUE if the window is viewable

gdk_window_get_state ()

GdkWindowState      gdk_window_get_state                (GdkWindow *window);

Gets the bitwise OR of the currently active window state flags, from the GdkWindowState enumeration.

window :

a GdkWindow

Returns :

window state bitfield

gdk_window_withdraw ()

void                gdk_window_withdraw                 (GdkWindow *window);

Withdraws a window (unmaps it and asks the window manager to forget about it). This function is not really useful as gdk_window_hide() automatically withdraws toplevel windows before hiding them.

window :

a toplevel GdkWindow

gdk_window_iconify ()

void                gdk_window_iconify                  (GdkWindow *window);

Asks to iconify (minimize) window. The window manager may choose to ignore the request, but normally will honor it. Using gtk_window_iconify() is preferred, if you have a GtkWindow widget.

This function only makes sense when window is a toplevel window.

window :

a toplevel GdkWindow

gdk_window_deiconify ()

void                gdk_window_deiconify                (GdkWindow *window);

Attempt to deiconify (unminimize) window. On X11 the window manager may choose to ignore the request to deiconify. When using GTK+, use gtk_window_deiconify() instead of the GdkWindow variant. Or better yet, you probably want to use gtk_window_present(), which raises the window, focuses it, unminimizes it, and puts it on the current desktop.

window :

a toplevel GdkWindow

gdk_window_stick ()

void                gdk_window_stick                    (GdkWindow *window);

"Pins" a window such that it's on all workspaces and does not scroll with viewports, for window managers that have scrollable viewports. (When using GtkWindow, gtk_window_stick() may be more useful.)

On the X11 platform, this function depends on window manager support, so may have no effect with many window managers. However, GDK will do the best it can to convince the window manager to stick the window. For window managers that don't support this operation, there's nothing you can do to force it to happen.

window :

a toplevel GdkWindow

gdk_window_unstick ()

void                gdk_window_unstick                  (GdkWindow *window);

Reverse operation for gdk_window_stick(); see gdk_window_stick(), and gtk_window_unstick().

window :

a toplevel GdkWindow

gdk_window_maximize ()

void                gdk_window_maximize                 (GdkWindow *window);

Maximizes the window. If the window was already maximized, then this function does nothing.

On X11, asks the window manager to maximize window, if the window manager supports this operation. Not all window managers support this, and some deliberately ignore it or don't have a concept of "maximized"; so you can't rely on the maximization actually happening. But it will happen with most standard window managers, and GDK makes a best effort to get it to happen.

On Windows, reliably maximizes the window.

window :

a toplevel GdkWindow

gdk_window_unmaximize ()

void                gdk_window_unmaximize               (GdkWindow *window);

Unmaximizes the window. If the window wasn't maximized, then this function does nothing.

On X11, asks the window manager to unmaximize window, if the window manager supports this operation. Not all window managers support this, and some deliberately ignore it or don't have a concept of "maximized"; so you can't rely on the unmaximization actually happening. But it will happen with most standard window managers, and GDK makes a best effort to get it to happen.

On Windows, reliably unmaximizes the window.

window :

a toplevel GdkWindow

gdk_window_fullscreen ()

void                gdk_window_fullscreen               (GdkWindow *window);

Moves the window into fullscreen mode. This means the window covers the entire screen and is above any panels or task bars.

If the window was already fullscreen, then this function does nothing.

On X11, asks the window manager to put window in a fullscreen state, if the window manager supports this operation. Not all window managers support this, and some deliberately ignore it or don't have a concept of "fullscreen"; so you can't rely on the fullscreenification actually happening. But it will happen with most standard window managers, and GDK makes a best effort to get it to happen.

window :

a toplevel GdkWindow

Since 2.2


gdk_window_unfullscreen ()

void                gdk_window_unfullscreen             (GdkWindow *window);

Moves the window out of fullscreen mode. If the window was not fullscreen, does nothing.

On X11, asks the window manager to move window out of the fullscreen state, if the window manager supports this operation. Not all window managers support this, and some deliberately ignore it or don't have a concept of "fullscreen"; so you can't rely on the unfullscreenification actually happening. But it will happen with most standard window managers, and GDK makes a best effort to get it to happen.

window :

a toplevel GdkWindow

Since 2.2


gdk_window_set_keep_above ()

void                gdk_window_set_keep_above           (GdkWindow *window,
                                                         gboolean setting);

Set if window must be kept above other windows. If the window was already above, then this function does nothing.

On X11, asks the window manager to keep window above, if the window manager supports this operation. Not all window managers support this, and some deliberately ignore it or don't have a concept of "keep above"; so you can't rely on the window being kept above. But it will happen with most standard window managers, and GDK makes a best effort to get it to happen.

window :

a toplevel GdkWindow

setting :

whether to keep window above other windows

Since 2.4


gdk_window_set_keep_below ()

void                gdk_window_set_keep_below           (GdkWindow *window,
                                                         gboolean setting);

Set if window must be kept below other windows. If the window was already below, then this function does nothing.

On X11, asks the window manager to keep window below, if the window manager supports this operation. Not all window managers support this, and some deliberately ignore it or don't have a concept of "keep below"; so you can't rely on the window being kept below. But it will happen with most standard window managers, and GDK makes a best effort to get it to happen.

window :

a toplevel GdkWindow

setting :

whether to keep window below other windows

Since 2.4


gdk_window_set_opacity ()

void                gdk_window_set_opacity              (GdkWindow *window,
                                                         gdouble opacity);

Request the windowing system to make window partially transparent, with opacity 0 being fully transparent and 1 fully opaque. (Values of the opacity parameter are clamped to the [0,1] range.)

On X11, this works only on X screens with a compositing manager running.

For setting up per-pixel alpha, see gdk_screen_get_rgba_colormap(). For making non-toplevel windows translucent, see gdk_window_set_composited().

window :

a top-level GdkWindow

opacity :

opacity

Since 2.12


gdk_window_set_composited ()

void                gdk_window_set_composited           (GdkWindow *window,
                                                         gboolean composited);

Sets a GdkWindow as composited, or unsets it. Composited windows do not automatically have their contents drawn to the screen. Drawing is redirected to an offscreen buffer and an expose event is emitted on the parent of the composited window. It is the responsibility of the parent's expose handler to manually merge the off-screen content onto the screen in whatever way it sees fit. See Example 7, “Composited windows” for an example.

It only makes sense for child windows to be composited; see gdk_window_set_opacity() if you need translucent toplevel windows.

An additional effect of this call is that the area of this window is no longer clipped from regions marked for invalidation on its parent. Draws done on the parent window are also no longer clipped by the child.

This call is only supported on some systems (currently, only X11 with new enough Xcomposite and Xdamage extensions). You must call gdk_display_supports_composite() to check if setting a window as composited is supported before attempting to do so.

window :

a GdkWindow

composited :

TRUE to set the window as composited

Since 2.12


gdk_window_move ()

void                gdk_window_move                     (GdkWindow *window,
                                                         gint x,
                                                         gint y);

Repositions a window relative to its parent window. For toplevel windows, window managers may ignore or modify the move; you should probably use gtk_window_move() on a GtkWindow widget anyway, instead of using GDK functions. For child windows, the move will reliably succeed.

If you're also planning to resize the window, use gdk_window_move_resize() to both move and resize simultaneously, for a nicer visual effect.

window :

a GdkWindow

x :

X coordinate relative to window's parent

y :

Y coordinate relative to window's parent

gdk_window_resize ()

void                gdk_window_resize                   (GdkWindow *window,
                                                         gint width,
                                                         gint height);

Resizes window; for toplevel windows, asks the window manager to resize the window. The window manager may not allow the resize. When using GTK+, use gtk_window_resize() instead of this low-level GDK function.

Windows may not be resized below 1x1.

If you're also planning to move the window, use gdk_window_move_resize() to both move and resize simultaneously, for a nicer visual effect.

window :

a GdkWindow

width :

new width of the window

height :

new height of the window

gdk_window_move_resize ()

void                gdk_window_move_resize              (GdkWindow *window,
                                                         gint x,
                                                         gint y,
                                                         gint width,
                                                         gint height);

Equivalent to calling gdk_window_move() and gdk_window_resize(), except that both operations are performed at once, avoiding strange visual effects. (i.e. the user may be able to see the window first move, then resize, if you don't use gdk_window_move_resize().)

window :

a GdkWindow

x :

new X position relative to window's parent

y :

new Y position relative to window's parent

width :

new width

height :

new height

gdk_window_scroll ()

void                gdk_window_scroll                   (GdkWindow *window,
                                                         gint dx,
                                                         gint dy);

Scroll the contents of its window, both pixels and children, by the given amount. Portions of the window that the scroll operation brings in from offscreen areas are invalidated.