#[repr(transparent)]pub struct Window { /* private fields */ }
Expand description
Implementations
sourceimpl Window
impl Window
sourcepub fn beep(&self)
pub fn beep(&self)
Emits a short beep associated to self
in the appropriate
display, if supported. Otherwise, emits a short beep on
the display just as Display::beep()
.
sourcepub fn begin_draw_frame(&self, region: &Region) -> Option<DrawingContext>
pub fn begin_draw_frame(&self, region: &Region) -> Option<DrawingContext>
Indicates that you are beginning the process of redrawing region
on self
, and provides you with a DrawingContext
.
If self
is a top level Window
, backed by a native window
implementation, a backing store (offscreen buffer) large enough to
contain region
will be created. The backing store will be initialized
with the background color or background surface for self
. Then, all
drawing operations performed on self
will be diverted to the
backing store. When you call gdk_window_end_frame()
, the contents of
the backing store will be copied to self
, making it visible
on screen. Only the part of self
contained in region
will be
modified; that is, drawing operations are clipped to region
.
The net result of all this is to remove flicker, because the user
sees the finished product appear all at once when you call
end_draw_frame()
. If you draw to self
directly without
calling begin_draw_frame()
, the user may see flicker
as individual drawing operations are performed in sequence.
When using GTK+, the widget system automatically places calls to
begin_draw_frame()
and end_draw_frame()
around
emissions of the GtkWidget::draw
signal. That is, if you’re
drawing the contents of the widget yourself, you can assume that the
widget has a cleared background, is already set as the clip region,
and already has a backing store. Therefore in most cases, application
code in GTK does not need to call begin_draw_frame()
explicitly.
region
a Cairo region
Returns
a DrawingContext
context that should be
used to draw the contents of the window; the returned context is owned
by GDK.
sourcepub fn begin_move_drag(&self, button: i32, root_x: i32, root_y: i32, timestamp: u32)
pub fn begin_move_drag(&self, button: i32, root_x: i32, root_y: i32, timestamp: u32)
Begins a window move operation (for a toplevel window).
This function assumes that the drag is controlled by the
client pointer device, use begin_move_drag_for_device()
to begin a drag with a different device.
button
the button being used to drag, or 0 for a keyboard-initiated drag
root_x
root window X coordinate of mouse click that began the drag
root_y
root window Y coordinate of mouse click that began the drag
timestamp
timestamp of mouse click that began the drag
sourcepub fn begin_move_drag_for_device(
&self,
device: &Device,
button: i32,
root_x: i32,
root_y: i32,
timestamp: u32
)
pub fn begin_move_drag_for_device(
&self,
device: &Device,
button: i32,
root_x: i32,
root_y: i32,
timestamp: u32
)
Begins a window move operation (for a toplevel window). You might use this function to implement a “window move grip,” for example. The function works best with window managers that support the Extended Window Manager Hints but has a fallback implementation for other window managers.
device
the device used for the operation
button
the button being used to drag, or 0 for a keyboard-initiated drag
root_x
root window X coordinate of mouse click that began the drag
root_y
root window Y coordinate of mouse click that began the drag
timestamp
timestamp of mouse click that began the drag
sourcepub fn begin_resize_drag(
&self,
edge: WindowEdge,
button: i32,
root_x: i32,
root_y: i32,
timestamp: u32
)
pub fn begin_resize_drag(
&self,
edge: WindowEdge,
button: i32,
root_x: i32,
root_y: i32,
timestamp: u32
)
Begins a window resize operation (for a toplevel window).
This function assumes that the drag is controlled by the
client pointer device, use begin_resize_drag_for_device()
to begin a drag with a different device.
edge
the edge or corner from which the drag is started
button
the button being used to drag, or 0 for a keyboard-initiated drag
root_x
root window X coordinate of mouse click that began the drag
root_y
root window Y coordinate of mouse click that began the drag
timestamp
timestamp of mouse click that began the drag (use gdk_event_get_time()
)
sourcepub fn begin_resize_drag_for_device(
&self,
edge: WindowEdge,
device: &Device,
button: i32,
root_x: i32,
root_y: i32,
timestamp: u32
)
pub fn begin_resize_drag_for_device(
&self,
edge: WindowEdge,
device: &Device,
button: i32,
root_x: i32,
root_y: i32,
timestamp: u32
)
Begins a window resize operation (for a toplevel window).
You might use this function to implement a “window resize grip,” for
example; in fact GtkStatusbar
uses it. The function works best
with window managers that support the
Extended Window Manager Hints
but has a fallback implementation for other window managers.
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
root_x
root window X coordinate of mouse click that began the drag
root_y
root window Y coordinate of mouse click that began the drag
timestamp
timestamp of mouse click that began the drag (use gdk_event_get_time()
)
sourcepub fn coords_from_parent(&self, parent_x: f64, parent_y: f64) -> (f64, f64)
pub fn coords_from_parent(&self, parent_x: f64, parent_y: f64) -> (f64, f64)
Transforms window coordinates from a parent window to a child
window, where the parent window is the normal parent as returned by
parent()
for normal windows, and the window’s
embedder as returned by gdk_offscreen_window_get_embedder()
for
offscreen windows.
For normal windows, calling this function is equivalent to subtracting
the return values of position()
from the parent coordinates.
For offscreen windows however (which can be arbitrarily transformed),
this function calls the GdkWindow::from-embedder: signal to translate
the coordinates.
You should always use this function when writing generic code that walks down a window hierarchy.
See also: coords_to_parent()
parent_x
X coordinate in parent’s coordinate system
parent_y
Y coordinate in parent’s coordinate system
Returns
x
return location for X coordinate in child’s coordinate system
y
return location for Y coordinate in child’s coordinate system
sourcepub fn coords_to_parent(&self, x: f64, y: f64) -> (f64, f64)
pub fn coords_to_parent(&self, x: f64, y: f64) -> (f64, f64)
Transforms window coordinates from a child window to its parent
window, where the parent window is the normal parent as returned by
parent()
for normal windows, and the window’s
embedder as returned by gdk_offscreen_window_get_embedder()
for
offscreen windows.
For normal windows, calling this function is equivalent to adding
the return values of position()
to the child coordinates.
For offscreen windows however (which can be arbitrarily transformed),
this function calls the GdkWindow::to-embedder: signal to translate
the coordinates.
You should always use this function when writing generic code that walks up a window hierarchy.
See also: coords_from_parent()
x
X coordinate in child’s coordinate system
y
Y coordinate in child’s coordinate system
Returns
parent_x
return location for X coordinate
in parent’s coordinate system, or None
parent_y
return location for Y coordinate
in parent’s coordinate system, or None
sourcepub fn create_gl_context(&self) -> Result<GLContext, Error>
pub fn create_gl_context(&self) -> Result<GLContext, Error>
Creates a new GLContext
matching the
framebuffer format to the visual of the Window
. The context
is disconnected from any particular window or surface.
If the creation of the GLContext
failed, error
will be set.
Before using the returned GLContext
, you will need to
call GLContext::make_current()
or GLContext::realize()
.
Returns
sourcepub fn deiconify(&self)
pub fn deiconify(&self)
Attempt to deiconify (unminimize) self
. On X11 the window manager may
choose to ignore the request to deiconify. When using GTK+,
use gtk_window_deiconify()
instead of the Window
variant. Or better yet,
you probably want to use gtk_window_present_with_time()
, which raises the window, focuses it,
unminimizes it, and puts it on the current desktop.
pub fn destroy(&self)
pub fn destroy_notify(&self)
sourcepub fn end_draw_frame(&self, context: &DrawingContext)
pub fn end_draw_frame(&self, context: &DrawingContext)
Indicates that the drawing of the contents of self
started with
gdk_window_begin_frame()
has been completed.
This function will take care of destroying the DrawingContext
.
It is an error to call this function without a matching
gdk_window_begin_frame()
first.
context
the DrawingContext
created by begin_draw_frame()
sourcepub fn end_paint(&self)
pub fn end_paint(&self)
Indicates that the backing store created by the most recent call
to gdk_window_begin_paint_region()
should be copied onscreen and
deleted, leaving the next-most-recent backing store or no backing
store at all as the active paint region. See
gdk_window_begin_paint_region()
for full details.
It is an error to call this function without a matching
gdk_window_begin_paint_region()
first.
sourcepub fn ensure_native(&self) -> bool
pub fn ensure_native(&self) -> bool
sourcepub fn focus(&self, timestamp: u32)
pub fn focus(&self, timestamp: u32)
Sets keyboard focus to self
. In most cases, gtk_window_present_with_time()
should be used on a GtkWindow
, rather than calling this function.
timestamp
timestamp of the event triggering the window focus
sourcepub fn freeze_updates(&self)
pub fn freeze_updates(&self)
Temporarily freezes a window such that it won’t receive expose
events. The window will begin receiving expose events again when
thaw_updates()
is called. If freeze_updates()
has been called more than once, thaw_updates()
must be called
an equal number of times to begin processing exposes.
sourcepub fn fullscreen(&self)
pub fn fullscreen(&self)
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 self
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.
sourcepub fn fullscreen_on_monitor(&self, monitor: i32)
pub fn fullscreen_on_monitor(&self, monitor: i32)
Moves the window into fullscreen mode on the given monitor. 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.
monitor
Which monitor to display fullscreen on.
sourcepub fn geometry_changed(&self)
pub fn geometry_changed(&self)
This function informs GDK that the geometry of an embedded offscreen window has changed. This is necessary for GDK to keep track of which offscreen window the pointer is in.
sourcepub fn accepts_focus(&self) -> bool
pub fn accepts_focus(&self) -> bool
Determines whether or not the desktop environment shuld be hinted that the window does not want to receive input focus.
Returns
whether or not the window should receive input focus.
sourcepub fn children(&self) -> Vec<Window>
pub fn children(&self) -> Vec<Window>
Gets the list of children of self
known to GDK.
This function only returns children created via GDK,
so for example it’s useless when used with the root window;
it only returns windows an application created itself.
The returned list must be freed, but the elements in the list need not be.
Returns
list of child windows inside self
sourcepub fn clip_region(&self) -> Option<Region>
pub fn clip_region(&self) -> Option<Region>
Computes the region of a window that potentially can be written to by drawing primitives. This region may not take into account other factors such as if the window is obscured by other windows, but no area outside of this region will be affected by drawing primitives.
Returns
a cairo::Region
. This must be freed with cairo_region_destroy()
when you are done.
sourcepub fn cursor(&self) -> Option<Cursor>
pub fn cursor(&self) -> Option<Cursor>
Retrieves a Cursor
pointer for the cursor currently set on the
specified Window
, or None
. If the return value is None
then
there is no custom cursor set on the specified window, and it is
using the cursor for its parent window.
Returns
a Cursor
, or None
. The
returned object is owned by the Window
and should not be
unreferenced directly. Use set_cursor()
to unset the
cursor of the window
sourcepub fn decorations(&self) -> Option<WMDecoration>
pub fn decorations(&self) -> Option<WMDecoration>
Returns the decorations set on the GdkWindow with
set_decorations()
.
Returns
true
if the window has decorations set, false
otherwise.
decorations
The window decorations will be written here
sourcepub fn device_cursor(&self, device: &Device) -> Option<Cursor>
pub fn device_cursor(&self, device: &Device) -> Option<Cursor>
Retrieves a Cursor
pointer for the device
currently set on the
specified Window
, or None
. If the return value is None
then
there is no custom cursor set on the specified window, and it is
using the cursor for its parent window.
device
a master, pointer Device
.
Returns
a Cursor
, or None
. The
returned object is owned by the Window
and should not be
unreferenced directly. Use set_cursor()
to unset the
cursor of the window
sourcepub fn device_events(&self, device: &Device) -> EventMask
pub fn device_events(&self, device: &Device) -> EventMask
sourcepub fn device_position(
&self,
device: &Device
) -> (Option<Window>, i32, i32, ModifierType)
pub fn device_position(
&self,
device: &Device
) -> (Option<Window>, i32, i32, ModifierType)
Obtains the current device position and modifier state.
The position is given in coordinates relative to the upper left
corner of self
.
Use device_position_double()
if you need subpixel precision.
device
pointer Device
to query to.
Returns
The window underneath device
(as with Device::window_at_position()
), or None
if the
window is not known to GDK.
x
return location for the X coordinate of device
, or None
.
y
return location for the Y coordinate of device
, or None
.
mask
return location for the modifier mask, or None
.
sourcepub fn device_position_double(
&self,
device: &Device
) -> (Option<Window>, f64, f64, ModifierType)
pub fn device_position_double(
&self,
device: &Device
) -> (Option<Window>, f64, f64, ModifierType)
Obtains the current device position in doubles and modifier state.
The position is given in coordinates relative to the upper left
corner of self
.
device
pointer Device
to query to.
Returns
The window underneath device
(as with Device::window_at_position()
), or None
if the
window is not known to GDK.
x
return location for the X coordinate of device
, or None
.
y
return location for the Y coordinate of device
, or None
.
mask
return location for the modifier mask, or None
.
sourcepub fn drag_protocol(&self) -> (DragProtocol, Window)
pub fn drag_protocol(&self) -> (DragProtocol, Window)
sourcepub fn effective_parent(&self) -> Option<Window>
pub fn effective_parent(&self) -> Option<Window>
sourcepub fn effective_toplevel(&self) -> Window
pub fn effective_toplevel(&self) -> Window
Gets the toplevel window that’s an ancestor of self
.
Works like toplevel()
, but treats an offscreen window’s
embedder as its parent, using effective_parent()
.
See also: gdk_offscreen_window_get_embedder()
Returns
the effective toplevel window containing self
sourcepub fn does_event_compression(&self) -> bool
pub fn does_event_compression(&self) -> bool
sourcepub fn events(&self) -> EventMask
pub fn events(&self) -> EventMask
Gets the event mask for self
for all master input devices. See
set_events()
.
Returns
event mask for self
sourcepub fn gets_focus_on_map(&self) -> bool
pub fn gets_focus_on_map(&self) -> bool
Determines whether or not the desktop environment should be hinted that the window does not want to receive input focus when it is mapped.
Returns
whether or not the window wants to receive input focus when it is mapped.
sourcepub fn frame_clock(&self) -> Option<FrameClock>
pub fn frame_clock(&self) -> Option<FrameClock>
Gets the frame clock for the window. The frame clock for a window never changes unless the window is reparented to a new toplevel window.
Returns
the frame clock
sourcepub fn frame_extents(&self) -> Rectangle
pub fn frame_extents(&self) -> Rectangle
Obtains the bounding box of the window, including window manager
titlebar/borders if any. The frame position is given in root window
coordinates. To get the position of the window itself (rather than
the frame) in root window coordinates, use origin()
.
Returns
rect
rectangle to fill with bounding box of the window frame
sourcepub fn fullscreen_mode(&self) -> FullscreenMode
pub fn fullscreen_mode(&self) -> FullscreenMode
Obtains the FullscreenMode
of the self
.
Returns
The FullscreenMode
applied to the window when fullscreen.
sourcepub fn geometry(&self) -> (i32, i32, i32, i32)
pub fn geometry(&self) -> (i32, i32, i32, i32)
Any of the return location arguments to this function may be None
,
if you aren’t interested in getting the value of that field.
The X and Y coordinates returned are relative to the parent window
of self
, which for toplevels usually means relative to the
window decorations (titlebar, etc.) rather than relative to the
root window (screen-size background window).
On the X11 platform, the geometry is obtained from the X server,
so reflects the latest position of self
; this may be out-of-sync
with the position of self
delivered in the most-recently-processed
EventConfigure
. position()
in contrast gets the
position from the most recent configure event.
Note: If self
is not a toplevel, it is much better
to call position()
, width()
and
height()
instead, because it avoids the roundtrip to
the X server and because these functions support the full 32-bit
coordinate space, whereas geometry()
is restricted to
the 16-bit coordinates of X11.
Returns
x
return location for X coordinate of window (relative to its parent)
y
return location for Y coordinate of window (relative to its parent)
width
return location for width of window
height
return location for height of window
sourcepub fn height(&self) -> i32
pub fn height(&self) -> i32
Returns the height of the given self
.
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.
Returns
The height of self
sourcepub fn is_modal_hint(&self) -> bool
pub fn is_modal_hint(&self) -> bool
Determines whether or not the window manager is hinted that self
has modal behaviour.
Returns
whether or not the window has the modal hint set.
sourcepub fn origin(&self) -> (i32, i32, i32)
pub fn origin(&self) -> (i32, i32, i32)
Obtains the position of a window in root window coordinates.
(Compare with position()
and
geometry()
which return the position of a window
relative to its parent window.)
Returns
not meaningful, ignore
x
return location for X coordinate
y
return location for Y coordinate
sourcepub fn parent(&self) -> Option<Window>
pub fn parent(&self) -> Option<Window>
Obtains the parent of self
, as known to GDK. Does not query the
X server; thus this returns the parent as passed to new()
,
not the actual parent. This should never matter unless you’re using
Xlib calls mixed with GDK calls on the X11 platform. It may also
matter for toplevel windows, because the window manager may choose
to reparent them.
Note that you should use effective_parent()
when
writing generic code that walks up a window hierarchy, because
parent()
will most likely not do what you expect if
there are offscreen windows in the hierarchy.
Returns
parent of self
sourcepub fn is_pass_through(&self) -> bool
pub fn is_pass_through(&self) -> bool
Returns whether input to the window is passed through to the window below.
See set_pass_through()
for details
sourcepub fn position(&self) -> (i32, i32)
pub fn position(&self) -> (i32, i32)
Obtains the position of the window as reported in the
most-recently-processed EventConfigure
. Contrast with
geometry()
which queries the X server for the
current window position, regardless of which events have been
received or processed.
The position coordinates are relative to the window’s parent window.
Returns
x
X coordinate of window
y
Y coordinate of window
sourcepub fn root_coords(&self, x: i32, y: i32) -> (i32, i32)
pub fn root_coords(&self, x: i32, y: i32) -> (i32, i32)
Obtains the position of a window position in root
window coordinates. This is similar to
origin()
but allows you to pass
in any position in the window, not just the origin.
x
X coordinate in window
y
Y coordinate in window
Returns
root_x
return location for X coordinate
root_y
return location for Y coordinate
sourcepub fn root_origin(&self) -> (i32, i32)
pub fn root_origin(&self) -> (i32, i32)
sourcepub fn scale_factor(&self) -> i32
pub fn scale_factor(&self) -> i32
Returns the internal scale factor that maps from window 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 window may change during runtime, if this happens a configure event will be sent to the toplevel window.
Returns
the scale factor
sourcepub fn source_events(&self, source: InputSource) -> EventMask
pub fn source_events(&self, source: InputSource) -> EventMask
Returns the event mask for self
corresponding to the device class specified
by source
.
source
a InputSource
to define the source class.
Returns
source event mask for self
sourcepub fn state(&self) -> WindowState
pub fn state(&self) -> WindowState
Gets the bitwise OR of the currently active window state flags,
from the WindowState
enumeration.
Returns
window state bitfield
sourcepub fn supports_multidevice(&self) -> bool
pub fn supports_multidevice(&self) -> bool
sourcepub fn toplevel(&self) -> Window
pub fn toplevel(&self) -> Window
Gets the toplevel window that’s an ancestor of self
.
Any window type but WindowType::Child
is considered a
toplevel window, as is a WindowType::Child
window that
has a root window as parent.
Note that you should use effective_toplevel()
when
you want to get to a window’s toplevel as seen on screen, because
toplevel()
will most likely not do what you expect
if there are offscreen windows in the hierarchy.
Returns
the toplevel window containing self
sourcepub fn type_hint(&self) -> WindowTypeHint
pub fn type_hint(&self) -> WindowTypeHint
sourcepub fn update_area(&self) -> Option<Region>
pub fn update_area(&self) -> Option<Region>
Transfers ownership of the update area from self
to the caller
of the function. That is, after calling this function, self
will
no longer have an invalid/dirty region; the update area is removed
from self
and handed to you. If a window has no update area,
update_area()
returns None
. You are responsible for
calling cairo_region_destroy()
on the returned region if it’s non-None
.
Returns
the update area for self
sourcepub fn visible_region(&self) -> Option<Region>
pub fn visible_region(&self) -> Option<Region>
Computes the region of the self
that is potentially visible.
This does not necessarily take into account if the window is
obscured by other windows, but no area outside of this region
is visible.
Returns
a cairo::Region
. This must be freed with cairo_region_destroy()
when you are done.
sourcepub fn width(&self) -> i32
pub fn width(&self) -> i32
Returns the width of the given self
.
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.
Returns
The width of self
sourcepub fn window_type(&self) -> WindowType
pub fn window_type(&self) -> WindowType
sourcepub fn has_native(&self) -> bool
pub fn has_native(&self) -> bool
Checks whether the window has a native window or not. Note that
you can use ensure_native()
if a native window is needed.
Returns
sourcepub fn hide(&self)
pub fn hide(&self)
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()
.
sourcepub fn iconify(&self)
pub fn iconify(&self)
Asks to iconify (minimize) self
. 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 self
is a toplevel window.
sourcepub fn input_shape_combine_region(
&self,
shape_region: &Region,
offset_x: i32,
offset_y: i32
)
pub fn input_shape_combine_region(
&self,
shape_region: &Region,
offset_x: i32,
offset_y: i32
)
Like shape_combine_region()
, but the shape applies
only to event handling. Mouse events which happen while
the pointer position corresponds to an unset bit in the
mask will be passed on the window below self
.
An input shape is typically used with RGBA windows. The alpha channel of the window defines which pixels are invisible and allows for nicely antialiased borders, and the input shape controls where the window 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.
shape_region
region of window to be non-transparent
offset_x
X position of shape_region
in self
coordinates
offset_y
Y position of shape_region
in self
coordinates
sourcepub fn invalidate_maybe_recurse(
&self,
region: &Region,
child_func: Option<&mut dyn FnMut(&Window) -> bool>
)
pub fn invalidate_maybe_recurse(
&self,
region: &Region,
child_func: Option<&mut dyn FnMut(&Window) -> bool>
)
Adds region
to the update area for self
. The update area is the
region that needs to be redrawn, or “dirty region.” The call
gdk_window_process_updates()
sends one or more expose events to the
window, which together cover the entire update area. An
application would normally redraw the contents of self
in
response to those expose events.
GDK will call gdk_window_process_all_updates()
on your behalf
whenever your program returns to the main loop and becomes idle, so
normally there’s no need to do that manually, you just need to
invalidate regions that you know should be redrawn.
The child_func
parameter controls whether the region of
each child window that intersects region
will also be invalidated.
Only children for which child_func
returns true
will have the area
invalidated.
region
child_func
function to use to decide if to
recurse to a child, None
means never recurse.
sourcepub fn invalidate_rect(&self, rect: Option<&Rectangle>, invalidate_children: bool)
pub fn invalidate_rect(&self, rect: Option<&Rectangle>, invalidate_children: bool)
A convenience wrapper around invalidate_region()
which
invalidates a rectangular region. See
invalidate_region()
for details.
rect
rectangle to invalidate or None
to invalidate the whole
window
invalidate_children
whether to also invalidate child windows
sourcepub fn invalidate_region(&self, region: &Region, invalidate_children: bool)
pub fn invalidate_region(&self, region: &Region, invalidate_children: bool)
Adds region
to the update area for self
. The update area is the
region that needs to be redrawn, or “dirty region.” The call
gdk_window_process_updates()
sends one or more expose events to the
window, which together cover the entire update area. An
application would normally redraw the contents of self
in
response to those expose events.
GDK will call gdk_window_process_all_updates()
on your behalf
whenever your program returns to the main loop and becomes idle, so
normally there’s no need to do that manually, you just need to
invalidate regions that you know should be redrawn.
The invalidate_children
parameter controls whether the region of
each child window that intersects region
will also be invalidated.
If false
, then the update area for child windows will remain
unaffected. See gdk_window_invalidate_maybe_recurse if you need
fine grained control over which children are invalidated.
region
invalidate_children
true
to also invalidate child windows
sourcepub fn is_destroyed(&self) -> bool
pub fn is_destroyed(&self) -> bool
sourcepub fn is_input_only(&self) -> bool
pub fn is_input_only(&self) -> bool
sourcepub fn is_viewable(&self) -> bool
pub fn is_viewable(&self) -> bool
sourcepub fn is_visible(&self) -> bool
pub fn is_visible(&self) -> bool
Checks whether the window has been mapped (with show()
or
show_unraised()
).
Returns
true
if the window is mapped
sourcepub fn lower(&self)
pub fn lower(&self)
Lowers self
to the bottom of the Z-order (stacking order), so that
other windows with the same parent window appear above self
.
This is true whether or not the other windows are visible.
If self
is a toplevel, the window manager may choose to deny the
request to move the window in the Z-order, lower()
only
requests the restack, does not guarantee it.
Note that show()
raises the window again, so don’t call this
function before show()
. (Try show_unraised()
.)
sourcepub fn mark_paint_from_clip(&self, cr: &Context)
pub fn mark_paint_from_clip(&self, cr: &Context)
If you call this during a paint (e.g. between gdk_window_begin_paint_region()
and end_paint()
then GDK will mark the current clip region of the
window as being drawn. This is required when mixing GL rendering via
gdk_cairo_draw_from_gl()
and cairo rendering, as otherwise GDK has no way
of knowing when something paints over the GL-drawn regions.
This is typically called automatically by GTK+ and you don’t need to care about this.
cr
sourcepub fn maximize(&self)
pub fn maximize(&self)
Maximizes the window. If the window was already maximized, then this function does nothing.
On X11, asks the window manager to maximize self
, 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.
sourcepub fn merge_child_input_shapes(&self)
pub fn merge_child_input_shapes(&self)
Merges the input shape masks for any child windows into the
input shape mask for self
. i.e. the union of all input masks
for self
and its children will become the new input mask
for self
. See input_shape_combine_region()
.
This function is distinct from set_child_input_shapes()
because it includes self
’s input shape mask in the set of
shapes to be merged.
sourcepub fn merge_child_shapes(&self)
pub fn merge_child_shapes(&self)
Merges the shape masks for any child windows into the
shape mask for self
. i.e. the union of all masks
for self
and its children will become the new mask
for self
. See shape_combine_region()
.
This function is distinct from set_child_shapes()
because it includes self
’s shape mask in the set of shapes to
be merged.
pub fn move_(&self, x: i32, y: i32)
sourcepub fn move_region(&self, region: &Region, dx: i32, dy: i32)
pub fn move_region(&self, region: &Region, dx: i32, dy: i32)
Move the part of self
indicated by region
by dy
pixels in the Y
direction and dx
pixels in the X direction. The portions of region
that not covered by the new position of region
are invalidated.
Child windows are not moved.
region
The cairo::Region
to move
dx
Amount to move in the X direction
dy
Amount to move in the Y direction
sourcepub fn move_resize(&self, x: i32, y: i32, width: i32, height: i32)
pub fn move_resize(&self, x: i32, y: i32, width: i32, height: i32)
Equivalent to calling move_()
and 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 move_resize()
.)
x
new X position relative to window’s parent
y
new Y position relative to window’s parent
width
new width
height
new height
sourcepub fn move_to_rect(
&self,
rect: &Rectangle,
rect_anchor: Gravity,
window_anchor: Gravity,
anchor_hints: AnchorHints,
rect_anchor_dx: i32,
rect_anchor_dy: i32
)
Available on crate feature v3_24
only.
pub fn move_to_rect(
&self,
rect: &Rectangle,
rect_anchor: Gravity,
window_anchor: Gravity,
anchor_hints: AnchorHints,
rect_anchor_dx: i32,
rect_anchor_dy: i32
)
v3_24
only.Moves self
to rect
, aligning their anchor points.
rect
is relative to the top-left corner of the window that self
is
transient for. rect_anchor
and window_anchor
determine anchor points on
rect
and self
to pin together. rect
’s anchor point can optionally be
offset by rect_anchor_dx
and rect_anchor_dy
, which is equivalent to
offsetting the position of self
.
anchor_hints
determines how self
will be moved if the anchor points cause
it to move off-screen. For example, AnchorHints::FLIP_X
will replace
Gravity::NorthWest
with Gravity::NorthEast
and vice versa if
self
extends beyond the left or right edges of the monitor.
Connect to the signal::Window::moved-to-rect
signal to find out how it was
actually positioned.
rect
the destination Rectangle
to align self
with
rect_anchor
the point on rect
to align with self
’s anchor point
window_anchor
the point on self
to align with rect
’s anchor point
anchor_hints
positioning hints to use when limited on space
rect_anchor_dx
horizontal offset to shift self
, i.e. rect
’s anchor
point
rect_anchor_dy
vertical offset to shift self
, i.e. rect
’s anchor point
sourcepub fn peek_children(&self) -> Vec<Window>
pub fn peek_children(&self) -> Vec<Window>
Like children()
, but does not copy the list of
children, so the list does not need to be freed.
Returns
a reference to the list of child windows in self
sourcepub fn raise(&self)
pub fn raise(&self)
Raises self
to the top of the Z-order (stacking order), so that
other windows with the same parent window appear below self
.
This is true whether or not the windows are visible.
If self
is a toplevel, the window manager may choose to deny the
request to move the window in the Z-order, raise()
only
requests the restack, does not guarantee it.
sourcepub fn register_dnd(&self)
pub fn register_dnd(&self)
Registers a window as a potential drop destination.
sourcepub fn reparent(&self, new_parent: &Window, x: i32, y: i32)
pub fn reparent(&self, new_parent: &Window, x: i32, y: i32)
Reparents self
into the given new_parent
. The window being
reparented will be unmapped as a side effect.
new_parent
new parent to move self
into
x
X location inside the new parent
y
Y location inside the new parent
sourcepub fn resize(&self, width: i32, height: i32)
pub fn resize(&self, width: i32, height: i32)
Resizes self
; 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 move_resize()
to both move and resize simultaneously, for a nicer visual effect.
width
new width of the window
height
new height of the window
sourcepub fn restack(&self, sibling: Option<&Window>, above: bool)
pub fn restack(&self, sibling: Option<&Window>, above: bool)
Changes the position of self
in the Z-order (stacking order), so that
it is above sibling
(if above
is true
) or below sibling
(if above
is
false
).
If sibling
is None
, then this either raises (if above
is true
) or
lowers the window.
If self
is a toplevel, the window manager may choose to deny the
request to move the window in the Z-order, restack()
only
requests the restack, does not guarantee it.
sibling
a Window
that is a sibling of self
, or None
above
a boolean
sourcepub fn scroll(&self, dx: i32, dy: i32)
pub fn scroll(&self, dx: i32, dy: i32)
Scroll the contents of self
, both pixels and children, by the
given amount. self
itself does not move. Portions of the window
that the scroll operation brings in from offscreen areas are
invalidated. The invalidated region may be bigger than what would
strictly be necessary.
For X11, a minimum area will be invalidated if the window has no subwindows, or if the edges of the window’s parent do not extend beyond the edges of the window. In other cases, a multi-step process is used to scroll the window which may produce temporary visual artifacts and unnecessary invalidations.
dx
Amount to scroll in the X direction
dy
Amount to scroll in the Y direction
sourcepub fn set_accept_focus(&self, accept_focus: bool)
pub fn set_accept_focus(&self, accept_focus: bool)
Setting accept_focus
to false
hints the desktop environment that the
window doesn’t want to receive input focus.
On X, it is the responsibility of the window manager to interpret this hint. ICCCM-compliant window manager usually respect it.
accept_focus
true
if the window should receive input focus
sourcepub fn set_child_input_shapes(&self)
pub fn set_child_input_shapes(&self)
Sets the input shape mask of self
to the union of input shape masks
for all children of self
, ignoring the input shape mask of self
itself. Contrast with merge_child_input_shapes()
which includes
the input shape mask of self
in the masks to be merged.
sourcepub fn set_child_shapes(&self)
pub fn set_child_shapes(&self)
Sets the shape mask of self
to the union of shape masks
for all children of self
, ignoring the shape mask of self
itself. Contrast with merge_child_shapes()
which includes
the shape mask of self
in the masks to be merged.
sourcepub fn set_cursor(&self, cursor: Option<&Cursor>)
pub fn set_cursor(&self, cursor: Option<&Cursor>)
Sets the default mouse pointer for a Window
.
Note that cursor
must be for the same display as self
.
Use Cursor::for_display()
or Cursor::from_pixbuf()
to
create the cursor. To make the cursor invisible, use CursorType::BlankCursor
.
Passing None
for the cursor
argument to set_cursor()
means
that self
will use the cursor of its parent window. Most windows
should use this default.
cursor
a cursor
sourcepub fn set_decorations(&self, decorations: WMDecoration)
pub fn set_decorations(&self, decorations: WMDecoration)
“Decorations” are the features the window manager adds to a toplevel Window
.
This function sets the traditional Motif window manager hints that tell the
window manager which decorations you would like your window to have.
Usually you should use gtk_window_set_decorated()
on a GtkWindow
instead of
using the GDK function directly.
The decorations
argument is the logical OR of the fields in
the WMDecoration
enumeration. If WMDecoration::ALL
is included in the
mask, the other bits indicate which decorations should be turned off.
If WMDecoration::ALL
is not included, then the other bits indicate
which decorations should be turned on.
Most window managers honor a decorations hint of 0 to disable all decorations, but very few honor all possible combinations of bits.
decorations
decoration hint mask
sourcepub fn set_device_cursor(&self, device: &Device, cursor: &Cursor)
pub fn set_device_cursor(&self, device: &Device, cursor: &Cursor)
Sets a specific Cursor
for a given device when it gets inside self
.
Use Cursor::for_display()
or Cursor::from_pixbuf()
to create
the cursor. To make the cursor invisible, use CursorType::BlankCursor
. Passing
None
for the cursor
argument to set_cursor()
means that
self
will use the cursor of its parent window. Most windows should
use this default.
device
a master, pointer Device
cursor
a Cursor
sourcepub fn set_device_events(&self, device: &Device, event_mask: EventMask)
pub fn set_device_events(&self, device: &Device, event_mask: EventMask)
Sets the event mask for a given device (Normally a floating device, not
attached to any visible pointer) to self
. For example, an event mask
including EventMask::BUTTON_PRESS_MASK
means the window should report button
press events. The event mask is the bitwise OR of values from the
EventMask
enumeration.
See the [input handling overview][event-masks] for details.
device
Device
to enable events for.
event_mask
event mask for self
sourcepub fn set_event_compression(&self, event_compression: bool)
pub fn set_event_compression(&self, event_compression: bool)
Determines whether or not extra unprocessed motion events in
the event queue can be discarded. If true
only the most recent
event will be delivered.
Some types of applications, e.g. paint programs, need to see all motion events and will benefit from turning off event compression.
By default, event compression is enabled.
event_compression
true
if motion events should be compressed
sourcepub fn set_events(&self, event_mask: EventMask)
pub fn set_events(&self, event_mask: EventMask)
The event mask for a window determines which events will be reported
for that window from all master input devices. For example, an event mask
including EventMask::BUTTON_PRESS_MASK
means the window should report button
press events. The event mask is the bitwise OR of values from the
EventMask
enumeration.
See the [input handling overview][event-masks] for details.
event_mask
event mask for self
sourcepub fn set_focus_on_map(&self, focus_on_map: bool)
pub fn set_focus_on_map(&self, focus_on_map: bool)
Setting focus_on_map
to false
hints the desktop environment that the
window doesn’t want to receive input focus when it is mapped.
focus_on_map should be turned off for windows that aren’t triggered
interactively (such as popups from network activity).
On X, it is the responsibility of the window manager to interpret this hint. Window managers following the freedesktop.org window manager extension specification should respect it.
focus_on_map
true
if the window should receive input focus when mapped
sourcepub fn set_fullscreen_mode(&self, mode: FullscreenMode)
pub fn set_fullscreen_mode(&self, mode: FullscreenMode)
Specifies whether the self
should span over all monitors (in a multi-head
setup) or only the current monitor when in fullscreen mode.
The mode
argument is from the FullscreenMode
enumeration.
If FullscreenMode::AllMonitors
is specified, the fullscreen self
will
span over all monitors from the Screen
.
On X11, searches through the list of monitors from the Screen
the ones
which delimit the 4 edges of the entire Screen
and will ask the window
manager to span the self
over these monitors.
If the XINERAMA extension is not available or not usable, this function has no effect.
Not all window managers support this, so you can’t rely on the fullscreen
window to span over the multiple monitors when FullscreenMode::AllMonitors
is specified.
mode
fullscreen mode
sourcepub fn set_functions(&self, functions: WMFunction)
pub fn set_functions(&self, functions: WMFunction)
Sets hints about the window management functions to make available via buttons on the window frame.
On the X backend, this function sets the traditional Motif window manager hint for this purpose. However, few window managers do anything reliable or interesting with this hint. Many ignore it entirely.
The functions
argument is the logical OR of values from the
WMFunction
enumeration. If the bitmask includes WMFunction::ALL
,
then the other bits indicate which functions to disable; if
it doesn’t include WMFunction::ALL
, it indicates which functions to
enable.
functions
bitmask of operations to allow on self
sourcepub fn set_geometry_hints(&self, geometry: &Geometry, geom_mask: WindowHints)
pub fn set_geometry_hints(&self, geometry: &Geometry, geom_mask: WindowHints)
Sets the geometry hints for self
. Hints flagged in geom_mask
are set, hints not flagged in geom_mask
are unset.
To unset all hints, use a geom_mask
of 0 and a geometry
of None
.
This function provides hints to the windowing system about
acceptable sizes for a toplevel window. The purpose of
this is to constrain user resizing, but the windowing system
will typically (but is not required to) also constrain the
current size of the window to the provided values and
constrain programatic resizing via resize()
or
move_resize()
.
Note that on X11, this effect has no effect on windows
of type WindowType::Temp
or windows where override redirect
has been turned on via set_override_redirect()
since these windows are not resizable by the user.
Since you can’t count on the windowing system doing the
constraints for programmatic resizes, you should generally
call constrain_size()
yourself to determine
appropriate sizes.
geometry
geometry hints
geom_mask
bitmask indicating fields of geometry
to pay attention to
sourcepub fn set_group(&self, leader: Option<&Window>)
pub fn set_group(&self, leader: Option<&Window>)
Sets the group leader window for self
. By default,
GDK sets the group leader for all toplevel windows
to a global window implicitly created by GDK. With this function
you can override this default.
The group leader window allows the window manager to distinguish all windows that belong to a single application. It may for example allow users to minimize/unminimize all windows belonging to an application at once. You should only set a non-default group window if your application pretends to be multiple applications.
leader
group leader window, or None
to restore the default group leader window
sourcepub fn set_icon_list(&self, pixbufs: &[Pixbuf])
pub fn set_icon_list(&self, pixbufs: &[Pixbuf])
Sets a list of icons for the window. One of these will be used to represent the window when it has been iconified. The icon is usually shown in an icon box or some sort of task bar. Which icon size is shown depends on the window manager. The window manager can scale the icon but setting several size icons can give better image quality since the window manager may only need to scale the icon by a small amount or not at all.
Note that some platforms don’t support window icons.
pixbufs
A list of pixbufs, of different sizes.
sourcepub fn set_icon_name(&self, name: Option<&str>)
pub fn set_icon_name(&self, name: Option<&str>)
Windows may have a name used while minimized, distinct from the name they display in their titlebar. Most of the time this is a bad idea from a user interface standpoint. But you can set such a name with this function, if you like.
After calling this with a non-None
name
, calls to set_title()
will not update the icon title.
Using None
for name
unsets the icon title; further calls to
set_title()
will again update the icon title as well.
Note that some platforms don’t support window icons.
name
name of window while iconified (minimized)
sourcepub fn set_keep_above(&self, setting: bool)
pub fn set_keep_above(&self, setting: bool)
Set if self
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 self
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.
setting
whether to keep self
above other windows
sourcepub fn set_keep_below(&self, setting: bool)
pub fn set_keep_below(&self, setting: bool)
Set if self
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 self
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.
setting
whether to keep self
below other windows
sourcepub fn set_modal_hint(&self, modal: bool)
pub fn set_modal_hint(&self, modal: bool)
The application can use this hint to tell the window manager that a certain window has modal behaviour. The window manager can use this information to handle modal windows in a special way.
You should only use this on windows for which you have
previously called set_transient_for()
modal
sourcepub fn set_opacity(&self, opacity: f64)
pub fn set_opacity(&self, opacity: f64)
Set self
to render as partially transparent,
with opacity 0 being fully transparent and 1 fully opaque. (Values
of the opacity parameter are clamped to the [0,1] range.)
For toplevel windows this depends on support from the windowing system
that may not always be there. For instance, On X11, this works only on
X screens with a compositing manager running. On Wayland, there is no
per-window opacity value that the compositor would apply. Instead, use
gdk_window_set_opaque_region (window, NULL)
to tell the compositor
that the entire window is (potentially) non-opaque, and draw your content
with alpha, or use gtk_widget_set_opacity()
to set an overall opacity
for your widgets.
For child windows this function only works for non-native windows.
For setting up per-pixel alpha topelevels, see Screen::rgba_visual()
,
and for non-toplevels, see gdk_window_set_composited()
.
Support for non-toplevel windows was added in 3.8.
opacity
opacity
sourcepub fn set_opaque_region(&self, region: Option<&Region>)
pub fn set_opaque_region(&self, region: Option<&Region>)
For optimisation purposes, compositing window managers may like to not draw obscured regions of windows, 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 windows.
GTK+ will update this property automatically if
the self
background is opaque, as we know where the opaque regions
are. If your window background is not opaque, please update this
property in your GtkWidget::style-updated
handler.
region
a region, or None
sourcepub fn set_override_redirect(&self, override_redirect: bool)
pub fn set_override_redirect(&self, override_redirect: bool)
An override redirect window is not under the control of the window manager. This means it won’t have a titlebar, won’t be minimizable, etc. - it will be entirely under the control of the application. The window manager can’t see the override redirect window at all.
Override redirect should only be used for short-lived temporary
windows, such as popup menus. GtkMenu
uses an override redirect
window in its implementation, for example.
override_redirect
true
if window should be override redirect
sourcepub fn set_pass_through(&self, pass_through: bool)
pub fn set_pass_through(&self, pass_through: bool)
Sets whether input to the window is passed through to the window below.
The default value of this is false
, which means that pointer
events that happen inside the window are send first to the window,
but if the event is not selected by the event mask then the event
is sent to the parent window, and so on up the hierarchy.
If pass_through
is true
then such pointer events happen as if the
window wasn’t there at all, and thus will be sent first to any
windows below self
. This is useful if the window is used in a
transparent fashion. In the terminology of the web this would be called
“pointer-events: none”.
Note that a window with pass_through
true
can still have a subwindow
without pass through, so you can get events on a subset of a window. And in
that cases you would get the in-between related events such as the pointer
enter/leave events on its way to the destination window.
pass_through
a boolean
sourcepub fn set_role(&self, role: &str)
pub fn set_role(&self, role: &str)
When using GTK+, typically you should use gtk_window_set_role()
instead
of this low-level function.
The window manager and session manager use a window’s role to distinguish it from other kinds of window in the same application. When an application is restarted after being saved in a previous session, all windows with the same title and role are treated as interchangeable. So if you have two windows with the same title that should be distinguished for session management purposes, you should set the role on those windows. It doesn’t matter what string you use for the role, as long as you have a different role for each non-interchangeable kind of window.
role
a string indicating its role
sourcepub fn set_shadow_width(&self, left: i32, right: i32, top: i32, bottom: i32)
pub fn set_shadow_width(&self, left: i32, right: i32, top: i32, bottom: i32)
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 windows.
left
The left extent
right
The right extent
top
The top extent
bottom
The bottom extent
sourcepub fn set_skip_pager_hint(&self, skips_pager: bool)
pub fn set_skip_pager_hint(&self, skips_pager: bool)
Toggles whether a window should appear in a pager (workspace
switcher, or other desktop utility program that displays a small
thumbnail representation of the windows on the desktop). If a
window’s semantic type as specified with set_type_hint()
already fully describes the window, this function should
not be called in addition, instead you should
allow the window to be treated according to standard policy for
its semantic type.
skips_pager
true
to skip the pager
sourcepub fn set_skip_taskbar_hint(&self, skips_taskbar: bool)
pub fn set_skip_taskbar_hint(&self, skips_taskbar: bool)
Toggles whether a window should appear in a task list or window
list. If a window’s semantic type as specified with
set_type_hint()
already fully describes the window, this
function should not be called in addition,
instead you should allow the window to be treated according to
standard policy for its semantic type.
skips_taskbar
true
to skip the taskbar
sourcepub fn set_source_events(&self, source: InputSource, event_mask: EventMask)
pub fn set_source_events(&self, source: InputSource, event_mask: EventMask)
Sets the event mask for any floating device (i.e. not attached to any
visible pointer) that has the source defined as source
. This event
mask will be applied both to currently existing, newly added devices
after this call, and devices being attached/detached.
source
a InputSource
to define the source class.
event_mask
event mask for self
sourcepub fn set_startup_id(&self, startup_id: &str)
pub fn set_startup_id(&self, startup_id: &str)
When using GTK+, typically you should use gtk_window_set_startup_id()
instead of this low-level function.
startup_id
a string with startup-notification identifier
sourcepub fn set_support_multidevice(&self, support_multidevice: bool)
pub fn set_support_multidevice(&self, support_multidevice: bool)
This function will enable multidevice features in self
.
Multidevice aware windows will need to handle properly multiple, per device enter/leave events, device grabs and grab ownerships.
support_multidevice
true
to enable multidevice support in self
.
sourcepub fn set_title(&self, title: &str)
pub fn set_title(&self, title: &str)
Sets the title of a toplevel window, to be displayed in the titlebar.
If you haven’t explicitly set the icon name for the window
(using set_icon_name()
), the icon name will be set to
title
as well. title
must be in UTF-8 encoding (as with all
user-readable strings in GDK/GTK+). title
may not be None
.
title
title of self
sourcepub fn set_transient_for(&self, parent: &Window)
pub fn set_transient_for(&self, parent: &Window)
Indicates to the window manager that self
is a transient dialog
associated with the application window parent
. This allows the
window manager to do things like center self
on parent
and
keep self
above parent
.
See gtk_window_set_transient_for()
if you’re using GtkWindow
or
GtkDialog
.
parent
another toplevel Window
sourcepub fn set_type_hint(&self, hint: WindowTypeHint)
pub fn set_type_hint(&self, hint: WindowTypeHint)
The application can use this call to provide a hint to the window manager about the functionality of a window. The window manager can use this information when determining the decoration and behaviour of the window.
The hint must be set before the window is mapped.
hint
A hint of the function this window will have
sourcepub fn set_urgency_hint(&self, urgent: bool)
pub fn set_urgency_hint(&self, urgent: bool)
sourcepub fn shape_combine_region(
&self,
shape_region: Option<&Region>,
offset_x: i32,
offset_y: i32
)
pub fn shape_combine_region(
&self,
shape_region: Option<&Region>,
offset_x: i32,
offset_y: i32
)
Makes pixels in self
outside shape_region
be transparent,
so that the window may be nonrectangular.
If shape_region
is None
, the shape will be unset, so the whole
window will be opaque again. offset_x
and offset_y
are ignored
if shape_region
is None
.
On the X11 platform, this uses an X server extension which is widely available on most common platforms, but not available on very old X servers, and occasionally the implementation will be buggy. On servers without the shape extension, this function will do nothing.
This function works on both toplevel and child windows.
shape_region
region of window to be non-transparent
offset_x
X position of shape_region
in self
coordinates
offset_y
Y position of shape_region
in self
coordinates
sourcepub fn show(&self)
pub fn show(&self)
Like 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 hide()
.
When implementing a GtkWidget
, you should call this function on the widget’s
Window
as part of the “map” method.
sourcepub fn show_unraised(&self)
pub fn show_unraised(&self)
Shows a Window
onscreen, but does not modify its stacking
order. In contrast, 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).
Asks the windowing system to show the window menu. The window menu is the menu shown when right-clicking the titlebar on traditional windows managed by the window manager. This is useful for windows using client-side decorations, activating it with a right-click on the window decorations.
event
a GdkEvent
to show the menu for
Returns
sourcepub fn stick(&self)
pub fn stick(&self)
“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.
sourcepub fn thaw_updates(&self)
pub fn thaw_updates(&self)
Thaws a window frozen with freeze_updates()
.
sourcepub fn unfullscreen(&self)
pub fn unfullscreen(&self)
Moves the window out of fullscreen mode. If the window was not fullscreen, does nothing.
On X11, asks the window manager to move self
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.
sourcepub fn unmaximize(&self)
pub fn unmaximize(&self)
Unmaximizes the window. If the window wasn’t maximized, then this function does nothing.
On X11, asks the window manager to unmaximize self
, 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.
sourcepub fn withdraw(&self)
pub fn withdraw(&self)
Withdraws a window (unmaps it and asks the window manager to forget about it).
This function is not really useful as hide()
automatically
withdraws toplevel windows before hiding them.
sourcepub fn constrain_size(
geometry: &mut Geometry,
flags: WindowHints,
width: i32,
height: i32
) -> (i32, i32)
pub fn constrain_size(
geometry: &mut Geometry,
flags: WindowHints,
width: i32,
height: i32
) -> (i32, i32)
Constrains a desired width and height according to a set of geometry hints (such as minimum and maximum size).
geometry
a Geometry
structure
flags
a mask indicating what portions of geometry
are set
width
desired width of window
height
desired height of the window
Returns
new_width
location to store resulting width
new_height
location to store resulting height
sourcepub fn connect_create_surface<F: Fn(&Self, i32, i32) -> Surface + 'static>(
&self,
f: F
) -> SignalHandlerId
pub fn connect_create_surface<F: Fn(&Self, i32, i32) -> Surface + 'static>(
&self,
f: F
) -> SignalHandlerId
The ::create-surface signal is emitted when an offscreen window
needs its surface (re)created, which happens either when the
window is first drawn to, or when the window is being
resized. The first signal handler that returns a non-None
surface will stop any further signal emission, and its surface
will be used.
Note that it is not possible to access the window’s previous
surface from within any callback of this signal. Calling
gdk_offscreen_window_get_surface()
will lead to a crash.
width
the width of the offscreen surface to create
height
the height of the offscreen surface to create
Returns
the newly created cairo::Surface
for the offscreen window
sourcepub fn connect_pick_embedded_child<F: Fn(&Self, f64, f64) -> Option<Window> + 'static>(
&self,
f: F
) -> SignalHandlerId
pub fn connect_pick_embedded_child<F: Fn(&Self, f64, f64) -> Option<Window> + 'static>(
&self,
f: F
) -> SignalHandlerId
pub fn connect_cursor_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
sourceimpl Window
impl Window
sourcepub fn new(parent: Option<&Window>, attributes: &WindowAttr) -> Window
pub fn new(parent: Option<&Window>, attributes: &WindowAttr) -> Window
Creates a new Window
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 Window
, or None
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 Window
sourcepub fn create_similar_surface(
&self,
content: Content,
width: i32,
height: i32
) -> Option<Surface>
pub fn create_similar_surface(
&self,
content: Content,
width: i32,
height: i32
) -> Option<Surface>
Create a new surface that is as compatible as possible with the
given self
. For example the new surface will have the same
fallback resolution and font options as self
. Generally, the new
surface will also use the same backend as self
, unless that is
not possible for some reason. The type of the returned surface may
be examined with cairo_surface_get_type()
.
Initially the surface contents are all 0 (transparent if contents have transparency, black otherwise.)
content
the content for the new surface
width
width of the new surface
height
height of the new surface
Returns
a pointer to the newly allocated surface. The caller
owns the surface and should call cairo_surface_destroy()
when done
with it.
This function always returns a valid pointer, but it will return a
pointer to a “nil” surface if other
is already in an error state
or any other error occurs.
sourcepub fn create_similar_image_surface(
&self,
format: Format,
width: i32,
height: i32,
scale: i32
) -> Option<Surface>
pub fn create_similar_image_surface(
&self,
format: Format,
width: i32,
height: i32,
scale: i32
) -> Option<Surface>
Create a new image surface that is efficient to draw on the
given self
.
Initially the surface contents are all 0 (transparent if contents have transparency, black otherwise.)
The width
and height
of the new surface are not affected by
the scaling factor of the self
, or by the scale
argument; they
are the size of the surface in device pixels. If you wish to create
an image surface capable of holding the contents of self
you can
use:
⚠️ The following code is in C ⚠️
int scale = gdk_window_get_scale_factor (window);
int width = gdk_window_get_width (window) * scale;
int height = gdk_window_get_height (window) * scale;
// format is set elsewhere
cairo_surface_t *surface =
gdk_window_create_similar_image_surface (window,
format,
width, height,
scale);
Note that unlike cairo_surface_create_similar_image()
, the new
surface’s device scale is set to scale
, or to the scale factor of
self
if scale
is 0.
format
the format for the new surface
width
width of the new surface
height
height of the new surface
scale
the scale of the new surface, or 0 to use same as self
Returns
a pointer to the newly allocated surface. The caller
owns the surface and should call cairo_surface_destroy()
when done
with it.
This function always returns a valid pointer, but it will return a
pointer to a “nil” surface if other
is already in an error state
or any other error occurs.
Trait Implementations
sourceimpl Ord for Window
impl Ord for Window
1.21.0 · sourceconst fn max(self, other: Self) -> Self
const fn max(self, other: Self) -> Self
1.21.0 · sourceconst fn min(self, other: Self) -> Self
const fn min(self, other: Self) -> Self
1.50.0 · sourceconst fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
const fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
sourceimpl ParentClassIs for Window
impl ParentClassIs for Window
sourceimpl<OT: ObjectType> PartialOrd<OT> for Window
impl<OT: ObjectType> PartialOrd<OT> for Window
sourcefn partial_cmp(&self, other: &OT) -> Option<Ordering>
fn partial_cmp(&self, other: &OT) -> Option<Ordering>
1.0.0 · sourceconst fn le(&self, other: &Rhs) -> bool
const fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresourceimpl StaticType for Window
impl StaticType for Window
sourcefn static_type() -> Type
fn static_type() -> Type
Self
.impl Eq for Window
Auto Trait Implementations
impl RefUnwindSafe for Window
impl !Send for Window
impl !Sync for Window
impl Unpin for Window
impl UnwindSafe for Window
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T> Cast for Twhere
T: ObjectType,
impl<T> Cast for Twhere
T: ObjectType,
sourcefn upcast<T>(self) -> Twhere
T: ObjectType,
Self: IsA<T>,
fn upcast<T>(self) -> Twhere
T: ObjectType,
Self: IsA<T>,
T
. Read moresourcefn upcast_ref<T>(&self) -> &Twhere
T: ObjectType,
Self: IsA<T>,
fn upcast_ref<T>(&self) -> &Twhere
T: ObjectType,
Self: IsA<T>,
T
. Read moresourcefn downcast<T>(self) -> Result<T, Self>where
T: ObjectType,
Self: CanDowncast<T>,
fn downcast<T>(self) -> Result<T, Self>where
T: ObjectType,
Self: CanDowncast<T>,
T
. Read moresourcefn downcast_ref<T>(&self) -> Option<&T>where
T: ObjectType,
Self: CanDowncast<T>,
fn downcast_ref<T>(&self) -> Option<&T>where
T: ObjectType,
Self: CanDowncast<T>,
T
. Read moresourcefn dynamic_cast<T>(self) -> Result<T, Self>where
T: ObjectType,
fn dynamic_cast<T>(self) -> Result<T, Self>where
T: ObjectType,
T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read moresourcefn dynamic_cast_ref<T>(&self) -> Option<&T>where
T: ObjectType,
fn dynamic_cast_ref<T>(&self) -> Option<&T>where
T: ObjectType,
T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read moresourceunsafe fn unsafe_cast<T>(self) -> Twhere
T: ObjectType,
unsafe fn unsafe_cast<T>(self) -> Twhere
T: ObjectType,
T
unconditionally. Read moresourceunsafe fn unsafe_cast_ref<T>(&self) -> &Twhere
T: ObjectType,
unsafe fn unsafe_cast_ref<T>(&self) -> &Twhere
T: ObjectType,
&T
unconditionally. Read moresourceimpl<U> IsSubclassableExt for Uwhere
U: IsClass + ParentClassIs,
impl<U> IsSubclassableExt for Uwhere
U: IsClass + ParentClassIs,
fn parent_class_init<T>(class: &mut Class<U>)where
T: ObjectSubclass,
<U as ParentClassIs>::Parent: IsSubclassable<T>,
fn parent_instance_init<T>(instance: &mut InitializingObject<T>)where
T: ObjectSubclass,
<U as ParentClassIs>::Parent: IsSubclassable<T>,
sourceimpl<T> ObjectExt for Twhere
T: ObjectType,
impl<T> ObjectExt for Twhere
T: ObjectType,
sourcefn is<U>(&self) -> boolwhere
U: StaticType,
fn is<U>(&self) -> boolwhere
U: StaticType,
true
if the object is an instance of (can be cast to) T
.sourcefn object_class(&self) -> &Class<Object>
fn object_class(&self) -> &Class<Object>
ObjectClass
of the object. Read moresourcefn class_of<U>(&self) -> Option<&Class<U>>where
U: IsClass,
fn class_of<U>(&self) -> Option<&Class<U>>where
U: IsClass,
T
. Read moresourcefn interface<U>(&self) -> Option<InterfaceRef<'_, U>>where
U: IsInterface,
fn interface<U>(&self) -> Option<InterfaceRef<'_, U>>where
U: IsInterface,
T
of the object. Read moresourcefn set_property<V>(&self, property_name: &str, value: V)where
V: ToValue,
fn set_property<V>(&self, property_name: &str, value: V)where
V: ToValue,
sourcefn set_property_from_value(&self, property_name: &str, value: &Value)
fn set_property_from_value(&self, property_name: &str, value: &Value)
sourcefn set_properties(&self, property_values: &[(&str, &dyn ToValue)])
fn set_properties(&self, property_values: &[(&str, &dyn ToValue)])
sourcefn set_properties_from_value(&self, property_values: &[(&str, Value)])
fn set_properties_from_value(&self, property_values: &[(&str, Value)])
sourcefn property<V>(&self, property_name: &str) -> Vwhere
V: 'static + for<'b> FromValue<'b>,
fn property<V>(&self, property_name: &str) -> Vwhere
V: 'static + for<'b> FromValue<'b>,
property_name
of the object and cast it to the type V. Read moresourcefn property_value(&self, property_name: &str) -> Value
fn property_value(&self, property_name: &str) -> Value
property_name
of the object. Read moresourcefn property_type(&self, property_name: &str) -> Option<Type>
fn property_type(&self, property_name: &str) -> Option<Type>
property_name
of this object. Read moresourcefn find_property(&self, property_name: &str) -> Option<ParamSpec>
fn find_property(&self, property_name: &str) -> Option<ParamSpec>
ParamSpec
of the property property_name
of this object.sourcefn list_properties(&self) -> PtrSlice<ParamSpec>
fn list_properties(&self) -> PtrSlice<ParamSpec>
ParamSpec
of the properties of this object.sourcefn freeze_notify(&self) -> PropertyNotificationFreezeGuard
fn freeze_notify(&self) -> PropertyNotificationFreezeGuard
sourceunsafe fn set_qdata<QD>(&self, key: Quark, value: QD)where
QD: 'static,
unsafe fn set_qdata<QD>(&self, key: Quark, value: QD)where
QD: 'static,
key
. Read moresourceunsafe fn qdata<QD>(&self, key: Quark) -> Option<NonNull<QD>>where
QD: 'static,
unsafe fn qdata<QD>(&self, key: Quark) -> Option<NonNull<QD>>where
QD: 'static,
key
. Read moresourceunsafe fn steal_qdata<QD>(&self, key: Quark) -> Option<QD>where
QD: 'static,
unsafe fn steal_qdata<QD>(&self, key: Quark) -> Option<QD>where
QD: 'static,
key
. Read moresourceunsafe fn set_data<QD>(&self, key: &str, value: QD)where
QD: 'static,
unsafe fn set_data<QD>(&self, key: &str, value: QD)where
QD: 'static,
key
. Read moresourceunsafe fn data<QD>(&self, key: &str) -> Option<NonNull<QD>>where
QD: 'static,
unsafe fn data<QD>(&self, key: &str) -> Option<NonNull<QD>>where
QD: 'static,
key
. Read moresourceunsafe fn steal_data<QD>(&self, key: &str) -> Option<QD>where
QD: 'static,
unsafe fn steal_data<QD>(&self, key: &str) -> Option<QD>where
QD: 'static,
key
. Read moresourcefn block_signal(&self, handler_id: &SignalHandlerId)
fn block_signal(&self, handler_id: &SignalHandlerId)
sourcefn unblock_signal(&self, handler_id: &SignalHandlerId)
fn unblock_signal(&self, handler_id: &SignalHandlerId)
sourcefn stop_signal_emission(&self, signal_id: SignalId, detail: Option<Quark>)
fn stop_signal_emission(&self, signal_id: SignalId, detail: Option<Quark>)
sourcefn stop_signal_emission_by_name(&self, signal_name: &str)
fn stop_signal_emission_by_name(&self, signal_name: &str)
sourcefn connect<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value> + Send + Sync,
fn connect<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value> + Send + Sync,
signal_name
on this object. Read moresourcefn connect_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value> + Send + Sync,
fn connect_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value> + Send + Sync,
signal_id
on this object. Read moresourcefn connect_local<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value>,
fn connect_local<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value>,
signal_name
on this object. Read moresourcefn connect_local_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value>,
fn connect_local_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value>,
signal_id
on this object. Read moresourceunsafe fn connect_unsafe<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value>,
unsafe fn connect_unsafe<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value>,
signal_name
on this object. Read moresourceunsafe fn connect_unsafe_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value>,
unsafe fn connect_unsafe_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value>,
signal_id
on this object. Read moresourcefn connect_closure(
&self,
signal_name: &str,
after: bool,
closure: RustClosure
) -> SignalHandlerId
fn connect_closure(
&self,
signal_name: &str,
after: bool,
closure: RustClosure
) -> SignalHandlerId
signal_name
on this object. Read moresourcefn connect_closure_id(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
closure: RustClosure
) -> SignalHandlerId
fn connect_closure_id(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
closure: RustClosure
) -> SignalHandlerId
signal_id
on this object. Read moresourcefn watch_closure(&self, closure: &impl AsRef<Closure>)
fn watch_closure(&self, closure: &impl AsRef<Closure>)
closure
to the lifetime of the object. When
the object’s reference count drops to zero, the closure will be
invalidated. An invalidated closure will ignore any calls to
invoke_with_values
, or
invoke
when using Rust closures. Read moresourcefn emit<R>(&self, signal_id: SignalId, args: &[&dyn ToValue]) -> Rwhere
R: TryFromClosureReturnValue,
fn emit<R>(&self, signal_id: SignalId, args: &[&dyn ToValue]) -> Rwhere
R: TryFromClosureReturnValue,
sourcefn emit_with_values(&self, signal_id: SignalId, args: &[Value]) -> Option<Value>
fn emit_with_values(&self, signal_id: SignalId, args: &[Value]) -> Option<Value>
Self::emit
but takes Value
for the arguments.sourcefn emit_by_name<R>(&self, signal_name: &str, args: &[&dyn ToValue]) -> Rwhere
R: TryFromClosureReturnValue,
fn emit_by_name<R>(&self, signal_name: &str, args: &[&dyn ToValue]) -> Rwhere
R: TryFromClosureReturnValue,
sourcefn emit_by_name_with_values(
&self,
signal_name: &str,
args: &[Value]
) -> Option<Value>
fn emit_by_name_with_values(
&self,
signal_name: &str,
args: &[Value]
) -> Option<Value>
sourcefn emit_by_name_with_details<R>(
&self,
signal_name: &str,
details: Quark,
args: &[&dyn ToValue]
) -> Rwhere
R: TryFromClosureReturnValue,
fn emit_by_name_with_details<R>(
&self,
signal_name: &str,
details: Quark,
args: &[&dyn ToValue]
) -> Rwhere
R: TryFromClosureReturnValue,
sourcefn emit_by_name_with_details_and_values(
&self,
signal_name: &str,
details: Quark,
args: &[Value]
) -> Option<Value>
fn emit_by_name_with_details_and_values(
&self,
signal_name: &str,
details: Quark,
args: &[Value]
) -> Option<Value>
sourcefn emit_with_details<R>(
&self,
signal_id: SignalId,
details: Quark,
args: &[&dyn ToValue]
) -> Rwhere
R: TryFromClosureReturnValue,
fn emit_with_details<R>(
&self,
signal_id: SignalId,
details: Quark,
args: &[&dyn ToValue]
) -> Rwhere
R: TryFromClosureReturnValue,
sourcefn emit_with_details_and_values(
&self,
signal_id: SignalId,
details: Quark,
args: &[Value]
) -> Option<Value>
fn emit_with_details_and_values(
&self,
signal_id: SignalId,
details: Quark,
args: &[Value]
) -> Option<Value>
sourcefn disconnect(&self, handler_id: SignalHandlerId)
fn disconnect(&self, handler_id: SignalHandlerId)
sourcefn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerIdwhere
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerIdwhere
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
notify
signal of the object. Read moresourcefn connect_notify_local<F>(&self, name: Option<&str>, f: F) -> SignalHandlerIdwhere
F: 'static + Fn(&T, &ParamSpec),
fn connect_notify_local<F>(&self, name: Option<&str>, f: F) -> SignalHandlerIdwhere
F: 'static + Fn(&T, &ParamSpec),
notify
signal of the object. Read moresourceunsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerIdwhere
F: Fn(&T, &ParamSpec),
unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerIdwhere
F: Fn(&T, &ParamSpec),
notify
signal of the object. Read more