Compare commits

...

54 Commits

Author SHA1 Message Date
Matthias Clasen
c3ccb68da8 Rename gdk_surface_input_shape_combine_region
There is no shape combining going on anymore, so
call this just gdk_surface_set_input_region, and
remove the offset arguments too. All callers pass
0 anyway.

Update all callers.
2020-03-01 11:32:24 -08:00
Matthias Clasen
7f0c0cc52d surface: Drop more toplevel api
The wm decorations and functions have been moved to
GdkToplevelLayout.
2020-03-01 11:32:24 -08:00
Matthias Clasen
40d2e8cfdf docs: Stop using gdk_surface_get_decorations 2020-03-01 11:32:24 -08:00
Matthias Clasen
92030880d4 testgtk: Stop using gdk_surface_set_decorations 2020-03-01 11:32:24 -08:00
Matthias Clasen
e6ee71e220 window: Stop using gdk_surface_set_decorations
And gdk_surface_set_functions. Instead, use the
toplevel layout functionality.
2020-03-01 11:32:24 -08:00
Matthias Clasen
423d4f4a8a surface: Use toplevel functions and decorations 2020-03-01 11:20:21 -08:00
Matthias Clasen
3079789719 Add wm functions and decorations to GdkToplevelLayout 2020-03-01 11:19:57 -08:00
Matthias Clasen
7e611569e3 window: Use toplevel api to show window menu 2020-03-01 11:04:58 -08:00
Matthias Clasen
ab103da680 surface: Implement new toplevel api 2020-03-01 11:03:50 -08:00
Matthias Clasen
f22310e8a9 toplevel: Add more api 2020-03-01 11:03:42 -08:00
Matthias Clasen
0bd98d13c3 surface: Drop more toplevel api 2020-03-01 10:44:12 -08:00
Matthias Clasen
60c39d7c03 window: Stop using gdk_surface_minimize etc 2020-03-01 10:43:55 -08:00
Matthias Clasen
6c974d5e54 surface: Implement new toplevel layout features 2020-03-01 10:29:10 -08:00
Matthias Clasen
2101f13694 Add more things to GdkToplevelLayout 2020-03-01 10:24:35 -08:00
Matthias Clasen
eed360200a surface: Drop fullscreen api
The fullscreen mode api is still kept internally, since
it is used in the x11 backend. This needs some more untangling.
2020-03-01 10:14:08 -08:00
Matthias Clasen
dc365f9c4c tests: Stop using gdk_surface_fullscreen 2020-03-01 10:10:39 -08:00
Matthias Clasen
71ec829c95 surface: Drop more toplevel api 2020-03-01 12:42:56 -05:00
Matthias Clasen
59e5e0180f window: Use GdkToplevel for more things 2020-03-01 12:42:56 -05:00
Matthias Clasen
157ebf42cd testgtk: Stop using gdk_surface_set_icon_name
Its not useful api, and will disappear.
2020-03-01 12:42:56 -05:00
Matthias Clasen
bdfc6a0812 wayland: Stop using gdk_surface_set_title
Directly call the backend function for this, and for
gdk_surface_set_transient_for.
2020-03-01 12:42:56 -05:00
Matthias Clasen
9b20973f12 x11: Stop using gdk_surface_set_title 2020-03-01 12:42:56 -05:00
Matthias Clasen
8aba6f43e3 surface: Implement more toplevel interface 2020-03-01 12:42:56 -05:00
Matthias Clasen
a537ddc841 toplevel: Move more toplevel api over 2020-03-01 12:42:56 -05:00
Matthias Clasen
b6658358f4 Drop gdk_surface_get_state
You can now use gdk_toplevel_get_state instead.
2020-03-01 12:42:56 -05:00
Matthias Clasen
f9aaace60b testgtk: Stop using gdk_surface_get_state 2020-03-01 12:42:56 -05:00
Matthias Clasen
78435e4628 demo: stop using gdk_surface_get_state 2020-03-01 12:37:22 -05:00
Matthias Clasen
e4856e27a4 a11y: Stop using gdk_surface_get_state 2020-03-01 12:37:22 -05:00
Matthias Clasen
7d96a5272c x11: Stop using gdk_surface_get_state
All the surfaces we are dealing with here are toplevels.
2020-03-01 12:37:22 -05:00
Matthias Clasen
2e30389a9a gtk: use toplevel state getter 2020-03-01 12:37:22 -05:00
Matthias Clasen
2bb1021df0 surface: implement toplevel state getter 2020-02-29 20:31:45 -05:00
Matthias Clasen
457ae1154d toplevel: add state getter 2020-02-29 20:31:31 -05:00
Matthias Clasen
6259735758 Drop more redundant api 2020-02-29 13:33:43 -05:00
Matthias Clasen
134f3fb0de Drop redundant toplevel api
The toplevel functionality to keep is moving to
GdkToplevel, and unused functions can go.
2020-02-29 13:33:43 -05:00
Matthias Clasen
c3b91572ff window: Use GdkToplevel 2020-02-29 13:33:43 -05:00
Matthias Clasen
c82877d777 surface: Implement GdkToplevel
This is not quite right, and only temporary, since
it makes GDK_IS_TOPLEVEL (surface) true for every surface.

Eventually, the implementation will be moved to the
backends.
2020-02-29 13:33:43 -05:00
Matthias Clasen
3546efdf0f Introduce GdkToplevel
This is a new interface for toplevel surfaces.
2020-02-29 13:33:43 -05:00
Matthias Clasen
c9e39f6a82 Introduce GdkToplevelLayout
This will be used in a new GdkTopleve interface in
the near future.
2020-02-29 13:33:43 -05:00
Matthias Clasen
ab3f08bad9 x11: Stop using gdk_surface_maximize
Just use the backend function directly.
2020-02-29 13:33:43 -05:00
Matthias Clasen
33b0413cee x11: Stop using gdk_surface_set_geometry_hints
Just use the backend function directly.
2020-02-29 13:33:43 -05:00
Matthias Clasen
da6498b2e8 wayland: Stop using gdk_surface_set_geometry_hints
Just use the backend function directly.
2020-02-29 13:33:43 -05:00
Matthias Clasen
a353254ad4 inspector: Stop raising and lowering windows
We should always be composited, so this should not
matter in practice.
2020-02-29 13:33:43 -05:00
Matthias Clasen
77f891037e x11: Stop using gdk_surface_raise
Avoid a vfunc roundtrip and just use the backend
implementation directly.
2020-02-29 13:33:43 -05:00
Matthias Clasen
090ce0ad3b broadway: Stop using gdk_surface_raise
We don't implement this anyway. Add a shortcut
to the backend function in case we ever do.
2020-02-29 13:33:43 -05:00
Matthias Clasen
903840e507 x11: Stop abusing type hints for dnd
Nothing in GDK depends on this being set, so just
don't do it.
2020-02-29 13:33:43 -05:00
Matthias Clasen
97f8e9fea0 wayland: Stop abusing type hints
Instead of misusing window type hints, introduce
a private flag for drag surfaces.
2020-02-29 13:33:43 -05:00
Matthias Clasen
85bd0d601d surface: Drop redundant popup api
Now that we have the GdkPopup interface,
these functions are no longer needed.
2020-02-29 13:33:43 -05:00
Matthias Clasen
fef15aec4e tooltip: Use GdkPopup 2020-02-29 13:33:43 -05:00
Matthias Clasen
bb74a85e1b popover: Use GdkPopup 2020-02-29 13:33:43 -05:00
Matthias Clasen
fb34e9146a surface: Implement GdkPopup
This is not quite right, and only temporary, since
it makes GDK_IS_POPUP (surface) true for every surface.

Eventually, the implementation will be moved to the
backends.
2020-02-29 13:33:43 -05:00
Matthias Clasen
25d19298c9 Introduce GdkPopup
This is a new interface for popup surfaces.
2020-02-29 13:33:43 -05:00
Matthias Clasen
726a3abc14 Move GdkSurface autocleanup declaration
We need this available after including gdksurface.h.
2020-02-29 13:33:43 -05:00
Matthias Clasen
0b73150a5b wayland: Stop calling frontend surface api
This is an unnecessary vfunc roundtrip, and the
frontend api is going away shortly.
2020-02-29 11:37:00 -05:00
Matthias Clasen
bc6d403a9a Simplify surface move/drag api
Drop the with_device variants, and always pass a device.
2020-02-29 11:37:00 -05:00
Matthias Clasen
1d39481c1c Drop gtk_window_begin_move/resize_drag
These are just simple wrappers around GdkSurface
api, and we don't need them.
2020-02-29 11:37:00 -05:00
35 changed files with 1743 additions and 1343 deletions

View File

@@ -477,7 +477,7 @@ surface_state_changed (GtkWidget *widget)
DemoApplicationWindow *window = (DemoApplicationWindow *)widget;
GdkSurfaceState new_state;
new_state = gdk_surface_get_state (gtk_native_get_surface (GTK_NATIVE (widget)));
new_state = gdk_toplevel_get_state (GDK_TOPLEVEL (gtk_native_get_surface (GTK_NATIVE (widget))));
window->maximized = (new_state & GDK_SURFACE_STATE_MAXIMIZED) != 0;
window->fullscreen = (new_state & GDK_SURFACE_STATE_FULLSCREEN) != 0;
}

View File

@@ -213,12 +213,8 @@ static guint shot_id;
static gboolean
window_is_csd (GdkSurface *window)
{
gboolean set;
GdkWMDecoration decorations = 0;
/* FIXME: is this accurate? */
set = gdk_surface_get_decorations (window, &decorations);
return (set && (decorations == 0));
return TRUE;
}
static gboolean

View File

