## GdkDisplay GdkDisplay — Controls a set of GdkScreens and their associated input devices |

## Functions

GdkDisplay * | gdk_display_open ()
GdkDisplay * | gdk_display_get_default ()
const gchar * | gdk_display_get_name ()
gint | gdk_display_get_n_screens ()
GdkScreen * | gdk_display_get_screen ()
GdkScreen * | gdk_display_get_default_screen ()
GdkDeviceManager * | gdk_display_get_device_manager ()
void | gdk_display_pointer_ungrab ()
void | gdk_display_keyboard_ungrab ()
gboolean | gdk_display_pointer_is_grabbed ()
gboolean | gdk_display_device_is_grabbed ()
void | gdk_display_beep ()
void | gdk_display_sync ()
void | gdk_display_flush ()
void | gdk_display_close ()
gboolean | gdk_display_is_closed ()
GdkEvent * | gdk_display_get_event ()
GdkEvent * | gdk_display_peek_event ()
void | gdk_display_put_event ()
gboolean | gdk_display_has_pending ()
void | gdk_display_set_double_click_time ()
void | gdk_display_set_double_click_distance ()
void | gdk_display_get_pointer ()
GList * | gdk_display_list_devices ()
GdkWindow * | gdk_display_get_window_at_pointer ()
void | gdk_display_warp_pointer ()
gboolean | gdk_display_supports_cursor_color ()
gboolean | gdk_display_supports_cursor_alpha ()
guint | gdk_display_get_default_cursor_size ()
void | gdk_display_get_maximal_cursor_size ()
GdkWindow * | gdk_display_get_default_group ()
gboolean | gdk_display_supports_selection_notification ()
gboolean | gdk_display_request_selection_notification ()
gboolean | gdk_display_supports_clipboard_persistence ()
void | gdk_display_store_clipboard ()
gboolean | gdk_display_supports_shapes ()
gboolean | gdk_display_supports_input_shapes ()
gboolean | gdk_display_supports_composite ()
GdkAppLaunchContext * | gdk_display_get_app_launch_context ()
void | gdk_display_notify_startup_complete ()

## Signals

void | closed | Run Last
void | opened | Run Last

## Types and Values

| GdkDisplay

## Object Hierarchy

        GObject
        ╰── GdkDisplay

## Includes

    #include <gdk/gdk.h>

## Description

GdkDisplay objects purpose are two fold:

- To manage and provide information about input devices (pointers and keyboards)

- To manage and provide information about the available GdkScreens

GdkDisplay objects are the GDK representation of an X Display, which can be described as a workstation consisting of a keyboard, a pointing device (such as a mouse) and one or more screens. It is used to open and keep track of various GdkScreen objects currently instantiated by the application. It is also used to access the keyboard(s) and mouse pointer(s) of the display.

Most of the input device handling has been factored out into the separate GdkDeviceManager object. Every display has a device manager, which you can obtain using `gdk_display_get_device_manager()`.

## Functions

### gdk_display_open ()

    GdkDisplay *
    gdk_display_open (const gchar *display_name);

Opens a display.

#### Parameters

display_name | the name of the display to open |

#### Returns

a GdkDisplay, or `NULL` if the display could not be opened.

[nullable][transfer none]

Since 2.2

### gdk_display_get_default ()

    GdkDisplay *
    gdk_display_get_default (void);

Gets the default GdkDisplay. This is a convenience function for: `gdk_display_manager_get_default_display (`gdk_display_manager_get()`)`.

#### Returns

a GdkDisplay, or `NULL` if there is no default display.

[nullable][transfer none]

Since 2.2

### gdk_display_get_name ()

    const gchar *
    gdk_display_get_name (GdkDisplay *display);

Gets the name of the display.

#### Parameters

display | a GdkDisplay |

#### Returns

a string representing the display name. This string is owned by GDK and should not be modified or freed.

Since 2.2

### gdk_display_get_n_screens ()

    gint
    gdk_display_get_n_screens (GdkDisplay *display);

`gdk_display_get_n_screens` has been deprecated since version 3.10 and should not be used in newly-written code.

The number of screens is always 1.

Gets the number of screen managed by the `display` .

#### Parameters

display | a GdkDisplay |

