Top | ![]() |
![]() |
![]() |
![]() |
GdkCursor * | cursor | Read / Write |
GdkDisplay * | display | Read / Write / Construct Only |
GdkFrameClock * | frame-clock | Read / Write / Construct Only |
gboolean | mapped | Read |
gboolean | event | Run Last |
void | popup-layout-changed | Run First |
gboolean | render | Run Last |
void | size-changed | Run First |
GdkSurface | |
enum | GdkSurfaceHints |
GdkGeometry | |
enum | GdkGravity |
enum | GdkSurfaceEdge |
enum | GdkSurfaceTypeHint |
enum | GdkSurfaceState |
enum | GdkModifierType |
enum | GdkModifierIntent |
A GdkSurface is a (usually) rectangular region on the screen. It’s a low-level object, used to implement high-level objects such as GtkWindow on the GTK level.
GdkSurface * gdk_surface_new_toplevel (GdkDisplay *display
,int width
,int height
);
Creates a new toplevel surface.
[constructor]
GdkSurface * gdk_surface_new_popup (GdkSurface *parent
,gboolean autohide
);
Create a new popup surface.
The surface will be attached to parent
and can be positioned relative to it
using gdk_surface_show_popup()
or later using gdk_surface_layout_popup()
.
[constructor]
void
gdk_surface_destroy (GdkSurface *surface
);
Destroys the window system resources associated with surface
and decrements surface
's
reference count. The window system resources for all children of surface
are also
destroyed, but the children’s reference counts are not decremented.
Note that a surface will not be destroyed automatically when its reference count reaches zero. You must call this function yourself before that happens.
gboolean
gdk_surface_is_destroyed (GdkSurface *surface
);
Check to see if a surface is destroyed..
GdkDisplay *
gdk_surface_get_display (GdkSurface *surface
);
Gets the GdkDisplay associated with a GdkSurface.
void
gdk_surface_hide (GdkSurface *surface
);
For toplevel surfaces, withdraws them, so they will no longer be
known to the window manager; for all surfaces, unmaps them, so
they won’t be displayed. Normally done automatically as
part of gtk_widget_hide()
.
gboolean
gdk_surface_is_viewable (GdkSurface *surface
);
Check if the surface and all ancestors of the surface are mapped. (This is not necessarily "viewable" in the X sense, since we only check as far as we have GDK surface parents, not to the root surface.)
gboolean
gdk_surface_get_mapped (GdkSurface *surface
);
Checks whether the surface has been mapped (with gdk_surface_show()
or
gdk_surface_show_unraised()
).
int
gdk_surface_get_width (GdkSurface *surface
);
Returns the width of the given surface
.
On the X11 platform the returned size is the size reported in the most-recently-processed configure event, rather than the current size on the X server.
int
gdk_surface_get_height (GdkSurface *surface
);
Returns the height of the given surface
.
On the X11 platform the returned size is the size reported in the most-recently-processed configure event, rather than the current size on the X server.
gboolean gdk_surface_translate_coordinates (GdkSurface *from
,GdkSurface *to
,double *x
,double *y
);
Translates the given coordinates from being
relative to the from
surface to being relative
to the to
surface.
Note that this only works if to
and from
are
popups or transient-for to the same toplevel
(directly or indirectly).
void gdk_surface_begin_resize_drag (GdkSurface *surface
,GdkSurfaceEdge edge
,GdkDevice *device
,gint button
,gint x
,gint y
,guint32 timestamp
);
Begins a surface resize operation (for a toplevel surface). You might use this function to implement a “window resize grip,”
surface |
a toplevel GdkSurface |
|
edge |
the edge or corner from which the drag is started |
|
device |
the device used for the operation |
|
button |
the button being used to drag, or 0 for a keyboard-initiated drag |
|
x |
surface X coordinate of mouse click that began the drag |
|
y |
surface Y coordinate of mouse click that began the drag |
|
timestamp |
timestamp of mouse click that began the drag (use |
void gdk_surface_begin_move_drag (GdkSurface *surface
,GdkDevice *device
,gint button
,gint x
,gint y
,guint32 timestamp
);
Begins a surface move operation (for a toplevel surface).
surface |
a toplevel GdkSurface |
|
device |
the device used for the operation |
|
button |
the button being used to drag, or 0 for a keyboard-initiated drag |
|
x |
surface X coordinate of mouse click that began the drag |
|
y |
surface Y coordinate of mouse click that began the drag |
|
timestamp |
timestamp of mouse click that began the drag |
void gdk_surface_constrain_size (GdkGeometry *geometry
,GdkSurfaceHints flags
,gint width
,gint height
,gint *new_width
,gint *new_height
);
Constrains a desired width and height according to a set of geometry hints (such as minimum and maximum size).
geometry |
a GdkGeometry structure |
|
flags |
a mask indicating what portions of |
|
width |
desired width of surface |
|
height |
desired height of the surface |
|
new_width |
location to store resulting width. |
[out] |
new_height |
location to store resulting height. |
[out] |
void
gdk_surface_beep (GdkSurface *surface
);
Emits a short beep associated to surface
in the appropriate
display, if supported. Otherwise, emits a short beep on
the display just as gdk_display_beep()
.
gint
gdk_surface_get_scale_factor (GdkSurface *surface
);
Returns the internal scale factor that maps from surface coordiantes to the actual device pixels. On traditional systems this is 1, but on very high density outputs this can be a higher value (often 2).
A higher value means that drawing is automatically scaled up to a higher resolution, so any code doing drawing will automatically look nicer. However, if you are supplying pixel-based data the scale value can be used to determine whether to use a pixel resource with higher resolution data.
The scale of a surface may change during runtime, if this happens a configure event will be sent to the toplevel surface.
void gdk_surface_set_opaque_region (GdkSurface *surface
,cairo_region_t *region
);
For optimisation purposes, compositing window managers may like to not draw obscured regions of surfaces, or turn off blending during for these regions. With RGB windows with no transparency, this is just the shape of the window, but with ARGB32 windows, the compositor does not know what regions of the window are transparent or not.
This function only works for toplevel surfaces.
GTK will update this property automatically if
the surface
background is opaque, as we know where the opaque regions
are. If your surface background is not opaque, please update this
property in your “css-changed” handler.
GdkGLContext * gdk_surface_create_gl_context (GdkSurface *surface
,GError **error
);
Creates a new GdkGLContext matching the framebuffer format to the visual of the GdkSurface. The context is disconnected from any particular surface or surface.
If the creation of the GdkGLContext failed, error
will be set.
Before using the returned GdkGLContext, you will need to
call gdk_gl_context_make_current()
or gdk_gl_context_realize()
.
GdkVulkanContext * gdk_surface_create_vulkan_context (GdkSurface *surface
,GError **error
);
Creates a new GdkVulkanContext for rendering on surface
.
If the creation of the GdkVulkanContext failed, error
will be set.
GdkCairoContext *
gdk_surface_create_cairo_context (GdkSurface *surface
);
Creates a new GdkCairoContext for rendering on surface
.
void
gdk_surface_queue_expose (GdkSurface *surface
);
Forces an expose event for surface
to be scheduled.
If the invalid area of surface
is empty, an expose event will
still be emitted. Its invalid region will be empty.
This function is useful for implementations that track invalid regions on their own.
void
gdk_surface_freeze_updates (GdkSurface *surface
);
Temporarily freezes a surface such that it won’t receive expose
events. The surface will begin receiving expose events again when
gdk_surface_thaw_updates()
is called. If gdk_surface_freeze_updates()
has been called more than once, gdk_surface_thaw_updates()
must be called
an equal number of times to begin processing exposes.
void
gdk_surface_thaw_updates (GdkSurface *surface
);
Thaws a surface frozen with gdk_surface_freeze_updates()
. Note that this
will not necessarily schedule updates if the surface freeze count reaches
zero.
GdkFrameClock *
gdk_surface_get_frame_clock (GdkSurface *surface
);
Gets the frame clock for the surface. The frame clock for a surface never changes unless the surface is reparented to a new toplevel surface.
void gdk_surface_set_cursor (GdkSurface *surface
,GdkCursor *cursor
);
Sets the default mouse pointer for a GdkSurface.
Note that cursor
must be for the same display as surface
.
Use gdk_cursor_new_from_name()
or gdk_cursor_new_from_texture()
to
create the cursor. To make the cursor invisible, use GDK_BLANK_CURSOR
.
Passing NULL
for the cursor
argument to gdk_surface_set_cursor()
means
that surface
will use the cursor of its parent surface. Most surfaces
should use this default.
GdkCursor *
gdk_surface_get_cursor (GdkSurface *surface
);
Retrieves a GdkCursor pointer for the cursor currently set on the
specified GdkSurface, or NULL
. If the return value is NULL
then
there is no custom cursor set on the specified surface, and it is
using the cursor for its parent surface.
a GdkCursor, or NULL
. The
returned object is owned by the GdkSurface and should not be
unreferenced directly. Use gdk_surface_set_cursor()
to unset the
cursor of the surface.
[nullable][transfer none]
void gdk_surface_set_device_cursor (GdkSurface *surface
,GdkDevice *device
,GdkCursor *cursor
);
Sets a specific GdkCursor for a given device when it gets inside surface
.
Use gdk_cursor_new_fromm_name()
or gdk_cursor_new_from_texture()
to create
the cursor. To make the cursor invisible, use GDK_BLANK_CURSOR
. Passing
NULL
for the cursor
argument to gdk_surface_set_cursor()
means that
surface
will use the cursor of its parent surface. Most surfaces should
use this default.
GdkCursor * gdk_surface_get_device_cursor (GdkSurface *surface
,GdkDevice *device
);
Retrieves a GdkCursor pointer for the device
currently set on the
specified GdkSurface, or NULL
. If the return value is NULL
then
there is no custom cursor set on the specified surface, and it is
using the cursor for its parent surface.
a GdkCursor, or NULL
. The
returned object is owned by the GdkSurface and should not be
unreferenced directly. Use gdk_surface_set_cursor()
to unset the
cursor of the surface.
[nullable][transfer none]
void gdk_surface_set_input_region (GdkSurface *surface
,cairo_region_t *region
);
Apply the region to the surface for the purpose of event
handling. Mouse events which happen while the pointer position
corresponds to an unset bit in the mask will be passed on the
surface below surface
.
An input shape is typically used with RGBA surfaces. The alpha channel of the surface defines which pixels are invisible and allows for nicely antialiased borders, and the input shape controls where the surface is “clickable”.
On the X11 platform, this requires version 1.1 of the shape extension.
On the Win32 platform, this functionality is not present and the function does nothing.
void gdk_surface_set_shadow_width (GdkSurface *surface
,gint left
,gint right
,gint top
,gint bottom
);
Newer GTK windows using client-side decorations use extra geometry around their frames for effects like shadows and invisible borders. Window managers that want to maximize windows or snap to edges need to know where the extents of the actual frame lie, so that users don’t feel like windows are snapping against random invisible edges.
Note that this property is automatically updated by GTK, so this function should only be used by applications which do not use GTK to create toplevel surfaces.
void gdk_surface_get_device_position (GdkSurface *surface
,GdkDevice *device
,double *x
,double *y
,GdkModifierType *mask
);
Obtains the current device position in doubles and modifier state.
The position is given in coordinates relative to the upper left
corner of surface
.
surface |
a GdkSurface. |
|
device |
pointer GdkDevice to query to. |
|
x |
return location for the X coordinate of |
[out][allow-none] |
y |
return location for the Y coordinate of |
[out][allow-none] |
mask |
return location for the modifier mask, or |
[out][allow-none] |
gboolean
gdk_surface_get_support_multidevice (GdkSurface *surface
);
Returns TRUE
if the surface is aware of the existence of multiple
devices.
void gdk_surface_set_support_multidevice (GdkSurface *surface
,gboolean support_multidevice
);
This function will enable multidevice features in surface
.
Multidevice aware surfaces will need to handle properly multiple, per device enter/leave events, device grabs and grab ownerships.
surface |
a GdkSurface. |
|
support_multidevice |
|
typedef struct _GdkSurface GdkSurface;
The GdkSurface struct contains only private fields and should not be accessed directly.
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.
indicates that the program has positioned the surface |
||
min size fields are set |
||
max size fields are set |
||
base size fields are set |
||
aspect ratio fields are set |
||
resize increment fields are set |
||
surface gravity field is set |
||
indicates that the surface’s position was explicitly set by the user |
||
indicates that the surface’s size was explicitly set by the user |
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 surface’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 GdkSurface it creates.
gdk_surface_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 surface 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 surface. 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”:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
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.
minimum width of surface (or -1 to use requisition, with GtkWindow only) |
||
minimum height of surface (or -1 to use requisition, with GtkWindow only) |
||
maximum width of surface (or -1 to use requisition, with GtkWindow only) |
||
maximum height of surface (or -1 to use requisition, with GtkWindow only) |
||
allowed surface widths are |
||
allowed surface widths are |
||
width resize increment |
||
height resize increment |
||
minimum width/height ratio |
||
maximum width/height ratio |
||
GdkGravity |
surface gravity, see |
Defines the reference point of a surface 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.
the reference point is at the top left corner. |
||
the reference point is in the middle of the top edge. |
||
the reference point is at the top right corner. |
||
the reference point is at the middle of the left edge. |
||
the reference point is at the center of the surface. |
||
the reference point is at the middle of the right edge. |
||
the reference point is at the lower left corner. |
||
the reference point is at the middle of the lower edge. |
||
the reference point is at the lower right corner. |
||
the reference point is at the top left corner of the surface itself, ignoring window manager decorations. |
Determines a surface edge or corner.
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.
Normal toplevel window. |
||
Dialog window. |
||
Window used to implement a menu; GTK uses this hint only for torn-off menus, see GtkTearoffMenuItem. |
||
Window used to implement toolbars. |
||
Window used to display a splash screen during application startup. |
||
Utility windows which are not detached toolbars or dialogs. |
||
Used for creating dock or panel windows. |
||
Used for creating the desktop background window. |
||
A menu that belongs to a menubar. |
||
A menu that does not belong to a menubar, e.g. a context menu. |
||
A tooltip. |
||
A notification - typically a “bubble” that belongs to a status icon. |
||
A popup from a combo box. |
||
A window that is used to implement a DND cursor. |
Specifies the state of a toplevel surface.
On platforms that support information about individual edges, the GDK_SURFACE_STATE_TILED
state will be set whenever any of the individual tiled states is set. On platforms
that lack that support, the tiled state will give an indication of tiledness without
any of the per-edge states being set.
the surface is not shown |
||
the surface is minimized |
||
the surface is maximized |
||
the surface is sticky |
||
the surface is maximized without decorations |
||
the surface is kept above other surfaces |
||
the surface is kept below other surfaces |
||
the surface is presented as focused (with active decorations) |
||
the surface is in a tiled state |
||
whether the top edge is tiled |
||
whether the top edge is resizable |
||
whether the right edge is tiled |
||
whether the right edge is resizable |
||
whether the bottom edge is tiled |
||
whether the bottom edge is resizable |
||
whether the left edge is tiled |
||
whether the left edge is resizable |
A set of bit-flags to indicate the state of modifier keys and mouse buttons in various event types. Typical modifier keys are Shift, Control, Meta, Super, Hyper, Alt, Compose, Apple, CapsLock or ShiftLock.
Like the X Window System, GDK supports 8 modifier keys and 5 mouse buttons.
GDK recognizes which of the Meta, Super or Hyper keys are mapped
to Mod2 - Mod5, and indicates this by setting GDK_SUPER_MASK
,
GDK_HYPER_MASK
or GDK_META_MASK
in the state field of key events.
Note that GDK may add internal values to events which include
reserved values such as GDK_MODIFIER_RESERVED_13_MASK
. Your code
should preserve and ignore them. You can use GDK_MODIFIER_MASK
to
remove all reserved values.
Also note that the GDK X backend interprets button press events for button
4-7 as scroll events, so GDK_BUTTON4_MASK
and GDK_BUTTON5_MASK
will never
be set.
the Shift key. |
||
a Lock key (depending on the modifier mapping of the X server this may either be CapsLock or ShiftLock). |
||
the Control key. |
||
the fourth modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier, but normally it is the Alt key). |
||
the fifth modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier). |
||
the sixth modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier). |
||
the seventh modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier). |
||
the eighth modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier). |
||
the first mouse button. |
||
the second mouse button. |
||
the third mouse button. |
||
the fourth mouse button. |
||
the fifth mouse button. |
||
A reserved bit flag; do not use in your own code |
||
A reserved bit flag; do not use in your own code |
||
A reserved bit flag; do not use in your own code |
||
A reserved bit flag; do not use in your own code |
||
A reserved bit flag; do not use in your own code |
||
A reserved bit flag; do not use in your own code |
||
A reserved bit flag; do not use in your own code |
||
A reserved bit flag; do not use in your own code |
||
A reserved bit flag; do not use in your own code |
||
A reserved bit flag; do not use in your own code |
||
A reserved bit flag; do not use in your own code |
||
A reserved bit flag; do not use in your own code |
||
A reserved bit flag; do not use in your own code |
||
the Super modifier |
||
the Hyper modifier |
||
the Meta modifier |
||
A reserved bit flag; do not use in your own code |
||
A reserved bit flag; do not use in your own code |
||
a mask covering all modifier types. |
This enum is used with gdk_keymap_get_modifier_mask()
in order to determine what modifiers the
currently used windowing system backend uses for particular
purposes. For example, on X11/Windows, the Control key is used for
invoking menu shortcuts (accelerators), whereas on Apple computers
it’s the Command key (which correspond to GDK_CONTROL_MASK
and
GDK_MOD2_MASK
, respectively).
the primary modifier used to invoke menu accelerators. |
||
the modifier used to invoke context menus. Note that mouse button 3 always triggers context menus. When this modifier is not 0, it additionally triggers context menus when used with mouse button 1. |
||
the modifier used to extend selections
using |
||
the modifier used to modify selections, which in most cases means toggling the clicked item into or out of the selection. |
||
when any of these modifiers is pressed, the key event cannot produce a symbol directly. This is meant to be used for input methods, and for use cases like typeahead search. |
||
the modifier that switches between keyboard groups (AltGr on X11/Windows and Option/Alt on OS X). |
||
The set of modifier masks accepted as modifiers in accelerators. Needed because Command is mapped to MOD2 on OSX, which is widely used, but on X11 MOD2 is NumLock and using that for a mod key is problematic at best. Ref: https://bugzilla.gnome.org/show_bug.cgi?id=736125. |
“cursor”
property“cursor” GdkCursor *
The mouse pointer for a GdkSurface. See gdk_surface_set_cursor()
and
gdk_surface_get_cursor()
for details.
Owner: GdkSurface
Flags: Read / Write
“display”
property“display” GdkDisplay *
The GdkDisplay connection of the surface. See gdk_surface_get_display()
for details.
Owner: GdkSurface
Flags: Read / Write / Construct Only
“frame-clock”
property“frame-clock” GdkFrameClock *
Frame Clock.
Owner: GdkSurface
Flags: Read / Write / Construct Only
“event”
signalgboolean user_function (GdkSurface *surface, GdkEvent *event, gpointer user_data)
Emitted when GDK receives an input event for surface
.
surface |
the GdkSurface |
|
event |
an input event |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
“popup-layout-changed”
signalvoid user_function (GdkSurface *surface, gpointer user_data)
Emitted when the layout of a popup surface
has changed, e.g. if the popup
layout was reactive and after the parent moved causing the popover to end
up partially off-screen.
surface |
the GdkSurface that was laid out |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First
“render”
signalgboolean user_function (GdkSurface *surface, CairoRegion *region, gpointer user_data)
Emitted when part of the surface needs to be redrawn.
surface |
the GdkSurface |
|
region |
the region that needs to be redrawn |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
“size-changed”
signalvoid user_function (GdkSurface *surface, gint width, gint height, gpointer user_data)
Emitted when the size of surface
is changed.
surface |
the GdkSurface |
|
width |
the new width |
|
height |
the new height |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First