@@ -486,10 +486,15 @@ gdk_broadway_surface_layout_popup (GdkSurface *surface,
}
}
static void
gdk_broadway_surface_raise (GdkSurface *surface)
{
}
static void
show_popup (GdkSurface *surface)
{
gdk_surface_raise (surface);
gdk_broadway_surface_raise (surface);
gdk_synthesize_surface_state (surface, GDK_SURFACE_STATE_WITHDRAWN, 0);
_gdk_surface_update_viewable (surface);
gdk_broadway_surface_show (surface, FALSE);
@@ -532,11 +537,6 @@ gdk_broadway_surface_present_popup (GdkSurface *surface,
return GDK_SURFACE_IS_MAPPED (surface);
}
static void
gdk_broadway_surface_raise (GdkSurface *surface)
{
}
static void
gdk_broadway_surface_restack_toplevel (GdkSurface *surface,
GdkSurface *sibling,

View File

@@ -37,7 +37,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkMonitor, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkSeat, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkPopupLayout, gdk_popup_layout_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkVulkanContext, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkSurface, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkContentFormats, gdk_content_formats_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkEvent, g_object_unref)

View File

@@ -68,6 +68,8 @@
#include <gdk/gdktypes.h>
#include <gdk/gdkvulkancontext.h>
#include <gdk/gdksurface.h>
#include <gdk/gdkpopup.h>
#include <gdk/gdktoplevel.h>
#include <gdk/gdk-autocleanup.h>

View File

@@ -282,6 +282,12 @@ void gdk_seat_ungrab (GdkSeat *seat);
GdkSurface * gdk_surface_new_temp (GdkDisplay *display,
const GdkRectangle *position);
void gdk_surface_set_fullscreen_mode (GdkSurface *surface,
GdkFullscreenMode mode);
GdkFullscreenMode gdk_surface_get_fullscreen_mode (GdkSurface *surface);
G_END_DECLS
#endif /* __GDK_INTERNALS_H__ */

214
gdk/gdkpopup.c Normal file
View File

@@ -0,0 +1,214 @@
/*
* Copyright © 2020 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen <mclasen@redhat.com>
*/
#include "config.h"
#include "gdkpopupprivate.h"
/**
* SECTION:gdkpopup
* @Short_description: Interface for popup surfaces
* @Title: Popups
*
* A #GdkPopup is a surface that is attached to another surface,
* and is positioned relative to it.
*/
/* FIXME: this can't have GdkSurface as a prerequisite
* as long as GdkSurface implements this interface itself
*/
G_DEFINE_INTERFACE (GdkPopup, gdk_popup, G_TYPE_OBJECT)
static gboolean
gdk_popup_default_present (GdkPopup *popup,
int width,
int height,
GdkPopupLayout *layout)
{
return FALSE;
}
static GdkGravity
gdk_popup_default_get_surface_anchor (GdkPopup *popup)
{
return GDK_GRAVITY_STATIC;
}
static GdkGravity
gdk_popup_default_get_rect_anchor (GdkPopup *popup)
{
return GDK_GRAVITY_STATIC;
}
static GdkSurface *
gdk_popup_default_get_parent (GdkPopup *popup)
{
return NULL;
}
static void
gdk_popup_default_get_position (GdkPopup *popup,
int *x,
int *y)
{
*x = 0;
*y = 0;
}
static gboolean
gdk_popup_default_get_autohide (GdkPopup *popup)
{
return FALSE;
}
static void
gdk_popup_default_init (GdkPopupInterface *iface)
{
iface->present = gdk_popup_default_present;
iface->get_surface_anchor = gdk_popup_default_get_surface_anchor;
iface->get_rect_anchor = gdk_popup_default_get_rect_anchor;
iface->get_parent = gdk_popup_default_get_parent;
iface->get_position = gdk_popup_default_get_position;
iface->get_autohide = gdk_popup_default_get_autohide;
}
/**
* gdk_popup_present:
* @popup: the #GdkPopup to show
* @width: the unconstrained popup width to layout
* @height: the unconstrained popup height to layout
* @layout: the #GdkPopupLayout object used to layout
*
* Present @popup after having processed the #GdkPopupLayout rules.
* If the popup was previously now showing, it will be showed,
* otherwise it will change position according to @layout.
*
* After calling this function, the result of the layout can be queried
* using gdk_popup_get_position(), gdk_surface_get_width(),
* gdk_surface_get_height(), gdk_popup_get_rect_anchor() and
* gdk_popup_get_surface_anchor().
*
* Presenting may have fail, for example if it was immediately
* hidden if the @popup was set to autohide.
*
* Returns: %FALSE if it failed to be presented, otherwise %TRUE.
*/
gboolean
gdk_popup_present (GdkPopup *popup,
int width,
int height,
GdkPopupLayout *layout)
{
g_return_val_if_fail (GDK_IS_POPUP (popup), FALSE);
g_return_val_if_fail (width > 0, FALSE);
g_return_val_if_fail (height > 0, FALSE);
g_return_val_if_fail (layout != NULL, FALSE);
return GDK_POPUP_GET_IFACE (popup)->present (popup, width, height, layout);
}
/**
* gdk_popup_get_surface_anchor:
* @popup: a #GdkPopup
*
* Gets the current popup surface anchor.
*
* The value returned may change after calling gdk_popup_present(),
* or after the "popup-layout-changed" is emitted.
*
* Returns: the current surface anchor value of @popup
*/
GdkGravity
gdk_popup_get_surface_anchor (GdkPopup *popup)
{
g_return_val_if_fail (GDK_IS_POPUP (popup), GDK_GRAVITY_STATIC);
return GDK_POPUP_GET_IFACE (popup)->get_surface_anchor (popup);
}
/**
* gdk_popup_get_rect_anchor:
* @popup: a #GdkPopup
*
* Gets the current popup rectangle anchor.
*
* The value returned may change after calling gdk_popup_present(),
* or after the "popup-layout-changed" is emitted.
*
* Returns: the current rectangle anchor value of @popup
*/
GdkGravity
gdk_popup_get_rect_anchor (GdkPopup *popup)
{
g_return_val_if_fail (GDK_IS_POPUP (popup), GDK_GRAVITY_STATIC);
return GDK_POPUP_GET_IFACE (popup)->get_rect_anchor (popup);
}
/**
* gdk_popup_get_parent:
* @popup: a #GdkPopup
*
* Returns the parent surface of a popup.
*
* Returns: (transfer none): the parent @popup
*/
GdkSurface *
gdk_popup_get_parent (GdkPopup *popup)
{
g_return_val_if_fail (GDK_IS_POPUP (popup), NULL);
return GDK_POPUP_GET_IFACE (popup)->get_parent (popup);
}
/**
* gdk_popup_get_position:
* @popup: a #GdkPopup
* @x: (out): X coordinate of popup
* @y: (out): Y coordinate of popup
*
* Obtains the position of the popup relative to its parent.
*/
void
gdk_popup_get_position (GdkPopup *popup,
int *x,
int *y)
{
g_return_if_fail (GDK_IS_POPUP (popup));
GDK_POPUP_GET_IFACE (popup)->get_position (popup, x, y);
}
/**
* gdk_popup_get_autohide:
* @popup: a #GdkPopup
*
* Returns whether this popup is set to hide on outside clicks.
*
* Returns: %TRUE if @popup will autohide
*/
gboolean
gdk_popup_get_autohide (GdkPopup *popup)
{
g_return_val_if_fail (GDK_IS_POPUP (popup), FALSE);
return GDK_POPUP_GET_IFACE (popup)->get_autohide (popup);
}

62
gdk/gdkpopup.h Normal file
View File

@@ -0,0 +1,62 @@
/*
* Copyright © 2020 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen <mclasen@redhat.com>
*/
#ifndef __GDK_POPUP_H__
#define __GDK_POPUP_H__
#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gdk/gdk.h> can be included directly."
#endif
#include <gdk/gdksurface.h>
#include <gdk/gdkpopuplayout.h>
G_BEGIN_DECLS
#define GDK_TYPE_POPUP (gdk_popup_get_type ())
GDK_AVAILABLE_IN_ALL
G_DECLARE_INTERFACE (GdkPopup, gdk_popup, GDK, POPUP, GObject)
GDK_AVAILABLE_IN_ALL
gboolean gdk_popup_present (GdkPopup *popup,
int width,
int height,
GdkPopupLayout *layout);
GDK_AVAILABLE_IN_ALL
GdkGravity gdk_popup_get_surface_anchor (GdkPopup *popup);
GDK_AVAILABLE_IN_ALL
GdkGravity gdk_popup_get_rect_anchor (GdkPopup *popup);
GDK_AVAILABLE_IN_ALL
GdkSurface * gdk_popup_get_parent (GdkPopup *popup);
GDK_AVAILABLE_IN_ALL
void gdk_popup_get_position (GdkPopup *popup,
int *x,
int *y);
GDK_AVAILABLE_IN_ALL
gboolean gdk_popup_get_autohide (GdkPopup *popup);
G_END_DECLS
#endif /* __GDK_POPUP_H__ */

29
gdk/gdkpopupprivate.h Normal file
View File

@@ -0,0 +1,29 @@
#ifndef __GDK_POPUP_PRIVATE_H__
#define __GDK_POPUP_PRIVATE_H__
#include "gdkpopup.h"
G_BEGIN_DECLS
struct _GdkPopupInterface
{
GTypeInterface g_iface;
gboolean (* present) (GdkPopup *popup,
int width,
int height,
GdkPopupLayout *layout);
GdkGravity (* get_surface_anchor) (GdkPopup *popup);
GdkGravity (* get_rect_anchor) (GdkPopup *popup);
GdkSurface * (* get_parent) (GdkPopup *popup);
void (* get_position) (GdkPopup *popup,
int *x,
int *y);
gboolean (* get_autohide) (GdkPopup *popup);
};
G_END_DECLS
#endif /* __GDK_POPUP_PRIVATE_H__ */

File diff suppressed because it is too large Load Diff

View File

@@ -350,9 +350,6 @@ GdkSurfaceType gdk_surface_get_surface_type (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
gboolean gdk_surface_is_destroyed (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
GdkSurface * gdk_surface_get_parent (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
GdkDisplay * gdk_surface_get_display (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
@@ -360,29 +357,10 @@ void gdk_surface_show (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_hide (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_show_unraised (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_resize (GdkSurface *surface,
gint width,
gint height);
GDK_AVAILABLE_IN_ALL
gboolean gdk_surface_present_popup (GdkSurface *surface,
int width,
int height,
GdkPopupLayout *layout);
GDK_AVAILABLE_IN_ALL
GdkGravity gdk_surface_get_popup_surface_anchor (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
GdkGravity gdk_surface_get_popup_rect_anchor (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_raise (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_lower (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_restack (GdkSurface *surface,
GdkSurface *sibling,
gboolean above);
GDK_AVAILABLE_IN_ALL
void gdk_surface_focus (GdkSurface *surface,
guint32 timestamp);
@@ -398,10 +376,8 @@ void gdk_surface_set_focus_on_map (GdkSurface *surface,
gboolean focus_on_map);
GDK_AVAILABLE_IN_ALL
void gdk_surface_input_shape_combine_region (GdkSurface *surface,
const cairo_region_t *shape_region,
gint offset_x,
gint offset_y);
void gdk_surface_set_input_region (GdkSurface *surface,
cairo_region_t *region);
GDK_AVAILABLE_IN_ALL
gboolean gdk_surface_is_viewable (GdkSurface *surface);
@@ -409,39 +385,6 @@ gboolean gdk_surface_is_viewable (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
gboolean gdk_surface_get_mapped (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
gboolean gdk_surface_get_autohide (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
GdkSurfaceState gdk_surface_get_state (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_type_hint (GdkSurface *surface,
GdkSurfaceTypeHint hint);
GDK_AVAILABLE_IN_ALL
GdkSurfaceTypeHint gdk_surface_get_type_hint (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
gboolean gdk_surface_get_modal_hint (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_modal_hint (GdkSurface *surface,
gboolean modal);
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_geometry_hints (GdkSurface *surface,
const GdkGeometry *geometry,
GdkSurfaceHints geom_mask);
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_title (GdkSurface *surface,
const gchar *title);
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_startup_id (GdkSurface *surface,
const gchar *startup_id);
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_transient_for (GdkSurface *surface,
GdkSurface *parent);
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_cursor (GdkSurface *surface,
GdkCursor *cursor);
@@ -459,10 +402,6 @@ int gdk_surface_get_width (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
int gdk_surface_get_height (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_get_position (GdkSurface *surface,
gint *x,
gint *y);
GDK_AVAILABLE_IN_ALL
gboolean gdk_surface_translate_coordinates (GdkSurface *from,
GdkSurface *to,
double *x,
@@ -477,21 +416,6 @@ void gdk_surface_get_device_position (GdkSurface *surface,
double *x,
double *y,
GdkModifierType *mask);
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_icon_list (GdkSurface *surface,
GList *surfaces);
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_icon_name (GdkSurface *surface,
const gchar *name);
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_decorations (GdkSurface *surface,
GdkWMDecoration decorations);
GDK_AVAILABLE_IN_ALL
gboolean gdk_surface_get_decorations (GdkSurface *surface,
GdkWMDecoration *decorations);
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_functions (GdkSurface *surface,
GdkWMFunction functions);
GDK_AVAILABLE_IN_ALL
cairo_surface_t *
@@ -503,63 +427,20 @@ cairo_surface_t *
GDK_AVAILABLE_IN_ALL
void gdk_surface_beep (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_minimize (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_unminimize (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_stick (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_unstick (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_maximize (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_unmaximize (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_fullscreen (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_fullscreen_on_monitor (GdkSurface *surface,
GdkMonitor *monitor);
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_fullscreen_mode (GdkSurface *surface,
GdkFullscreenMode mode);
GDK_AVAILABLE_IN_ALL
GdkFullscreenMode
gdk_surface_get_fullscreen_mode (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_unfullscreen (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_keep_above (GdkSurface *surface,
gboolean setting);
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_keep_below (GdkSurface *surface,
gboolean setting);
GDK_AVAILABLE_IN_ALL
void gdk_surface_set_opacity (GdkSurface *surface,
gdouble opacity);
GDK_AVAILABLE_IN_ALL
void gdk_surface_begin_resize_drag (GdkSurface *surface,
GdkSurfaceEdge edge,
gint button,
gint x,
gint y,
guint32 timestamp);
GDK_AVAILABLE_IN_ALL
void gdk_surface_begin_resize_drag_for_device (GdkSurface *surface,
GdkSurfaceEdge edge,
GdkDevice *device,
gint button,
gint x,
gint y,
guint32 timestamp);
GDK_AVAILABLE_IN_ALL
void gdk_surface_begin_move_drag (GdkSurface *surface,
gint button,
gint x,
gint y,
guint32 timestamp);
GDK_AVAILABLE_IN_ALL
void gdk_surface_begin_move_drag_for_device (GdkSurface *surface,
GdkDevice *device,
gint button,
gint x,
@@ -601,9 +482,6 @@ void gdk_surface_set_shadow_width (GdkSurface *surface,
gint right,
gint top,
gint bottom);
GDK_AVAILABLE_IN_ALL
gboolean gdk_surface_show_window_menu (GdkSurface *surface,
GdkEvent *event);
GDK_AVAILABLE_IN_ALL
GdkCairoContext *gdk_surface_create_cairo_context(GdkSurface *surface);
@@ -615,6 +493,8 @@ GdkVulkanContext *
gdk_surface_create_vulkan_context(GdkSurface *surface,
GError **error);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkSurface, g_object_unref)
G_END_DECLS
#endif /* __GDK_SURFACE_H__ */

237
gdk/gdktoplevel.c Normal file
View File

@@ -0,0 +1,237 @@
/*
* Copyright © 2020 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen <mclasen@redhat.com>
*/
#include "config.h"
#include "gdktoplevelprivate.h"
/**
* SECTION:gdktoplevel
* @Short_description: Interface for toplevel surfaces
* @Title: Toplevels
*
* A #GdkToplevel is a freestanding toplevel surface.
*/
/* FIXME: this can't have GdkSurface as a prerequisite
* as long as GdkSurface implements this interface itself
*/
G_DEFINE_INTERFACE (GdkToplevel, gdk_toplevel, G_TYPE_OBJECT)
static gboolean
gdk_toplevel_default_present (GdkToplevel *toplevel,
int width,
int height,
GdkToplevelLayout *layout)
{
return FALSE;
}
static GdkSurfaceState
gdk_toplevel_default_get_state (GdkToplevel *toplevel)
{
return 0;
}
static void
gdk_toplevel_default_set_title (GdkToplevel *toplevel,
const char *title)
{
}
static void
gdk_toplevel_default_set_startup_id (GdkToplevel *toplevel,
const char *startup_id)
{
}
static void
gdk_toplevel_default_set_transient_for (GdkToplevel *toplevel,
GdkSurface *parent)
{
}
static void
gdk_toplevel_default_set_icon_list (GdkToplevel *toplevel,
GList *surfaces)
{
}
static gboolean
gdk_toplevel_default_show_window_menu (GdkToplevel *toplevel,
GdkEvent *event)
{
return FALSE;
}
static void
gdk_toplevel_default_init (GdkToplevelInterface *iface)
{
iface->present = gdk_toplevel_default_present;
iface->get_state = gdk_toplevel_default_get_state;
iface->set_title = gdk_toplevel_default_set_title;
iface->set_startup_id = gdk_toplevel_default_set_startup_id;
iface->set_transient_for = gdk_toplevel_default_set_transient_for;
iface->set_icon_list = gdk_toplevel_default_set_icon_list;
iface->show_window_menu = gdk_toplevel_default_show_window_menu;
}
/**
* gdk_toplevel_present:
* @toplevel: the #GdkToplevel to show
* @width: the unconstrained toplevel width to layout
* @height: the unconstrained toplevel height to layout
* @layout: the #GdkToplevelLayout object used to layout
*
* Present @toplevel after having processed the #GdkToplevelLayout rules.
* If the toplevel was previously now showing, it will be showed,
* otherwise it will change layout according to @layout.
*
* Presenting may fail.
*
* Returns: %FALSE if @toplevel failed to be presented, otherwise %TRUE.
*/
gboolean
gdk_toplevel_present (GdkToplevel *toplevel,
int width,
int height,
GdkToplevelLayout *layout)
{
g_return_val_if_fail (GDK_IS_TOPLEVEL (toplevel), FALSE);
g_return_val_if_fail (width > 0, FALSE);
g_return_val_if_fail (height > 0, FALSE);
g_return_val_if_fail (layout != NULL, FALSE);
return GDK_TOPLEVEL_GET_IFACE (toplevel)->present (toplevel, width, height, layout);
}
GdkSurfaceState
gdk_toplevel_get_state (GdkToplevel *toplevel)
{
g_return_val_if_fail (GDK_IS_TOPLEVEL (toplevel), 0);
return GDK_TOPLEVEL_GET_IFACE (toplevel)->get_state (toplevel);
}
/**
* gdk_toplevel_set_title:
* @toplevel: a #GdkToplevel
* @title: title of @surface
*
* Sets the title of a toplevel surface, to be displayed in the titlebar,
* in lists of windows, etc.
*/
void
gdk_toplevel_set_title (GdkToplevel *toplevel,
const char *title)
{
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
GDK_TOPLEVEL_GET_IFACE (toplevel)->set_title (toplevel, title);
}
/**
* gdk_toplevel_set_startup_id:
* @toplevel: a #GdkToplevel
* @startup_id: a string with startup-notification identifier
*
* When using GTK, typically you should use gtk_window_set_startup_id()
* instead of this low-level function.
*/
void
gdk_toplevel_set_startup_id (GdkToplevel *toplevel,
const char *startup_id)
{
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
GDK_TOPLEVEL_GET_IFACE (toplevel)->set_startup_id (toplevel, startup_id);
}
/**
* gdk_toplevel_set_transient_for:
* @toplevel: a #GdkToplevel
* @parent: another toplevel #GdkSurface
*
* Indicates to the window manager that @surface is a transient dialog
* associated with the application surface @parent. This allows the
* window manager to do things like center @surface on @parent and
* keep @surface above @parent.
*
* See gtk_window_set_transient_for() if youre using #GtkWindow or
* #GtkDialog.
*/
void
gdk_toplevel_set_transient_for (GdkToplevel *toplevel,
GdkSurface *parent)
{
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
GDK_TOPLEVEL_GET_IFACE (toplevel)->set_transient_for (toplevel, parent);
}
/**
* gdk_toplevel_set_icon_list:
* @toplevel: a #GdkToplevel
* @surfaces: (transfer none) (element-type GdkTexture):
* A list of textures to use as icon, of different sizes
*
* Sets a list of icons for the surface.
*
* One of these will be used to represent the surface in iconic form.
* The icon may be shown in window lists or task bars. 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.
*
* Note that some platforms don't support surface icons.
*/
void
gdk_toplevel_set_icon_list (GdkToplevel *toplevel,
GList *surfaces)
{
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
GDK_TOPLEVEL_GET_IFACE (toplevel)->set_icon_list (toplevel, surfaces);
}
/**
* gdk_toplevel_show_window_menu:
* @toplevel: a #GdkToplevel
* @event: a #GdkEvent to show the menu for
*
* 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.
*
* Returns: %TRUE if the window menu was shown and %FALSE otherwise.
*/
gboolean
gdk_toplevel_show_window_menu (GdkToplevel *toplevel,
GdkEvent *event)
{
g_return_val_if_fail (GDK_IS_TOPLEVEL (toplevel), FALSE);
return GDK_TOPLEVEL_GET_IFACE (toplevel)->show_window_menu (toplevel, event);
}

70
gdk/gdktoplevel.h Normal file
View File

@@ -0,0 +1,70 @@
/*
* Copyright © 2020 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen <mclasen@redhat.com>
*/
#ifndef __GDK_TOPLEVEL_H__
#define __GDK_TOPLEVEL_H__
#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gdk/gdk.h> can be included directly."
#endif
#include <gdk/gdksurface.h>
#include <gdk/gdktoplevellayout.h>
G_BEGIN_DECLS
#define GDK_TYPE_TOPLEVEL (gdk_toplevel_get_type ())
GDK_AVAILABLE_IN_ALL
G_DECLARE_INTERFACE (GdkToplevel, gdk_toplevel, GDK, TOPLEVEL, GObject)
GDK_AVAILABLE_IN_ALL
gboolean gdk_toplevel_present (GdkToplevel *toplevel,
int width,
int height,
GdkToplevelLayout *layout);
GDK_AVAILABLE_IN_ALL
GdkSurfaceState gdk_toplevel_get_state (GdkToplevel *toplevel);
GDK_AVAILABLE_IN_ALL
void gdk_toplevel_set_title (GdkToplevel *toplevel,
const char *title);
GDK_AVAILABLE_IN_ALL
void gdk_toplevel_set_startup_id (GdkToplevel *toplevel,
const char *startup_id);
GDK_AVAILABLE_IN_ALL
void gdk_toplevel_set_transient_for (GdkToplevel *toplevel,
GdkSurface *parent);
GDK_AVAILABLE_IN_ALL
void gdk_toplevel_set_icon_list (GdkToplevel *toplevel,
GList *surfaces);
GDK_AVAILABLE_IN_ALL
gboolean gdk_toplevel_show_window_menu (GdkToplevel *toplevel,
GdkEvent *event);
G_END_DECLS
#endif /* __GDK_TOPLEVEL_H__ */

360
gdk/gdktoplevellayout.c Normal file
View File

@@ -0,0 +1,360 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2020 Red Hat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include "gdktoplevellayout.h"
#include "gdkmonitor.h"
struct _GdkToplevelLayout
{
/* < private >*/
grefcount ref_count;
int min_width;
int min_height;
int max_width;
int max_height;
guint maximized : 1;
guint minimized : 1;
guint fullscreen : 1;
guint modal : 1;
guint raise : 1;
guint lower : 1;
guint stick : 1;
guint keep_above : 1;
guint keep_below : 1;
GdkMonitor *fullscreen_monitor;
GdkSurfaceTypeHint type_hint;
GdkWMDecoration decorations;
GdkWMFunction functions;
};
G_DEFINE_BOXED_TYPE (GdkToplevelLayout, gdk_toplevel_layout,
gdk_toplevel_layout_ref,
gdk_toplevel_layout_unref)
/**
* gdk_toplevel_layout_new: (constructor)
*
* Create a toplevel layout description. Used together with
* gdk_surface_present_toplevel() to describe how a toplevel surface
* should be placed and behave on-screen.
*
* Returns: (transfer full): newly created instance of #GdkToplevelLayout
*/
GdkToplevelLayout *
gdk_toplevel_layout_new (int min_width,
int min_height,
int max_width,
int max_height)
{
GdkToplevelLayout *layout;
layout = g_new0 (GdkToplevelLayout, 1);
g_ref_count_init (&layout->ref_count);
layout->min_width = min_width;
layout->min_height = min_height;
layout->max_width = max_width;
layout->max_height = max_height;
layout->type_hint = GDK_SURFACE_TYPE_HINT_NORMAL;
layout->maximized = FALSE;
layout->fullscreen = FALSE;
layout->fullscreen_monitor = NULL;
layout->raise = TRUE;
layout->lower = FALSE;
return layout;
}
/**
* gdk_toplevel_layout_ref:
* @layout: a #GdkToplevelLayout
*
* Increases the reference count of @layout.
*
* Returns: the same @layout
*/
GdkToplevelLayout *
gdk_toplevel_layout_ref (GdkToplevelLayout *layout)
{
g_ref_count_inc (&layout->ref_count);
return layout;
}
/**
* gdk_toplevel_layout_unref:
* @layout: a #GdkToplevelLayout
*
* Decreases the reference count of @layout.
*/
void
gdk_toplevel_layout_unref (GdkToplevelLayout *layout)
{
if (g_ref_count_dec (&layout->ref_count))
{
g_clear_object (&layout->fullscreen_monitor);
g_free (layout);
}
}
/**
* gdk_toplevel_layout_copy:
* @layout: a #GdkToplevelLayout
*
* Create a new #GdkToplevelLayout and copy the contents of @layout into it.
*
* Returns: (transfer full): a copy of @layout.
*/
GdkToplevelLayout *
gdk_toplevel_layout_copy (GdkToplevelLayout *layout)
{
GdkToplevelLayout *new_layout;
new_layout = g_new0 (GdkToplevelLayout, 1);
g_ref_count_init (&new_layout->ref_count);
new_layout->min_width = layout->min_width;
new_layout->min_height = layout->min_height;
new_layout->max_width = layout->max_width;
new_layout->max_height = layout->max_height;
new_layout->maximized = layout->maximized;
new_layout->fullscreen = layout->fullscreen;
if (layout->fullscreen_monitor)
new_layout->fullscreen_monitor = g_object_ref (layout->fullscreen_monitor);
new_layout->raise = layout->raise;
new_layout->lower = layout->lower;
return new_layout;
}
/**
* gdk_toplevel_layout_equal:
* @layout: a #GdkToplevelLayout
* @other: another #GdkToplevelLayout
*
* Check whether @layout and @other has identical layout properties.
*
* Returns: %TRUE if @layout and @other have identical layout properties,
* otherwise %FALSE.
*/
gboolean
gdk_toplevel_layout_equal (GdkToplevelLayout *layout,
GdkToplevelLayout *other)
{
g_return_val_if_fail (layout, FALSE);
g_return_val_if_fail (other, FALSE);
return layout->min_width == other->min_width &&
layout->min_height == other->min_height &&
layout->max_width == other->max_width &&
layout->max_height == other->max_height &&
layout->maximized == other->maximized &&
layout->fullscreen == other->fullscreen &&
layout->fullscreen_monitor == other->fullscreen_monitor;
}
void
gdk_toplevel_layout_get_min_size (GdkToplevelLayout *layout,
int *width,
int *height)
{
*width = layout->min_width;
*height = layout->min_height;
}
void
gdk_toplevel_layout_get_max_size (GdkToplevelLayout *layout,
int *width,
int *height)
{
*width = layout->max_width;
*height = layout->max_height;
}
void
gdk_toplevel_layout_set_maximized (GdkToplevelLayout *layout,
gboolean maximized)
{
layout->maximized = maximized;
}
gboolean
gdk_toplevel_layout_get_maximized (GdkToplevelLayout *layout)
{
return layout->maximized;
}
void
gdk_toplevel_layout_set_fullscreen (GdkToplevelLayout *layout,
gboolean fullscreen,
GdkMonitor *monitor)
{
layout->fullscreen = fullscreen;
if (monitor)
layout->fullscreen_monitor = g_object_ref (monitor);
}
gboolean
gdk_toplevel_layout_get_fullscreen (GdkToplevelLayout *layout)
{
return layout->fullscreen;
}
GdkMonitor *
gdk_toplevel_layout_get_fullscreen_monitor (GdkToplevelLayout *layout)
{
return layout->fullscreen_monitor;
}
void
gdk_toplevel_layout_set_modal (GdkToplevelLayout *layout,
gboolean modal)
{
layout->modal = modal;
}
gboolean
gdk_toplevel_layout_get_modal (GdkToplevelLayout *layout)
{
return layout->modal;
}
void
gdk_toplevel_layout_set_type_hint (GdkToplevelLayout *layout,
GdkSurfaceTypeHint type_hint)
{
layout->type_hint = type_hint;
}
GdkSurfaceTypeHint
gdk_toplevel_layout_get_type_hint (GdkToplevelLayout *layout)
{
return layout->type_hint;
}
void
gdk_toplevel_layout_set_raise (GdkToplevelLayout *layout,
gboolean raise)
{
layout->raise = raise;
}
gboolean
gdk_toplevel_layout_get_raise (GdkToplevelLayout *layout)
{
return layout->raise;
}
void
gdk_toplevel_layout_set_lower (GdkToplevelLayout *layout,
gboolean lower)
{
layout->lower = lower;
}
gboolean
gdk_toplevel_layout_get_lower (GdkToplevelLayout *layout)
{
return layout->lower;
}
void
gdk_toplevel_layout_set_minimized (GdkToplevelLayout *layout,
gboolean minimized)
{
layout->minimized = minimized;
}
gboolean
gdk_toplevel_layout_get_minimized (GdkToplevelLayout *layout)
{
return layout->minimized;
}
void
gdk_toplevel_layout_set_stick (GdkToplevelLayout *layout,
gboolean stick)
{
layout->stick = stick;
}
gboolean
gdk_toplevel_layout_get_stick (GdkToplevelLayout *layout)
{
return layout->stick;
}
void
gdk_toplevel_layout_set_keep_above (GdkToplevelLayout *layout,
gboolean keep_above)
{
layout->keep_above = keep_above;
}
gboolean
gdk_toplevel_layout_get_keep_above (GdkToplevelLayout *layout)
{
return layout->keep_above;
}
void
gdk_toplevel_layout_set_keep_below (GdkToplevelLayout *layout,
gboolean keep_below)
{
layout->keep_below = keep_below;
}
gboolean
gdk_toplevel_layout_get_keep_below (GdkToplevelLayout *layout)
{
return layout->keep_below;
}
void
gdk_toplevel_layout_set_decorations (GdkToplevelLayout *layout,
GdkWMDecoration decorations)
{
layout->decorations = decorations;
}
GdkWMDecoration
gdk_toplevel_layout_get_decorations (GdkToplevelLayout *layout)
{
return layout->decorations;
}
void
gdk_toplevel_layout_set_functions (GdkToplevelLayout *layout,
GdkWMFunction functions)
{
layout->functions = functions;
}
GdkWMFunction
gdk_toplevel_layout_get_functions (GdkToplevelLayout *layout)
{
return layout->functions;
}

161
gdk/gdktoplevellayout.h Normal file
View File

@@ -0,0 +1,161 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2020 Red Hat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __GDK_TOPLEVEL_LAYOUT_H__
#define __GDK_TOPLEVEL_LAYOUT_H__
#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gdk/gdk.h> can be included directly."
#endif
#include <gdk/gdkversionmacros.h>
#include <gdk/gdktypes.h>
#include <gdk/gdkmonitor.h>
#include <gdk/gdksurface.h>
G_BEGIN_DECLS
/**
* GdkTopLevelLayout:
*/
typedef struct _GdkToplevelLayout GdkToplevelLayout;
#define GDK_TYPE_TOPLEVEL_LAYOUT (gdk_toplevel_layout_get_type ())
GDK_AVAILABLE_IN_ALL
GType gdk_toplevel_layout_get_type (void);
GDK_AVAILABLE_IN_ALL
GdkToplevelLayout * gdk_toplevel_layout_new (int min_width,
int min_height,
int max_width,
int max_height);
GDK_AVAILABLE_IN_ALL
GdkToplevelLayout * gdk_toplevel_layout_ref (GdkToplevelLayout *layout);
GDK_AVAILABLE_IN_ALL
void gdk_toplevel_layout_unref (GdkToplevelLayout *layout);
GDK_AVAILABLE_IN_ALL
GdkToplevelLayout * gdk_toplevel_layout_copy (GdkToplevelLayout *layout);
GDK_AVAILABLE_IN_ALL
gboolean gdk_toplevel_layout_equal (GdkToplevelLayout *layout,
GdkToplevelLayout *other);
GDK_AVAILABLE_IN_ALL
void gdk_toplevel_layout_set_maximized (GdkToplevelLayout *layout,
gboolean maximized);
GDK_AVAILABLE_IN_ALL
void gdk_toplevel_layout_set_fullscreen (GdkToplevelLayout *layout,
gboolean fullscreen,
GdkMonitor *monitor);
GDK_AVAILABLE_IN_ALL
void gdk_toplevel_layout_get_min_size (GdkToplevelLayout *layout,
int *width,
int *height);
GDK_AVAILABLE_IN_ALL
void gdk_toplevel_layout_get_max_size (GdkToplevelLayout *layout,
int *width,
int *height);
GDK_AVAILABLE_IN_ALL
gboolean gdk_toplevel_layout_get_maximized (GdkToplevelLayout *layout);
GDK_AVAILABLE_IN_ALL
gboolean gdk_toplevel_layout_get_fullscreen (GdkToplevelLayout *layout);
GDK_AVAILABLE_IN_ALL
GdkMonitor * gdk_toplevel_layout_get_fullscreen_monitor (GdkToplevelLayout *layout);
GDK_AVAILABLE_IN_ALL
void gdk_toplevel_layout_set_modal (GdkToplevelLayout *layout,
gboolean modal);
GDK_AVAILABLE_IN_ALL
gboolean gdk_toplevel_layout_get_modal (GdkToplevelLayout *layout);
GDK_AVAILABLE_IN_ALL
void gdk_toplevel_layout_set_type_hint (GdkToplevelLayout *layout,
GdkSurfaceTypeHint hint);
GDK_AVAILABLE_IN_ALL
GdkSurfaceTypeHint gdk_toplevel_layout_get_type_hint (GdkToplevelLayout *layout);
GDK_AVAILABLE_IN_ALL
void gdk_toplevel_layout_set_raise (GdkToplevelLayout *layout,
gboolean raise);
GDK_AVAILABLE_IN_ALL
gboolean gdk_toplevel_layout_get_raise (GdkToplevelLayout *layout);
GDK_AVAILABLE_IN_ALL
void gdk_toplevel_layout_set_lower (GdkToplevelLayout *layout,
gboolean lower);
GDK_AVAILABLE_IN_ALL
gboolean gdk_toplevel_layout_get_lower (GdkToplevelLayout *layout);
GDK_AVAILABLE_IN_ALL
void gdk_toplevel_layout_set_minimized (GdkToplevelLayout *layout,
gboolean minimized);
GDK_AVAILABLE_IN_ALL
gboolean gdk_toplevel_layout_get_minimized (GdkToplevelLayout *layout);
GDK_AVAILABLE_IN_ALL
void gdk_toplevel_layout_set_stick (GdkToplevelLayout *layout,
gboolean stick);
GDK_AVAILABLE_IN_ALL
gboolean gdk_toplevel_layout_get_stick (GdkToplevelLayout *layout);
GDK_AVAILABLE_IN_ALL
void gdk_toplevel_layout_set_keep_above (GdkToplevelLayout *layout,
gboolean keep_above);
GDK_AVAILABLE_IN_ALL
gboolean gdk_toplevel_layout_get_keep_above (GdkToplevelLayout *layout);
GDK_AVAILABLE_IN_ALL
void gdk_toplevel_layout_set_keep_below (GdkToplevelLayout *layout,
gboolean keep_below);
GDK_AVAILABLE_IN_ALL
gboolean gdk_toplevel_layout_get_keep_below (GdkToplevelLayout *layout);
GDK_AVAILABLE_IN_ALL
void gdk_toplevel_layout_set_decorations (GdkToplevelLayout *layout,
GdkWMDecoration decorations);
GDK_AVAILABLE_IN_ALL
GdkWMDecoration gdk_toplevel_layout_get_decorations (GdkToplevelLayout *layout);
GDK_AVAILABLE_IN_ALL
void gdk_toplevel_layout_set_functions (GdkToplevelLayout *layout,
GdkWMFunction functions);
GDK_AVAILABLE_IN_ALL
GdkWMFunction gdk_toplevel_layout_get_functions (GdkToplevelLayout *layout);
G_END_DECLS
#endif /* __GDK_TOPLEVEL_LAYOUT_H__ */

38
gdk/gdktoplevelprivate.h Normal file
View File

@@ -0,0 +1,38 @@
#ifndef __GDK_TOPLEVEL_PRIVATE_H__
#define __GDK_TOPLEVEL_PRIVATE_H__
#include "gdktoplevel.h"
G_BEGIN_DECLS
struct _GdkToplevelInterface
{
GTypeInterface g_iface;
gboolean (* present) (GdkToplevel *toplevel,
int width,
int height,
GdkToplevelLayout *layout);
GdkSurfaceState (* get_state) (GdkToplevel *toplevel);
void (* set_title) (GdkToplevel *toplevel,
const char *title);
void (* set_startup_id) (GdkToplevel *toplevel,
const char *startup_id);
void (* set_transient_for) (GdkToplevel *toplevel,
GdkSurface *surface);
void (* set_icon_list) (GdkToplevel *toplevel,
GList *surfaces);
gboolean (* show_window_menu) (GdkToplevel *toplevel,
GdkEvent *event);
};
G_END_DECLS
#endif /* __GDK_TOPLEVEL_PRIVATE_H__ */

View File

@@ -44,7 +44,10 @@ gdk_public_sources = files([
'gdkvulkancontext.c',
'gdksurface.c',
'gdkpopuplayout.c',
'gdkprofiler.c'
'gdkprofiler.c',
'gdkpopup.c',
'gdktoplevellayout.c',
'gdktoplevel.c',
])
gdk_public_headers = files([
@@ -89,6 +92,9 @@ gdk_public_headers = files([
'gdkvulkancontext.h',
'gdksurface.h',
'gdkpopuplayout.h',
'gdkpopup.h',
'gdktoplevellayout.h',
'gdktoplevel.h',
])
install_headers(gdk_public_headers, subdir: 'gtk-4.0/gdk/')

View File

@@ -197,18 +197,6 @@ gdk_wayland_drag_class_init (GdkWaylandDragClass *klass)
drag_class->cancel = gdk_wayland_drag_cancel;
}
static GdkSurface *
create_dnd_surface (GdkDisplay *display)
{
GdkSurface *surface;
surface = gdk_surface_new_temp (display, &(GdkRectangle) { 0, 0, 100, 100 });
gdk_surface_set_type_hint (surface, GDK_SURFACE_TYPE_HINT_DND);
return surface;
}
static inline GdkDragAction
_wl_to_gdk_actions (uint32_t dnd_actions)
{

View File

@@ -199,5 +199,7 @@ void gdk_wayland_surface_restore_shortcuts (GdkSurface *surface,
void gdk_wayland_surface_update_scale (GdkSurface *surface);
GdkSurface * create_dnd_surface (GdkDisplay *display);
#endif /* __GDK_PRIVATE_WAYLAND_H__ */

View File

@@ -97,6 +97,7 @@ struct _GdkWaylandSurface
unsigned int pending_commit : 1;
unsigned int awaiting_frame : 1;
unsigned int awaiting_frame_frozen : 1;
unsigned int is_drag_surface : 1;
GdkSurfaceTypeHint hint;
GdkSurface *transient_for;
GdkSurface *popup_parent;
@@ -601,6 +602,8 @@ gdk_wayland_surface_update_scale (GdkSurface *surface)
}
static void gdk_wayland_surface_create_surface (GdkSurface *surface);
static void gdk_wayland_surface_set_title (GdkSurface *surface,
const char *title);
GdkSurface *
_gdk_wayland_display_create_surface (GdkDisplay *display,
@@ -653,7 +656,7 @@ _gdk_wayland_display_create_surface (GdkDisplay *display,
gdk_display_get_n_monitors (display) > 0)
impl->scale = gdk_monitor_get_scale_factor (gdk_display_get_monitor (display, 0));
gdk_surface_set_title (surface, get_default_title ());
gdk_wayland_surface_set_title (surface, get_default_title ());
if (parent == NULL)
display_wayland->toplevels = g_list_prepend (display_wayland->toplevels, surface);
@@ -1024,6 +1027,10 @@ gdk_wayland_surface_get_window_geometry (GdkSurface *surface,
};
}
static void gdk_wayland_surface_set_geometry_hints (GdkSurface *surface,
const GdkGeometry *geometry,
GdkSurfaceHints geom_mask);
static void
gdk_wayland_surface_sync_margin (GdkSurface *surface)
{
@@ -1036,9 +1043,9 @@ gdk_wayland_surface_sync_margin (GdkSurface *surface)
return;
gdk_wayland_surface_get_window_geometry (surface, &geometry);
gdk_surface_set_geometry_hints (surface,
&impl->geometry_hints,
impl->geometry_mask);
gdk_wayland_surface_set_geometry_hints (surface,
&impl->geometry_hints,
impl->geometry_mask);
switch (display_wayland->shell_variant)
{
@@ -2363,7 +2370,7 @@ should_be_mapped (GdkSurface *surface)
if (surface->surface_type == GDK_SURFACE_TEMP && surface->x < 0 && surface->y < 0)
return FALSE;
if (impl->hint == GDK_SURFACE_TYPE_HINT_DND)
if (impl->is_drag_surface)
return FALSE;
return TRUE;
@@ -2634,6 +2641,11 @@ is_fallback_relayout_possible (GdkSurface *surface)
return TRUE;
}
static gboolean gdk_wayland_surface_present_popup (GdkSurface *surface,
int width,
int height,
GdkPopupLayout *layout);
static void
queue_relayout_fallback (GdkSurface *surface,
GdkPopupLayout *layout)
@@ -2644,10 +2656,10 @@ queue_relayout_fallback (GdkSurface *surface,
return;
gdk_wayland_surface_hide_surface (surface);
gdk_surface_present_popup (surface,
impl->popup.unconstrained_width,
impl->popup.unconstrained_height,
layout);
gdk_wayland_surface_present_popup (surface,
impl->popup.unconstrained_width,
impl->popup.unconstrained_height,
layout);
}
static void
@@ -3119,9 +3131,9 @@ gdk_wayland_surface_init_gtk_surface (GdkSurface *surface)
impl->display_server.wl_surface);
wl_proxy_set_queue ((struct wl_proxy *) impl->display_server.gtk_surface,
impl->event_queue);
gdk_surface_set_geometry_hints (surface,
&impl->geometry_hints,
impl->geometry_mask);
gdk_wayland_surface_set_geometry_hints (surface,
&impl->geometry_hints,
impl->geometry_mask);
gtk_surface1_add_listener (impl->display_server.gtk_surface,
&gtk_surface_listener,
surface);
@@ -4328,7 +4340,7 @@ gdk_wayland_surface_set_transient_for_exported (GdkSurface *surface,
return FALSE;
}
gdk_surface_set_transient_for (surface, NULL);
gdk_wayland_surface_set_transient_for (surface, NULL);
impl->imported_transient_for =
zxdg_importer_v1_import (display_wayland->xdg_importer, parent_handle_str);
@@ -4387,3 +4399,14 @@ gdk_wayland_surface_restore_shortcuts (GdkSurface *surface,
g_hash_table_remove (impl->shortcuts_inhibitors, seat);
}
GdkSurface *
create_dnd_surface (GdkDisplay *display)
{
GdkSurface *surface;
surface = gdk_surface_new_temp (display, &(GdkRectangle) { 0, 0, 100, 100 });
GDK_WAYLAND_SURFACE (surface)->is_drag_surface = TRUE;
return surface;
}

View File

@@ -378,7 +378,7 @@ do_net_wm_state_changes (GdkSurface *surface)
gdk_surface_get_surface_type (surface) != GDK_SURFACE_TOPLEVEL)
return;
old_state = gdk_surface_get_state (surface);
old_state = gdk_toplevel_get_state (GDK_TOPLEVEL (surface));
set = unset = 0;

View File

@@ -1270,8 +1270,6 @@ create_drag_surface (GdkDisplay *display)
surface = gdk_surface_new_temp (display, &(GdkRectangle) { 0, 0, 100, 100 });
gdk_surface_set_type_hint (surface, GDK_SURFACE_TYPE_HINT_DND);
return surface;
}
@@ -1401,7 +1399,7 @@ move_drag_surface (GdkDrag *drag,
gdk_x11_surface_move (drag_x11->drag_surface,
x_root - drag_x11->hot_x,
y_root - drag_x11->hot_y);
gdk_surface_raise (drag_x11->drag_surface);
gdk_x11_surface_raise (drag_x11->drag_surface);
}
static gboolean

View File

@@ -44,7 +44,7 @@ gdk_monitor_has_fullscreen_window (GdkMonitor *monitor)
{
surface = l->data;
if ((gdk_surface_get_state (surface) & GDK_SURFACE_STATE_FULLSCREEN) == 0)
if ((gdk_toplevel_get_state (GDK_TOPLEVEL (surface)) & GDK_SURFACE_STATE_FULLSCREEN) == 0)
continue;
if (gdk_surface_get_fullscreen_mode (surface) == GDK_FULLSCREEN_ON_ALL_MONITORS ||

View File

@@ -230,6 +230,8 @@ void gdk_x11_surface_get_root_coords (GdkSurface *surface,
gint *root_x,
gint *root_y);
void gdk_x11_surface_raise (GdkSurface *surface);
GdkGrabStatus _gdk_x11_convert_grab_status (gint status);
cairo_surface_t * _gdk_x11_display_create_bitmap_surface (GdkDisplay *display,

View File

@@ -792,6 +792,9 @@ disconnect_frame_clock (GdkSurface *surface)
}
}
static void gdk_x11_surface_set_title (GdkSurface *surface,
const char *title);
GdkSurface *
_gdk_x11_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type,
@@ -909,7 +912,7 @@ _gdk_x11_display_create_surface (GdkDisplay *display,
g_object_ref (surface);
_gdk_x11_display_add_window (x11_screen->display, &impl->xid, surface);
gdk_surface_set_title (surface, get_default_title ());
gdk_x11_surface_set_title (surface, get_default_title ());
class_hint = XAllocClassHint ();
class_hint->res_name = (char *) g_get_prgname ();
@@ -1455,7 +1458,7 @@ gdk_x11_surface_layout_popup (GdkSurface *surface,
static void
show_popup (GdkSurface *surface)
{
gdk_surface_raise (surface);
gdk_x11_surface_raise (surface);
gdk_synthesize_surface_state (surface, GDK_SURFACE_STATE_WITHDRAWN, 0);
_gdk_surface_update_viewable (surface);
gdk_x11_surface_show (surface, FALSE);
@@ -1520,6 +1523,10 @@ gdk_x11_surface_update_popups (GdkSurface *parent)
}
}
static void gdk_x11_surface_set_geometry_hints (GdkSurface *surface,
const GdkGeometry *geometry,
GdkSurfaceHints geom_mask);
void
_gdk_x11_surface_set_surface_scale (GdkSurface *surface,
int scale)
@@ -1542,9 +1549,9 @@ _gdk_x11_surface_set_surface_scale (GdkSurface *surface,
geom_mask = toplevel->last_geometry_hints_mask &
(GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_BASE_SIZE | GDK_HINT_RESIZE_INC);
if (geom_mask)
gdk_surface_set_geometry_hints (surface,
&toplevel->last_geometry_hints,
geom_mask);
gdk_x11_surface_set_geometry_hints (surface,
&toplevel->last_geometry_hints,
geom_mask);
}
if (impl->override_redirect)
@@ -1561,7 +1568,7 @@ _gdk_x11_surface_set_surface_scale (GdkSurface *surface,
gdk_surface_invalidate_rect (surface, NULL);
}
static void
void
gdk_x11_surface_raise (GdkSurface *surface)
{
XRaiseWindow (GDK_SURFACE_XDISPLAY (surface), GDK_SURFACE_XID (surface));
@@ -3878,7 +3885,7 @@ check_maximize (MoveResizeData *mv_resize,
if (mv_resize->is_resize)
return;
state = gdk_surface_get_state (mv_resize->moveresize_surface);
state = gdk_toplevel_get_state (GDK_TOPLEVEL (mv_resize->moveresize_surface));
if (state & GDK_SURFACE_STATE_MAXIMIZED)
return;
@@ -3886,7 +3893,7 @@ check_maximize (MoveResizeData *mv_resize,
y = mv_resize->moveresize_orig_y + (y_root - mv_resize->moveresize_y);
if (y < 10)
gdk_surface_maximize (mv_resize->moveresize_surface);
gdk_x11_surface_maximize (mv_resize->moveresize_surface);
}
static void
@@ -3900,7 +3907,7 @@ check_unmaximize (MoveResizeData *mv_resize,
if (mv_resize->is_resize)
return;
state = gdk_surface_get_state (mv_resize->moveresize_surface);
state = gdk_toplevel_get_state (GDK_TOPLEVEL (mv_resize->moveresize_surface));
if ((state & (GDK_SURFACE_STATE_MAXIMIZED | GDK_SURFACE_STATE_TILED)) == 0)
return;
@@ -3909,7 +3916,7 @@ check_unmaximize (MoveResizeData *mv_resize,
dy = y_root - mv_resize->moveresize_y;
if (ABS (dx) > 20 || ABS (dy) > 20)
gdk_surface_unmaximize (mv_resize->moveresize_surface);
gdk_x11_surface_unmaximize (mv_resize->moveresize_surface);
}
static void

View File

@@ -229,9 +229,9 @@ gtk_window_accessible_ref_state_set (AtkObject *accessible)
atk_state_set_add_state (state_set, ATK_STATE_ACTIVE);
gdk_surface = gtk_native_get_surface (GTK_NATIVE (window));
if (gdk_surface)
if (GDK_IS_TOPLEVEL (gdk_surface))
{
state = gdk_surface_get_state (gdk_surface);
state = gdk_toplevel_get_state (GDK_TOPLEVEL (gdk_surface));
if (state & GDK_SURFACE_STATE_MINIMIZED)
atk_state_set_add_state (state_set, ATK_STATE_ICONIFIED);
}

View File

@@ -1084,7 +1084,7 @@ surface_state_changed (GtkWidget *widget)
GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar);
GdkSurfaceState changed, new_state;
new_state = gdk_surface_get_state (gtk_native_get_surface (gtk_widget_get_native (widget)));
new_state = gdk_toplevel_get_state (GDK_TOPLEVEL (gtk_native_get_surface (gtk_widget_get_native (widget))));
changed = new_state ^ priv->state;
priv->state = new_state;

View File

@@ -141,7 +141,6 @@ typedef struct {
GskRenderer *renderer;
GtkWidget *default_widget;
GdkSurfaceState state;
GdkRectangle pointing_to;
gboolean has_pointing_to;
guint surface_transform_changed_cb;
@@ -351,6 +350,7 @@ update_popover_layout (GtkPopover *popover,
GdkRectangle final_rect;
gboolean flipped_x;
gboolean flipped_y;
GdkPopup *popup = GDK_POPUP (priv->surface);
g_clear_pointer (&priv->layout, gdk_popup_layout_unref);
priv->layout = layout;
@@ -359,20 +359,18 @@ update_popover_layout (GtkPopover *popover,
.width = gdk_surface_get_width (priv->surface),
.height = gdk_surface_get_height (priv->surface),
};
gdk_surface_get_position (priv->surface,
&final_rect.x,
&final_rect.y);
gdk_popup_get_position (popup, &final_rect.x, &final_rect.y);
flipped_x =
did_flip_horizontally (gdk_popup_layout_get_rect_anchor (layout),
gdk_surface_get_popup_rect_anchor (priv->surface)) &&
gdk_popup_get_rect_anchor (popup)) &&
did_flip_horizontally (gdk_popup_layout_get_surface_anchor (layout),
gdk_surface_get_popup_surface_anchor (priv->surface));
gdk_popup_get_surface_anchor (popup));
flipped_y =
did_flip_vertically (gdk_popup_layout_get_rect_anchor (layout),
gdk_surface_get_popup_rect_anchor (priv->surface)) &&
gdk_popup_get_rect_anchor (popup)) &&
did_flip_vertically (gdk_popup_layout_get_surface_anchor (layout),
gdk_surface_get_popup_surface_anchor (priv->surface));
gdk_popup_get_surface_anchor (popup));
gtk_widget_allocate (GTK_WIDGET (popover),
gdk_surface_get_width (priv->surface),
@@ -544,7 +542,7 @@ present_popup (GtkPopover *popover)
layout = create_popup_layout (popover);
gtk_widget_get_preferred_size (GTK_WIDGET (popover), NULL, &req);
if (gdk_surface_present_popup (priv->surface,
if (gdk_popup_present (GDK_POPUP (priv->surface),
MAX (req.width, 1),
MAX (req.height, 1),
layout))
@@ -592,23 +590,12 @@ gtk_popover_key_pressed (GtkWidget *widget,
}
static void
surface_state_changed (GtkWidget *widget)
surface_mapped_changed (GtkWidget *widget)
{
GtkPopover *popover = GTK_POPOVER (widget);
GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
GdkSurfaceState new_surface_state;
GdkSurfaceState changed_mask;
new_surface_state = gdk_surface_get_state (priv->surface);
changed_mask = new_surface_state ^ priv->state;
priv->state = new_surface_state;
if (changed_mask & GDK_SURFACE_STATE_WITHDRAWN)
{
if (priv->state & GDK_SURFACE_STATE_WITHDRAWN &&
gtk_widget_is_visible (widget))
gtk_widget_hide (widget);
}
gtk_widget_set_visible (widget, gdk_surface_get_mapped (priv->surface));
}
static void
@@ -752,7 +739,7 @@ gtk_popover_realize (GtkWidget *widget)
gdk_surface_set_widget (priv->surface, widget);
g_signal_connect_swapped (priv->surface, "notify::state", G_CALLBACK (surface_state_changed), widget);
g_signal_connect_swapped (priv->surface, "notify::mapped", G_CALLBACK (surface_mapped_changed), widget);
g_signal_connect_swapped (priv->surface, "size-changed", G_CALLBACK (surface_size_changed), widget);
g_signal_connect (priv->surface, "render", G_CALLBACK (surface_render), widget);
g_signal_connect (priv->surface, "event", G_CALLBACK (surface_event), widget);
@@ -774,7 +761,7 @@ gtk_popover_unrealize (GtkWidget *widget)
gsk_renderer_unrealize (priv->renderer);
g_clear_object (&priv->renderer);
g_signal_handlers_disconnect_by_func (priv->surface, surface_state_changed, widget);
g_signal_handlers_disconnect_by_func (priv->surface, surface_mapped_changed, widget);
g_signal_handlers_disconnect_by_func (priv->surface, surface_size_changed, widget);
g_signal_handlers_disconnect_by_func (priv->surface, surface_render, widget);
g_signal_handlers_disconnect_by_func (priv->surface, surface_event, widget);
@@ -1175,11 +1162,11 @@ gtk_popover_update_shape (GtkPopover *popover)
region = gdk_cairo_region_create_from_surface (cairo_surface);
cairo_surface_destroy (cairo_surface);
gdk_surface_input_shape_combine_region (priv->surface, region, 0, 0);
gdk_surface_set_input_region (priv->surface, region);
cairo_region_destroy (region);
}
else
gdk_surface_input_shape_combine_region (priv->surface, NULL, 0, 0);
gdk_surface_set_input_region (priv->surface, NULL);
}
static gint

View File

@@ -136,10 +136,10 @@ gtk_tooltip_window_relayout (GtkTooltipWindow *window)
gtk_widget_get_preferred_size (GTK_WIDGET (window), NULL, &req);
layout = create_popup_layout (window);
gdk_surface_present_popup (window->surface,
MAX (req.width, 1),
MAX (req.height, 1),
layout);
gdk_popup_present (GDK_POPUP (window->surface),
MAX (req.width, 1),
MAX (req.height, 1),
layout);
gdk_popup_layout_unref (layout);
}
@@ -178,7 +178,7 @@ surface_state_changed (GtkWidget *widget)
GdkSurfaceState new_surface_state;
GdkSurfaceState changed_mask;
new_surface_state = gdk_surface_get_state (window->surface);
new_surface_state = gdk_toplevel_get_state (GDK_TOPLEVEL (window->surface));
changed_mask = new_surface_state ^ window->state;
window->state = new_surface_state;
@@ -284,10 +284,10 @@ gtk_tooltip_window_map (GtkWidget *widget)
GtkWidget *child;
layout = create_popup_layout (window);
gdk_surface_present_popup (window->surface,
gdk_surface_get_width (window->surface),
gdk_surface_get_height (window->surface),
layout);
gdk_popup_present (GDK_POPUP (window->surface),
gdk_surface_get_width (window->surface),
gdk_surface_get_height (window->surface),
layout);
gdk_popup_layout_unref (layout);
window->surface_transform_changed_cb =

View File

@@ -507,6 +507,11 @@ static void gtk_window_state_flags_changed (GtkWidget *widget,
GtkStateFlags previous_state);
static void _gtk_window_set_is_active (GtkWindow *window,
gboolean is_active);
static void gtk_window_present_toplevel (GtkWindow *window);
static void gtk_window_update_toplevel (GtkWindow *window);
static GdkToplevelLayout * gtk_window_compute_layout (GtkWindow *window,
int *width,
int *height);
static GListStore *toplevel_list = NULL;
static guint window_signals[LAST_SIGNAL] = { 0 };
@@ -1319,9 +1324,26 @@ gtk_window_titlebar_action (GtkWindow *window,
_gtk_window_toggle_maximized (window);
}
else if (g_str_equal (action, "lower"))
gdk_surface_lower (priv->surface);
{
int w, h;
GdkToplevelLayout *layout;
layout = gtk_window_compute_layout (window, &w, &h);
gdk_toplevel_layout_set_raise (layout, FALSE);
gdk_toplevel_layout_set_lower (layout, TRUE);
gdk_toplevel_present (GDK_TOPLEVEL (priv->surface), w, h, layout);
gdk_toplevel_layout_unref (layout);
}
else if (g_str_equal (action, "minimize"))
gdk_surface_minimize (priv->surface);
{
int w, h;
GdkToplevelLayout *layout;
layout = gtk_window_compute_layout (window, &w, &h);
gdk_toplevel_layout_set_minimized (layout, TRUE);
gdk_toplevel_present (GDK_TOPLEVEL (priv->surface), w, h, layout);
gdk_toplevel_layout_unref (layout);
}
else if (g_str_equal (action, "menu"))
gtk_window_do_popup (window, (GdkEventButton*) event);
else
@@ -1393,7 +1415,16 @@ click_gesture_pressed_cb (GtkGestureClick *gesture,
event_widget = gtk_get_event_widget ((GdkEvent *) event);
if (region == GTK_WINDOW_REGION_TITLE)
gdk_surface_raise (priv->surface);
{
int w, h;
GdkToplevelLayout *layout;
layout = gtk_window_compute_layout (window, &w, &h);
gdk_toplevel_layout_set_raise (layout, TRUE);
gdk_toplevel_layout_set_lower (layout, FALSE);
gdk_toplevel_present (GDK_TOPLEVEL (priv->surface), w, y, layout);
gdk_toplevel_layout_unref (layout);
}
switch (region)
{
@@ -1434,12 +1465,12 @@ click_gesture_pressed_cb (GtkGestureClick *gesture,
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
gdk_event_get_position (event, &tx, &ty);
gdk_surface_begin_resize_drag_for_device (priv->surface,
(GdkSurfaceEdge) region,
gdk_event_get_device ((GdkEvent *) event),
GDK_BUTTON_PRIMARY,
tx, ty,
gdk_event_get_time (event));
gdk_surface_begin_resize_drag (priv->surface,
(GdkSurfaceEdge) region,
gdk_event_get_device ((GdkEvent *) event),
GDK_BUTTON_PRIMARY,
tx, ty,
gdk_event_get_time (event));
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (priv->drag_gesture));
@@ -1535,11 +1566,11 @@ drag_gesture_update_cb (GtkGestureDrag *gesture,
gtk_gesture_drag_get_start_point (gesture, &start_x, &start_y);
gdk_surface_begin_move_drag_for_device (priv->surface,
gtk_gesture_get_device (GTK_GESTURE (gesture)),
gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture)),
(int)start_x, (int)start_y,
gtk_get_current_event_time ());
gdk_surface_begin_move_drag (priv->surface,
gtk_gesture_get_device (GTK_GESTURE (gesture)),
gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture)),
(int)start_x, (int)start_y,
gtk_get_current_event_time ());
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (priv->click_gesture));
@@ -2407,7 +2438,7 @@ gtk_window_set_title_internal (GtkWindow *window,
priv->title = new_title;
if (_gtk_widget_get_realized (GTK_WIDGET (window)))
gdk_surface_set_title (priv->surface, new_title != NULL ? new_title : "");
gdk_toplevel_set_title (GDK_TOPLEVEL (priv->surface), new_title != NULL ? new_title : "");
if (update_titlebar && GTK_IS_HEADER_BAR (priv->title_box))
gtk_header_bar_set_title (GTK_HEADER_BAR (priv->title_box), new_title != NULL ? new_title : "");
@@ -2505,7 +2536,7 @@ gtk_window_set_startup_id (GtkWindow *window,
gtk_window_present_with_time (window, timestamp);
else
{
gdk_surface_set_startup_id (priv->surface, priv->startup_id);
gdk_toplevel_set_startup_id (GDK_TOPLEVEL (priv->surface), priv->startup_id);
/* If window is mapped, terminate the startup-notification too */
if (_gtk_widget_get_mapped (widget) && !disable_startup_notification)
@@ -2861,9 +2892,7 @@ gtk_window_set_modal (GtkWindow *window,
priv->modal = modal;
widget = GTK_WIDGET (window);
/* adjust desired modality state */
if (_gtk_widget_get_realized (widget))
gdk_surface_set_modal_hint (priv->surface, priv->modal);
gtk_window_update_toplevel (window);
if (gtk_widget_get_visible (widget))
{
@@ -3024,7 +3053,7 @@ gtk_window_transient_parent_realized (GtkWidget *parent,
GtkWindowPrivate *priv = gtk_window_get_instance_private (GTK_WINDOW (window));
GtkWindowPrivate *parent_priv = gtk_window_get_instance_private (GTK_WINDOW (parent));
if (_gtk_widget_get_realized (window))
gdk_surface_set_transient_for (priv->surface, parent_priv->surface);
gdk_toplevel_set_transient_for (GDK_TOPLEVEL (priv->surface), parent_priv->surface);
}
static void
@@ -3033,7 +3062,7 @@ gtk_window_transient_parent_unrealized (GtkWidget *parent,
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (GTK_WINDOW (window));
if (_gtk_widget_get_realized (window))
gdk_surface_set_transient_for (priv->surface, NULL);
gdk_toplevel_set_transient_for (GDK_TOPLEVEL (priv->surface), NULL);
}
static void
@@ -3047,7 +3076,7 @@ gtk_window_transient_parent_display_changed (GtkWindow *parent,
}
static void
gtk_window_unset_transient_for (GtkWindow *window)
gtk_window_unset_transient_for (GtkWindow *window)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
@@ -3360,8 +3389,7 @@ gtk_window_set_type_hint (GtkWindow *window,
priv->type_hint = hint;
if (priv->surface)
gdk_surface_set_type_hint (priv->surface, hint);
gtk_window_update_toplevel (window);
g_object_notify_by_pspec (G_OBJECT (window), window_props[PROP_TYPE_HINT]);
@@ -3807,19 +3835,7 @@ gtk_window_set_decorated (GtkWindow *window,
priv->decorated = setting;
if (priv->surface)
{
if (priv->decorated)
{
if (priv->client_decorated)
gdk_surface_set_decorations (priv->surface, 0);
else
gdk_surface_set_decorations (priv->surface, GDK_DECOR_ALL);
}
else
gdk_surface_set_decorations (priv->surface, 0);
}
gtk_window_update_toplevel (window);
update_window_buttons (window);
gtk_widget_queue_resize (GTK_WIDGET (window));
@@ -3876,15 +3892,7 @@ gtk_window_set_deletable (GtkWindow *window,
priv->deletable = setting;
if (priv->surface)
{
if (priv->deletable)
gdk_surface_set_functions (priv->surface, GDK_FUNC_ALL);
else
gdk_surface_set_functions (priv->surface,
GDK_FUNC_ALL | GDK_FUNC_CLOSE);
}
gtk_window_update_toplevel (window);
update_window_buttons (window);
g_object_notify_by_pspec (G_OBJECT (window), window_props[PROP_DELETABLE]);
@@ -4069,7 +4077,7 @@ gtk_window_realize_icon (GtkWindow *window)
info->realized = TRUE;
gdk_surface_set_icon_list (priv->surface, icon_list);
gdk_toplevel_set_icon_list (GDK_TOPLEVEL (priv->surface), icon_list);
if (GTK_IS_HEADER_BAR (priv->title_box))
_gtk_header_bar_update_window_icon (GTK_HEADER_BAR (priv->title_box), window);
@@ -4884,13 +4892,84 @@ gtk_window_hide (GtkWidget *widget)
gtk_grab_remove (widget);
}
static GdkToplevelLayout *
gtk_window_compute_layout (GtkWindow *window,
int *width,
int *height)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GdkRectangle request;
GdkGeometry geometry;
GdkSurfaceHints flags;
GdkToplevelLayout *layout;
gtk_window_compute_configure_request (window, &request,
&geometry, &flags);
if (width)
*width = request.width;
if (height)
*height = request.height;
if (!(flags & GDK_HINT_MIN_SIZE))
geometry.min_width = geometry.min_height = 1;
if (!(flags & GDK_HINT_MAX_SIZE))
geometry.max_width = geometry.max_height = G_MAXINT;
layout = gdk_toplevel_layout_new (geometry.min_width, geometry.min_height,
geometry.max_width, geometry.max_height);
gdk_toplevel_layout_set_maximized (layout, priv->maximize_initially);
gdk_toplevel_layout_set_minimized (layout, priv->minimize_initially);
gdk_toplevel_layout_set_stick (layout, priv->stick_initially);
gdk_toplevel_layout_set_keep_above (layout, priv->above_initially);
gdk_toplevel_layout_set_keep_below (layout, priv->below_initially);
gdk_toplevel_layout_set_fullscreen (layout,
priv->fullscreen_initially,
priv->initial_fullscreen_monitor);
gdk_toplevel_layout_set_modal (layout, priv->modal);
gdk_toplevel_layout_set_type_hint (layout, priv->type_hint);
gdk_toplevel_layout_set_raise (layout, TRUE);
if (priv->decorated && !priv->client_decorated)
gdk_toplevel_layout_set_decorations (layout, GDK_DECOR_ALL);
else
gdk_toplevel_layout_set_decorations (layout, 0);
if (priv->deletable)
gdk_toplevel_layout_set_functions (layout, GDK_FUNC_ALL);
else
gdk_toplevel_layout_set_functions (layout, GDK_FUNC_ALL | GDK_FUNC_CLOSE);
return layout;
}
static void
gtk_window_present_toplevel (GtkWindow *window)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
int width, height;
GdkToplevelLayout *layout;
layout = gtk_window_compute_layout (window, &width, &height);
gdk_toplevel_present (GDK_TOPLEVEL (priv->surface), width, height, layout);
gdk_toplevel_layout_unref (layout);
}
static void
gtk_window_update_toplevel (GtkWindow *window)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
if (priv->surface && gdk_surface_get_mapped (priv->surface))
gtk_window_present_toplevel (window);
}
static void
gtk_window_map (GtkWidget *widget)
{
GtkWidget *child;
GtkWindow *window = GTK_WINDOW (widget);
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GdkSurface *surface;
GTK_WIDGET_CLASS (gtk_window_parent_class)->map (widget);
@@ -4903,44 +4982,13 @@ gtk_window_map (GtkWidget *widget)
gtk_widget_get_child_visible (priv->title_box))
gtk_widget_map (priv->title_box);
surface = priv->surface;
if (priv->maximize_initially)
gdk_surface_maximize (surface);
else
gdk_surface_unmaximize (surface);
if (priv->stick_initially)
gdk_surface_stick (surface);
else
gdk_surface_unstick (surface);
if (priv->minimize_initially)
gdk_surface_minimize (surface);
else
gdk_surface_unminimize (surface);
if (priv->fullscreen_initially)
{
if (priv->initial_fullscreen_monitor)
gdk_surface_fullscreen_on_monitor (surface, priv->initial_fullscreen_monitor);
else
gdk_surface_fullscreen (surface);
}
else
gdk_surface_unfullscreen (surface);
gdk_surface_set_keep_above (surface, priv->above_initially);
gdk_surface_set_keep_below (surface, priv->below_initially);
gtk_window_present_toplevel (window);
gtk_window_set_theme_variant (window);
/* No longer use the default settings */
priv->need_default_size = FALSE;
gdk_surface_show (surface);
if (!disable_startup_notification)
{
/* Do we have a custom startup-notification id? */
@@ -4987,7 +5035,7 @@ gtk_window_unmap (GtkWidget *widget)
}
priv->configure_notify_received = FALSE;
state = gdk_surface_get_state (priv->surface);
state = gdk_toplevel_get_state (GDK_TOPLEVEL (priv->surface));
priv->minimize_initially = (state & GDK_SURFACE_STATE_MINIMIZED) != 0;
priv->maximize_initially = (state & GDK_SURFACE_STATE_MAXIMIZED) != 0;
priv->stick_initially = (state & GDK_SURFACE_STATE_STICKY) != 0;
@@ -5342,7 +5390,7 @@ update_csd_shape (GtkWindow *window)
if (priv->extra_input_region)
cairo_region_intersect (region, priv->extra_input_region);
gdk_surface_input_shape_combine_region (priv->surface, region, 0, 0);
gdk_surface_set_input_region (priv->surface, region);
cairo_region_destroy (region);
}
}
@@ -5521,25 +5569,17 @@ gtk_window_realize (GtkWidget *widget)
_gtk_widget_get_realized (GTK_WIDGET (priv->transient_parent)))
{
GtkWindowPrivate *parent_priv = gtk_window_get_instance_private (priv->transient_parent);
gdk_surface_set_transient_for (surface, parent_priv->surface);
gdk_toplevel_set_transient_for (GDK_TOPLEVEL (surface), parent_priv->surface);
}
gdk_surface_set_type_hint (surface, priv->type_hint);
if (priv->title)
gdk_surface_set_title (surface, priv->title);
if (!priv->decorated || priv->client_decorated)
gdk_surface_set_decorations (surface, 0);
gdk_toplevel_set_title (GDK_TOPLEVEL (surface), priv->title);
#ifdef GDK_WINDOWING_WAYLAND
if (priv->client_decorated && GDK_IS_WAYLAND_SURFACE (surface))
gdk_wayland_surface_announce_csd (surface);
#endif
if (!priv->deletable)
gdk_surface_set_functions (surface, GDK_FUNC_ALL | GDK_FUNC_CLOSE);
if (gtk_window_get_accept_focus (window))
gdk_surface_set_accept_focus (surface, TRUE);
else
@@ -5550,11 +5590,6 @@ gtk_window_realize (GtkWidget *widget)
else
gdk_surface_set_focus_on_map (surface, FALSE);
if (priv->modal)
gdk_surface_set_modal_hint (surface, TRUE);
else
gdk_surface_set_modal_hint (surface, FALSE);
if (priv->startup_id)
{
#ifdef GDK_WINDOWING_X11
@@ -5566,7 +5601,7 @@ gtk_window_realize (GtkWidget *widget)
}
#endif
if (!startup_id_is_fake (priv->startup_id))
gdk_surface_set_startup_id (surface, priv->startup_id);
gdk_toplevel_set_startup_id (GDK_TOPLEVEL (surface), priv->startup_id);
}
#ifdef GDK_WINDOWING_X11
@@ -5913,7 +5948,7 @@ surface_state_changed (GtkWidget *widget)
GdkSurfaceState new_surface_state;
GdkSurfaceState changed_mask;
new_surface_state = gdk_surface_get_state (priv->surface);
new_surface_state = gdk_toplevel_get_state (GDK_TOPLEVEL (priv->surface));
changed_mask = new_surface_state ^ priv->state;
priv->state = new_surface_state;
@@ -6650,7 +6685,7 @@ gtk_window_get_state (GtkWindow *window)
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
if (priv->surface)
return gdk_surface_get_state (priv->surface);
return gdk_toplevel_get_state (GDK_TOPLEVEL (priv->surface));
return 0;
}
@@ -6681,11 +6716,13 @@ move_window_clicked (GtkModelButton *button,
gpointer user_data)
{
GtkWindow *window = GTK_WINDOW (user_data);
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
gtk_window_begin_move_drag (window,
0, /* 0 means "use keyboard" */
0, 0,
GDK_CURRENT_TIME);
gdk_surface_begin_move_drag (priv->surface,
NULL,
0, /* 0 means "use keyboard" */
0, 0,
GDK_CURRENT_TIME);
}
static void
@@ -6693,9 +6730,11 @@ resize_window_clicked (GtkModelButton *button,
gpointer user_data)
{
GtkWindow *window = GTK_WINDOW (user_data);
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
gtk_window_begin_resize_drag (window,
gdk_surface_begin_resize_drag (priv->surface,
0,
NULL,
0, /* 0 means "use keyboard" */
0, 0,
GDK_CURRENT_TIME);
@@ -6871,7 +6910,7 @@ gtk_window_do_popup (GtkWindow *window,
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
if (!gdk_surface_show_window_menu (priv->surface, (GdkEvent *) event))
if (!gdk_toplevel_show_window_menu (GDK_TOPLEVEL (priv->surface), (GdkEvent *) event))
gtk_window_do_popup_fallback (window, event);
}
@@ -7045,6 +7084,7 @@ gtk_window_move_resize (GtkWindow *window)
gboolean hints_changed; /* do we need to send these again */
GtkWindowLastGeometryInfo saved_last_info;
int current_width, current_height;
GdkToplevelLayout *layout;
widget = GTK_WIDGET (window);
@@ -7136,13 +7176,6 @@ gtk_window_move_resize (GtkWindow *window)
hints_changed = TRUE;
}
/* Set hints if necessary
*/
if (hints_changed)
gdk_surface_set_geometry_hints (priv->surface,
&new_geometry,
new_flags);
current_width = gdk_surface_get_width (priv->surface);
current_height = gdk_surface_get_height (priv->surface);
@@ -7266,8 +7299,11 @@ gtk_window_move_resize (GtkWindow *window)
if (configure_request_pos_changed)
g_warning ("configure request position changed. This should not happen. Ignoring the position");
gdk_surface_resize (priv->surface,
new_request.width, new_request.height);
layout = gtk_window_compute_layout (window, NULL, NULL);
gdk_toplevel_present (GDK_TOPLEVEL (priv->surface),
new_request.width, new_request.height,
layout);
gdk_toplevel_layout_unref (layout);
}
else
{
@@ -7625,7 +7661,7 @@ gtk_window_present_with_time (GtkWindow *window,
g_assert (surface != NULL);
gdk_surface_show (surface);
gtk_window_present_toplevel (window);
/* Translate a timestamp of GDK_CURRENT_TIME appropriately */
if (timestamp == GDK_CURRENT_TIME)
@@ -7680,8 +7716,7 @@ gtk_window_minimize (GtkWindow *window)
priv->minimize_initially = TRUE;
if (priv->surface)
gdk_surface_minimize (priv->surface);
gtk_window_update_toplevel (window);
}
/**
@@ -7708,8 +7743,7 @@ gtk_window_unminimize (GtkWindow *window)
priv->minimize_initially = FALSE;
if (priv->surface)
gdk_surface_unminimize (priv->surface);
gtk_window_update_toplevel (window);
}
/**
@@ -7738,8 +7772,7 @@ gtk_window_stick (GtkWindow *window)
priv->stick_initially = TRUE;
if (priv->surface)
gdk_surface_stick (priv->surface);
gtk_window_update_toplevel (window);
}
/**
@@ -7765,8 +7798,7 @@ gtk_window_unstick (GtkWindow *window)
priv->stick_initially = FALSE;
if (priv->surface)
gdk_surface_unstick (priv->surface);
gtk_window_update_toplevel (window);
}
/**
@@ -7798,8 +7830,7 @@ gtk_window_maximize (GtkWindow *window)
priv->maximize_initially = TRUE;
if (priv->surface)
gdk_surface_maximize (priv->surface);
gtk_window_update_toplevel (window);
}
/**
@@ -7826,8 +7857,7 @@ gtk_window_unmaximize (GtkWindow *window)
priv->maximize_initially = FALSE;
if (priv->surface)
gdk_surface_unmaximize (priv->surface);
gtk_window_update_toplevel (window);
}
/**
@@ -7853,8 +7883,7 @@ gtk_window_fullscreen (GtkWindow *window)
priv->fullscreen_initially = TRUE;
if (priv->surface)
gdk_surface_fullscreen (priv->surface);
gtk_window_update_toplevel (window);
}
static void
@@ -7900,8 +7929,7 @@ gtk_window_fullscreen_on_monitor (GtkWindow *window,
priv->fullscreen_initially = TRUE;
if (priv->surface)
gdk_surface_fullscreen_on_monitor (priv->surface, monitor);
gtk_window_update_toplevel (window);
}
/**
@@ -7928,8 +7956,7 @@ gtk_window_unfullscreen (GtkWindow *window)
unset_fullscreen_monitor (window);
priv->fullscreen_initially = FALSE;
if (priv->surface)
gdk_surface_unfullscreen (priv->surface);
gtk_window_update_toplevel (window);
}
/**
@@ -7970,8 +7997,7 @@ gtk_window_set_keep_above (GtkWindow *window,
priv->above_initially = setting;
priv->below_initially &= !setting;
if (priv->surface)
gdk_surface_set_keep_above (priv->surface, setting);
gtk_window_update_toplevel (window);
}
/**
@@ -8012,8 +8038,7 @@ gtk_window_set_keep_below (GtkWindow *window,
priv->below_initially = setting;
priv->above_initially &= !setting;
if (priv->surface)
gdk_surface_set_keep_below (priv->surface, setting);
gtk_window_update_toplevel (window);
}
/**
@@ -8064,60 +8089,6 @@ gtk_window_get_resizable (GtkWindow *window)
return priv->resizable;
}
/**
* gtk_window_begin_resize_drag:
* @window: a #GtkWindow
* @button: mouse button that initiated the drag
* @edge: position of the resize control
* @x: X position where the user clicked to initiate the drag, in window coordinates
* @y: Y position where the user clicked to initiate the drag
* @timestamp: timestamp from the click event that initiated the drag
*
* Starts resizing a window. This function is used if an application
* has window resizing controls.
*/
void
gtk_window_begin_resize_drag (GtkWindow *window,
GdkSurfaceEdge edge,
gint button,
gint x,
gint y,
guint32 timestamp)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
g_return_if_fail (GTK_IS_WINDOW (window));
g_return_if_fail (gtk_widget_get_visible (GTK_WIDGET (window)));
gdk_surface_begin_resize_drag (priv->surface, edge, button, x, y, timestamp);
}
/**
* gtk_window_begin_move_drag:
* @window: a #GtkWindow
* @button: mouse button that initiated the drag
* @x: X position where the user clicked to initiate the drag, in window coordinates
* @y: Y position where the user clicked to initiate the drag
* @timestamp: timestamp from the click event that initiated the drag
*
* Starts moving a window. This function is used if an application has
* window movement grips.
*/
void
gtk_window_begin_move_drag (GtkWindow *window,
gint button,
gint x,
gint y,
guint32 timestamp)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
g_return_if_fail (GTK_IS_WINDOW (window));
g_return_if_fail (gtk_widget_get_visible (GTK_WIDGET (window)));
gdk_surface_begin_move_drag (priv->surface, button, x, y, timestamp);
}
/**
* gtk_window_set_display:
* @window: a #GtkWindow.
@@ -8795,7 +8766,7 @@ ensure_state_flag_backdrop (GtkWidget *widget)
GtkWindowPrivate *priv = gtk_window_get_instance_private (GTK_WINDOW (widget));
gboolean surface_focused = TRUE;
surface_focused = gdk_surface_get_state (priv->surface) & GDK_SURFACE_STATE_FOCUSED;
surface_focused = gdk_toplevel_get_state (GDK_TOPLEVEL (priv->surface)) & GDK_SURFACE_STATE_FOCUSED;
if (!surface_focused)
gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_BACKDROP, FALSE);

View File

@@ -266,20 +266,6 @@ void gtk_window_set_keep_above (GtkWindow *window, gboolean setting);
GDK_AVAILABLE_IN_ALL
void gtk_window_set_keep_below (GtkWindow *window, gboolean setting);
GDK_AVAILABLE_IN_ALL
void gtk_window_begin_resize_drag (GtkWindow *window,
GdkSurfaceEdge edge,
gint button,
gint x,
gint y,
guint32 timestamp);
GDK_AVAILABLE_IN_ALL
void gtk_window_begin_move_drag (GtkWindow *window,
gint button,
gint x,
gint y,
guint32 timestamp);
/* Set initial default size of the window (does not constrain user
* resize operations)
*/

View File

@@ -99,7 +99,9 @@ on_inspect_widget (GtkInspectorWindow *iw,
{
GtkWidget *widget;
#if 0
gdk_surface_raise (gtk_native_get_surface (GTK_NATIVE (iw)));
#endif
clear_flash (iw);
@@ -122,8 +124,10 @@ reemphasize_window (GtkWidget *window)
gtk_widget_set_opacity (window, 1.0);
gtk_window_set_extra_input_region (GTK_WINDOW (iw), NULL);
}
#if 0
else
gdk_surface_raise (gtk_native_get_surface (GTK_NATIVE (window)));
#endif
}
static gboolean handle_event (GtkInspectorWindow *iw, GdkEvent *event);
@@ -206,8 +210,10 @@ gtk_inspector_on_inspect (GtkWidget *button,
gtk_window_set_extra_input_region (GTK_WINDOW (iw), region);
cairo_region_destroy (region);
}
#if 0
else
gdk_surface_lower (gtk_native_get_surface (GTK_NATIVE (iw)));
#endif
g_signal_connect (iw, "event", G_CALLBACK (handle_event), NULL);
}

View File

@@ -22,21 +22,41 @@
static void
set_fullscreen_monitor_cb (GtkWidget *widget, gpointer user_data)
{
GdkFullscreenMode mode = (GdkFullscreenMode) GPOINTER_TO_INT (user_data);
GdkSurface *window;
GdkFullscreenMode mode = GPOINTER_TO_INT (user_data);
GdkDisplay *display;
GdkSurface *surface;
GdkMonitor *monitor;
GdkToplevelLayout *layout;
window = gtk_native_get_surface (gtk_widget_get_native (widget));
gdk_surface_set_fullscreen_mode (window, mode);
gdk_surface_fullscreen (window);
display = gtk_widget_get_display (widget);
surface = gtk_native_get_surface (gtk_widget_get_native (widget));
if (mode == GDK_FULLSCREEN_ON_CURRENT_MONITOR)
monitor = gdk_display_get_monitor_at_surface (display, surface);
else
monitor = NULL;
layout = gdk_toplevel_layout_new (0, 0, G_MAXINT, G_MAXINT);
gdk_toplevel_layout_set_fullscreen (layout, TRUE, monitor);
gdk_toplevel_present (GDK_TOPLEVEL (surface),
gdk_surface_get_width (surface),
gdk_surface_get_height (surface),
layout);
gdk_toplevel_layout_unref (layout);
}
static void
remove_fullscreen_cb (GtkWidget *widget, gpointer user_data)
{
GdkSurface *window;
GdkSurface *surface;
GdkToplevelLayout *layout;
window = gtk_native_get_surface (gtk_widget_get_native (widget));
gdk_surface_unfullscreen (window);
surface = gtk_native_get_surface (gtk_widget_get_native (widget));
layout = gdk_toplevel_layout_new (0, 0, G_MAXINT, G_MAXINT);
gdk_toplevel_layout_set_fullscreen (layout, FALSE, NULL);
gdk_toplevel_present (GDK_TOPLEVEL (surface),
gdk_surface_get_width (surface),
gdk_surface_get_height (surface),
layout);
gdk_toplevel_layout_unref (layout);
}
int

View File

@@ -4651,7 +4651,6 @@ create_wmhints (GtkWidget *widget)
GtkWidget *button;
GtkWidget *box1;
GtkWidget *box2;
GdkSurface *gdk_surface;
GdkPixbuf *pixbuf;
GdkTexture *texture;
GList *list;
@@ -4671,8 +4670,6 @@ create_wmhints (GtkWidget *widget)
gtk_widget_realize (window);
gdk_surface = gtk_native_get_surface (GTK_NATIVE (window));
pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) openfile);
texture = gdk_texture_new_for_pixbuf (pixbuf);
@@ -4682,11 +4679,6 @@ create_wmhints (GtkWidget *widget)
g_object_unref (texture);
g_object_unref (pixbuf);
gdk_surface_set_icon_name (gdk_surface, "WMHints Test Icon");
gdk_surface_set_decorations (gdk_surface, GDK_DECOR_ALL | GDK_DECOR_MENU);
gdk_surface_set_functions (gdk_surface, GDK_FUNC_ALL | GDK_FUNC_RESIZE);
box1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (window), box1);
gtk_widget_show (box1);
@@ -4736,7 +4728,7 @@ surface_state_callback (GdkSurface *window,
gchar *msg;
GdkSurfaceState new_state;
new_state = gdk_surface_get_state (window);
new_state = gdk_toplevel_get_state (GDK_TOPLEVEL (window));
msg = g_strconcat ((const char *)g_object_get_data (G_OBJECT (label), "title"), ": ",
(new_state & GDK_SURFACE_STATE_WITHDRAWN) ?
"withdrawn" : "not withdrawn", ", ",

View File

@@ -28,7 +28,7 @@ start_resize (GtkGestureClick *gesture,
gtk_widget_translate_coordinates (widget, GTK_WIDGET (gtk_widget_get_root (widget)),
xx, yy, &xx, &yy);
gdk_surface_begin_resize_drag (surface, edge, button, xx, yy, timestamp);
gdk_surface_begin_resize_drag (surface, edge, gdk_event_get_device (event), button, xx, yy, timestamp);
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
}
@@ -76,7 +76,7 @@ start_move (GtkGestureClick *gesture,
gtk_widget_translate_coordinates (widget, GTK_WIDGET (gtk_widget_get_root (widget)),
xx, yy, &xx, &yy);
gdk_surface_begin_move_drag (surface, button, xx, yy, timestamp);
gdk_surface_begin_move_drag (surface, gdk_event_get_device (event), button, xx, yy, timestamp);
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
}