#### Returns

number of screens.

Since 2.2

### gdk_display_get_screen ()

    GdkScreen *
    gdk_display_get_screen (GdkDisplay *display,
                            gint screen_num);

Returns a screen object for one of the screens of the display.

#### Parameters

display | a GdkDisplay |
screen_num | the screen number |

#### Returns

the GdkScreen object.

[transfer none]

Since 2.2

### gdk_display_get_default_screen ()

    GdkScreen *
    gdk_display_get_default_screen (GdkDisplay *display);

Get the default GdkScreen for `display` .

#### Parameters

display | a GdkDisplay |

#### Returns

the default GdkScreen object for `display` .

[transfer none]

Since 2.2

### gdk_display_get_device_manager ()

    GdkDeviceManager *
    gdk_display_get_device_manager (GdkDisplay *display);

Returns the GdkDeviceManager associated to `display` .

#### Parameters

display | a GdkDisplay. |

#### Returns

A GdkDeviceManager, or `NULL`. This memory is owned by GDK and must not be freed or unreferenced.

[nullable][transfer none]

Since 3.0

### gdk_display_pointer_ungrab ()

    void
    gdk_display_pointer_ungrab (GdkDisplay *display,
                                guint32 time_);

`gdk_display_pointer_ungrab` has been deprecated since version 3.0 and should not be used in newly-written code.

Use `gdk_device_ungrab()`, together with `gdk_device_grab()` instead.

Release any pointer grab.

#### Parameters

display | a GdkDisplay. |
time_ | a timestap (e.g. `GDK_CURRENT_TIME`). |

Since 2.2

### gdk_display_keyboard_ungrab ()

    void
    gdk_display_keyboard_ungrab (GdkDisplay *display,
                                 guint32 time_);

`gdk_display_keyboard_ungrab` has been deprecated since version 3.0 and should not be used in newly-written code.

Use `gdk_device_ungrab()`, together with `gdk_device_grab()` instead.

Release any keyboard grab

#### Parameters

display | a GdkDisplay. |
time_ | a timestap (e.g GDK_CURRENT_TIME). |

Since 2.2

### gdk_display_pointer_is_grabbed ()

    gboolean
    gdk_display_pointer_is_grabbed (GdkDisplay *display);

`gdk_display_pointer_is_grabbed` has been deprecated since version 3.0 and should not be used in newly-written code.

Use `gdk_display_device_is_grabbed()` instead.

Test if the pointer is grabbed.

#### Parameters

display | a GdkDisplay |

#### Returns

`TRUE` if an active X pointer grab is in effect

Since 2.2

### gdk_display_device_is_grabbed ()

    gboolean
    gdk_display_device_is_grabbed (GdkDisplay *display,
                                   GdkDevice *device);

Returns `TRUE` if there is an ongoing grab on `device` for `display` .

#### Parameters

display | a GdkDisplay |
device | a GdkDevice |

#### Returns

`TRUE` if there is a grab in effect for `device` .

### gdk_display_beep ()

    void
    gdk_display_beep (GdkDisplay *display);

Emits a short beep on `display`

#### Parameters

display | a GdkDisplay |

Since 2.2

### gdk_display_sync ()

    void
    gdk_display_sync (GdkDisplay *display);

Flushes any requests queued for the windowing system and waits until all requests have been handled. This is often used for making sure that the display is synchronized with the current state of the program. Calling `gdk_display_sync()` before `gdk_error_trap_pop()` makes sure that any errors generated from earlier requests are handled before the error trap is removed.

This is most useful for X11. On windowing systems where requests are handled synchronously, this function will do nothing.

#### Parameters

display | a GdkDisplay |

Since 2.2

### gdk_display_flush ()

    void
    gdk_display_flush (GdkDisplay *display);

Flushes any requests queued for the windowing system; this happens automatically when the main loop blocks waiting for new events, but if your application is drawing without returning control to the main loop, you may need to call this function explicitly. A common case where this function needs to be called is when an application is executing drawing commands from a thread other than the thread where the main loop is running.

This is most useful for X11. On windowing systems where requests are handled synchronously, this function will do nothing.

#### Parameters

display | a GdkDisplay |

Since 2.4

### gdk_display_close ()

    void
    gdk_display_close (GdkDisplay *display);

Closes the connection to the windowing system for the given display, and cleans up associated resources.

#### Parameters

display | a GdkDisplay |

Since 2.2

### gdk_display_is_closed ()

    gboolean
    gdk_display_is_closed (GdkDisplay *display);

Finds out if the display has been closed.

#### Parameters

display | a GdkDisplay |

#### Returns

`TRUE` if the display is closed.

Since 2.22

### gdk_display_get_event ()

    GdkEvent *
    gdk_display_get_event (GdkDisplay *display);

Gets the next GdkEvent to be processed for `display` , fetching events from the windowing system if necessary.

#### Parameters

display | a GdkDisplay |

#### Returns

the next GdkEvent to be processed, or `NULL` if no events are pending. The returned GdkEvent should be freed with `gdk_event_free()`.

[nullable]

Since 2.2

### gdk_display_peek_event ()

    GdkEvent *
    gdk_display_peek_event (GdkDisplay *display);

Gets a copy of the first GdkEvent in the `display` ’s event queue, without removing the event from the queue. (Note that this function will not get more events from the windowing system. It only checks the events that have already been moved to the GDK event queue.)

#### Parameters

display | a GdkDisplay |

#### Returns

a copy of the first GdkEvent on the event queue, or `NULL` if no events are in the queue. The returned GdkEvent should be freed with `gdk_event_free()`.

[nullable]

Since 2.2

### gdk_display_put_event ()

    void
    gdk_display_put_event (GdkDisplay *display,
                           const GdkEvent *event);

Appends a copy of the given event onto the front of the event queue for `display` .

#### Parameters

display | a GdkDisplay |
event | a GdkEvent. |

Since 2.2

### gdk_display_has_pending ()

    gboolean
    gdk_display_has_pending (GdkDisplay *display);

Returns whether the display has events that are waiting to be processed.

#### Parameters

display | a GdkDisplay |

#### Returns

`TRUE` if there are events ready to be processed.

Since 3.0

### gdk_display_set_double_click_time ()

    void
    gdk_display_set_double_click_time (GdkDisplay *display,
                                       guint msec);

Sets the double click time (two clicks within this time interval count as a double click and result in a GDK_2BUTTON_PRESS event). Applications should not set this, it is a global user-configured setting.

#### Parameters

display | a GdkDisplay |
msec | double click time in milliseconds (thousandths of a second) |

Since 2.2

### gdk_display_set_double_click_distance ()

    void
    gdk_display_set_double_click_distance (GdkDisplay *display,
                                           guint distance);

Sets the double click distance (two clicks within this distance count as a double click and result in a GDK_2BUTTON_PRESS event). See also `gdk_display_set_double_click_time()`. Applications should not set this, it is a global user-configured setting.

#### Parameters

display | a GdkDisplay |
distance | distance in pixels |

Since 2.4

### gdk_display_get_pointer ()

    void
    gdk_display_get_pointer (GdkDisplay *display,
                             GdkScreen **screen,
                             gint *x,
                             gint *y,
                             GdkModifierType *mask);

`gdk_display_get_pointer` has been deprecated since version 3.0 and should not be used in newly-written code.

Use `gdk_device_get_position()` instead.

Gets the current location of the pointer and the current modifier mask for a given display.

#### Parameters

display | a GdkDisplay |
screen | location to store the screen that the cursor is on, or `NULL`. | [out][allow-none][transfer none]
x | location to store root window X coordinate of pointer, or `NULL`. | [out][allow-none]
y | location to store root window Y coordinate of pointer, or `NULL`. | [out][allow-none]
mask | location to store current modifier mask, or `NULL`. | [out][allow-none]

Since 2.2

### gdk_display_list_devices ()

    GList *
    gdk_display_list_devices (GdkDisplay *display);

`gdk_display_list_devices` has been deprecated since version 3.0 and should not be used in newly-written code.

Use `gdk_device_manager_list_devices()` instead.

Returns the list of available input devices attached to `display` . The list is statically allocated and should not be freed.

#### Parameters

display | a GdkDisplay |

#### Returns

a list of GdkDevice.

[transfer none][element-type GdkDevice]

Since 2.2

### gdk_display_get_window_at_pointer ()

    GdkWindow *
    gdk_display_get_window_at_pointer (GdkDisplay *display,
                                       gint *win_x,
                                       gint *win_y);

`gdk_display_get_window_at_pointer` has been deprecated since version 3.0 and should not be used in newly-written code.

Use `gdk_device_get_window_at_position()` instead.

Obtains the window underneath the mouse pointer, returning the location of the pointer in that window in `win_x` , `win_y` for `screen` . Returns `NULL` if the window under the mouse pointer is not known to GDK (for example, belongs to another application).

#### Parameters

display | a GdkDisplay |
win_x | return location for x coordinate of the pointer location relative to the window origin, or `NULL`. | [out][allow-none]
win_y | return location for y coordinate of the pointer location relative & to the window origin, or `NULL`. | [out][allow-none]

#### Returns

the window under the mouse pointer, or `NULL`.

[nullable][transfer none]

Since 2.2

### gdk_display_warp_pointer ()

    void
    gdk_display_warp_pointer (GdkDisplay *display,
                              GdkScreen *screen,
                              gint x,
                              gint y);

`gdk_display_warp_pointer` has been deprecated since version 3.0 and should not be used in newly-written code.

Use `gdk_device_warp()` instead.

Warps the pointer of `display` to the point `x` ,`y` on the screen `screen` , unless the pointer is confined to a window by a grab, in which case it will be moved as far as allowed by the grab. Warping the pointer creates events as if the user had moved the mouse instantaneously to the destination.

Note that the pointer should normally be under the control of the user. This function was added to cover some rare use cases like keyboard navigation support for the color picker in the GtkColorSelectionDialog.

#### Parameters

display | a GdkDisplay |
screen | the screen of `display` to warp the pointer to |
x | the x coordinate of the destination |
y | the y coordinate of the destination |

Since 2.8

### gdk_display_supports_cursor_color ()

    gboolean
    gdk_display_supports_cursor_color (GdkDisplay *display);

Returns `TRUE` if multicolored cursors are supported on `display` . Otherwise, cursors have only a forground and a background color.

#### Parameters

display | a GdkDisplay |

#### Returns

whether cursors can have multiple colors.

Since 2.4

### gdk_display_supports_cursor_alpha ()

    gboolean
    gdk_display_supports_cursor_alpha (GdkDisplay *display);

Returns `TRUE` if cursors can use an 8bit alpha channel on `display` . Otherwise, cursors are restricted to bilevel alpha (i.e. a mask).

#### Parameters

display | a GdkDisplay |

#### Returns

whether cursors can have alpha channels.

Since 2.4

### gdk_display_get_default_cursor_size ()

    guint
    gdk_display_get_default_cursor_size (GdkDisplay *display);

Returns the default size to use for cursors on `display` .

#### Parameters

display | a GdkDisplay |

#### Returns

the default cursor size.

Since 2.4

### gdk_display_get_maximal_cursor_size ()

    void
    gdk_display_get_maximal_cursor_size (GdkDisplay *display,
                                         guint *width,
                                         guint *height);

Gets the maximal size to use for cursors on `display` .

#### Parameters

display | a GdkDisplay |
width | the return location for the maximal cursor width. | [out]
height | the return location for the maximal cursor height. | [out]

Since 2.4

### gdk_display_get_default_group ()

    GdkWindow *
    gdk_display_get_default_group (GdkDisplay *display);

Returns the default group leader window for all toplevel windows on `display` . This window is implicitly created by GDK. See `gdk_window_set_group()`.

#### Parameters

display | a GdkDisplay |

#### Returns

The default group leader window for `display` .

[transfer none]

Since 2.4

### gdk_display_supports_selection_notification ()

    gboolean
    gdk_display_supports_selection_notification
                                   (GdkDisplay *display);

Returns whether GdkEventOwnerChange events will be sent when the owner of a selection changes.

#### Parameters

display | a GdkDisplay |

#### Returns

whether GdkEventOwnerChange events will be sent.

Since 2.6

### gdk_display_request_selection_notification ()

    gboolean
    gdk_display_request_selection_notification
                                   (GdkDisplay *display,
                                    GdkAtom selection);

Request GdkEventOwnerChange events for ownership changes of the selection named by the given atom.

#### Parameters

display | a GdkDisplay |
selection | the GdkAtom naming the selection for which ownership change notification is requested |

#### Returns

whether GdkEventOwnerChange events will be sent.

Since 2.6

### gdk_display_supports_clipboard_persistence ()

    gboolean
    gdk_display_supports_clipboard_persistence
                                   (GdkDisplay *display);

Returns whether the speicifed display supports clipboard persistance; i.e. if it’s possible to store the clipboard data after an application has quit. On X11 this checks if a clipboard daemon is running.

#### Parameters

display | a GdkDisplay |

#### Returns

`TRUE` if the display supports clipboard persistance.

Since 2.6

### gdk_display_store_clipboard ()

    void
    gdk_display_store_clipboard (GdkDisplay *display,
                                 GdkWindow *clipboard_window,
                                 guint32 time_,
                                 const GdkAtom *targets,
                                 gint n_targets);

Issues a request to the clipboard manager to store the clipboard data. On X11, this is a special program that works according to the FreeDesktop Clipboard Specification.

#### Parameters

display | a GdkDisplay |
clipboard_window | a GdkWindow belonging to the clipboard owner |
time_ | a timestamp |
targets | an array of targets that should be saved, or `NULL` if all available targets should be saved. | [array length=n_targets]
n_targets | length of the `targets` array |

Since 2.6

### gdk_display_supports_shapes ()

    gboolean
    gdk_display_supports_shapes (GdkDisplay *display);

Returns `TRUE` if `gdk_window_shape_combine_mask()` can be used to create shaped windows on `display` .

#### Parameters

display | a GdkDisplay |

#### Returns

`TRUE` if shaped windows are supported

Since 2.10

### gdk_display_supports_input_shapes ()

    gboolean
    gdk_display_supports_input_shapes (GdkDisplay *display);

Returns `TRUE` if `gdk_window_input_shape_combine_mask()` can be used to modify the input shape of windows on `display` .

#### Parameters

display | a GdkDisplay |

#### Returns

`TRUE` if windows with modified input shape are supported

Since 2.10

### gdk_display_supports_composite ()

    gboolean
    gdk_display_supports_composite (GdkDisplay *display);

Returns `TRUE` if `gdk_window_set_composited()` can be used to redirect drawing on the window using compositing.

Currently this only works on X11 with XComposite and XDamage extensions available.

#### Parameters

display | a GdkDisplay |

#### Returns

`TRUE` if windows may be composited.

Since 2.12

### gdk_display_get_app_launch_context ()

    GdkAppLaunchContext *
    gdk_display_get_app_launch_context (GdkDisplay *display);

Returns a GdkAppLaunchContext suitable for launching applications on the given display.

#### Parameters

display | a GdkDisplay |

#### Returns

a new GdkAppLaunchContext for `display` . Free with `g_object_unref()` when done.

[transfer full]

Since 3.0

### gdk_display_notify_startup_complete ()

    void
    gdk_display_notify_startup_complete (GdkDisplay *display,
                                         const gchar *startup_id);

Indicates to the GUI environment that the application has finished loading, using a given identifier.

GTK+ will call this function automatically for GtkWindow with custom startup-notification identifier unless `gtk_window_set_auto_startup_notification()` is called to disable that feature.

#### Parameters

display | a GdkDisplay |
startup_id | a startup-notification identifier, for which notification process should be completed |

Since 3.0

## Types and Values

### GdkDisplay

    typedef struct _GdkDisplay GdkDisplay;

## Signal Details

### The `“closed”` signal

    void
    user_function (GdkDisplay *display,
                   gboolean    is_error,
                   gpointer    user_data)

The ::closed signal is emitted when the connection to the windowing system for `display` is closed.

#### Parameters

display | the object on which the signal is emitted |
is_error | `TRUE` if the display was closed due to an error |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

Since 2.2

### The `“opened”` signal

    void
    user_function (GdkDisplay *display,
                   gpointer    user_data)

The ::opened signal is emitted when the connection to the windowing system for `display` is opened.

#### Parameters

display | the object on which the signal is emitted |
user_data | user data set when the signal handler was connected. |

Flags: Run Last