Compare commits

..

177 Commits

Author SHA1 Message Date
Matthias Clasen 865cab3cc6 Add a test for changing content
This is meant to produce lots of widget that all share the
same CSS and size, and frequently change content.
2023-04-30 08:08:31 -04:00
Matthias Clasen bc47cc5970 docs: Migration guide updates
Mention various widget size apis going away.
2023-04-29 16:17:51 -04:00
Matthias Clasen 27c621695e Merge branch 'deprecated-get-allocated-width' into 'main'
Deprecated get allocated width

See merge request GNOME/gtk!5894
2023-04-29 18:55:45 +00:00
Matthias Clasen 1a237ef6a8 Merge branch 'box-baseline-child' into 'main'
boxlayout: Add a baseline child property

See merge request GNOME/gtk!5891
2023-04-29 18:30:59 +00:00
Matthias Clasen e7ba8e7e9a Deprecate gtk_widget_get_allocated_width 2023-04-29 14:30:21 -04:00
Matthias Clasen 14279785e6 tests: Stop using gtk_widget_get_allocated_width 2023-04-29 14:30:21 -04:00
Matthias Clasen 5b6f8d7002 gtk4-demo: Stop using gtk_widget_get_allocated_size 2023-04-29 14:30:21 -04:00
Matthias Clasen 71a752490a popover: Stop using gtk_widget_get_allocated_width 2023-04-29 14:30:21 -04:00
Matthias Clasen 3f4f37661c placesview: Stop using gtk_widget_get_allocated_width 2023-04-29 14:30:21 -04:00
Matthias Clasen 5bc5a6f2cd placessidebar: Stop using gtk_widget_get_allocated_width 2023-04-29 14:30:21 -04:00
Matthias Clasen 1a90724de9 columnview: Stop using gtk_widget_get_allocated_width 2023-04-29 14:30:21 -04:00
Matthias Clasen f8f91095a3 Merge branch 'matthiasc/for-main' into 'main'
widget: Cosmetics

See merge request GNOME/gtk!5892
2023-04-29 18:29:14 +00:00
Benjamin Otte 6cc1548c5f Merge branch 'wip/carlosg/x11-artifacts' into 'main'
gdk/x11: Invalidate whole surface after size change

See merge request GNOME/gtk!5857
2023-04-29 18:11:21 +00:00
Matthias Clasen 30b12ff890 docs: Mention baselines
Add a paragraph about baselines to the coordinates overview.
2023-04-29 13:48:03 -04:00
Matthias Clasen b9931e9573 widget: Cosmetics
Rename allocated_size_baseline to allocated_baseline,
to match better with the other allocated_ fields.
2023-04-29 13:47:51 -04:00
Matthias Clasen cab8981c57 spinbutton: Use GtkBoxLayout:baseline-child
This makes it so that vertical spin buttons are
properly aligned to the baseline.
2023-04-29 13:28:55 -04:00
Matthias Clasen b6786b8a49 Revert "spinbutton: Use a grid layout"
This reverts commit d648a7721e.
2023-04-29 13:28:55 -04:00
Matthias Clasen 2d9ae241d5 boxlayout: Add a baseline child property
In horizontal layout, we line up the baselines of all children to find
how much space we need above and below the box baseline.

In vertical layout, we need to pick one child to inherit the baseline
from, which is what the new GtkBoxLayout:baseline-child property is
about. It is the equivalent of GtkGridLayout:baseline-row.
2023-04-29 13:28:55 -04:00
Daniel Boles a24a924a6b EventController: Fix type "even propagation"→event 2023-04-29 18:12:30 +01:00
Matthias Clasen 825eb93509 Remove more debug spew 2023-04-29 11:46:16 -04:00
Matthias Clasen a8a0850b64 Merge branch 'matthiasc/for-main' into 'main'
entry: Ignore the baseline when centering

See merge request GNOME/gtk!5889
2023-04-29 14:16:42 +00:00
Matthias Clasen 03f388d099 widget: Don't set baselines when unused
When we are not doing baseline alignment, don't pass
a baseline to the allocated widget. This helps because
a number of widgets (GtkLabel, GtkEntry, etc) always
position their text on the given baseline.
2023-04-29 09:52:34 -04:00
Matthias Clasen 92205744d2 entry: Ignore the baseline when centering
GtkEntry was always placing its text on the baseline,
even when the valign said something else.
2023-04-29 09:52:34 -04:00
Matthias Clasen f6f3a78dd9 Merge branch 'matthiasc/for-main' into 'main'
theme: Reinstate switch labels in hc

See merge request GNOME/gtk!5888
2023-04-29 12:27:23 +00:00
Matthias Clasen 76698e5de8 testbaseline2: Don't set height-requests
Widget with height requests have their baselines
ignored. Oops.
2023-04-29 08:01:11 -04:00
Matthias Clasen 21260e8ed4 theme: Reinstate switch labels in hc
Since we show them in GNOME shell, show them here too.

The comment that says "only show these in the a11y
theme" was still there, but we were always hiding them.
2023-04-29 08:01:03 -04:00
Carlos Garnacho 24302315fb gdk/x11: Invalidate whole surface after size change
The Expose events following a ConfigureNotify may arrive at
a time that we did not resize the surface yet, making these
expose events a no-op. Even though gsk/gtk take care of the
window content itself, this might lead to unrendered portions
of the window shadow.

This may be seen with GSK_RENDERER=cairo and GDK_BACKEND=x11,
attempting to tile a window (e.g. gtk4-demo) left or right.
The window will show black rectangles or other artifacts in
the window shadow areas that correspond to the newly painted
portions (as the window needs to expand vertically).

In order to fix this with a similar behavior to Wayland,
consider ourselves the whole surface invalidated after resize,
in order to ensure everything is painted from scratch.
2023-04-29 11:51:32 +02:00
Fabio Tomat fc9642ce2a Update Friulian translation 2023-04-29 08:57:53 +00:00
Benjamin Otte c542351a73 Merge branch 'wip/otte/for-main' into 'main'
wayland: Use wl_surface_damage_buffer() in Cairo

See merge request GNOME/gtk!5886
2023-04-29 03:43:45 +00:00
Benjamin Otte 3198330188 rendernode: Add diffing for affine transforms
This will be needed most importantly for inverted textures,
like in GLArea.
2023-04-29 05:10:51 +02:00
Benjamin Otte 11aaa29a69 wayland: Use wl_surface_damage_buffer() in Cairo
... when it is available.

Also introduce the new function gdk_rectangle_transform_affine(), which
looks like overkill for this purpose, but I'm about to use it elsewhere.
2023-04-29 05:07:03 +02:00
Matthias Clasen d1a25178fd Merge branch 'matthiasc/for-main' into 'main'
shortcutswindow: Avoid criticals

See merge request GNOME/gtk!5885
2023-04-29 01:15:58 +00:00
Matthias Clasen 092745161c shortcutswindow: Avoid criticals
No point in resetting accessible relations
when we are in finalize.
2023-04-28 20:44:18 -04:00
Matthias Clasen 0da4a92298 Merge branch 'clarify-swapped-default-object-signal' into 'main'
builder: Clarify default "swapped" value when "object" is set for signals

See merge request GNOME/gtk!4514
2023-04-28 23:00:31 +00:00
Matthias Clasen 8b816d3b03 Merge branch 'gtkshortcutswindow_a11y' into 'main'
GtkShortcutsWindow: Allow a screen reader user to browse the available shortcuts

See merge request GNOME/gtk!5042
2023-04-28 22:57:10 +00:00
Matthias Clasen 63b50f48a9 Merge branch 'harmonize-would_drop' into 'main'
Harmonize would_drop() replacement for g_log_writer_default_would_drop()

See merge request GNOME/gtk!4935
2023-04-28 22:55:42 +00:00
Matthias Clasen 8b91762c42 Merge branch 'deprecate-get-allocation' into 'main'
Deprecate get allocation

See merge request GNOME/gtk!5882
2023-04-28 22:49:42 +00:00
Matthias Clasen 01f39d8522 README: Updates
Drop the section that talked about main and how to update
local checkouts - its been 2 years, people should have gotten
around to it by now. Add some general git hints instead.
2023-04-28 17:31:12 -04:00
Benjamin Otte e94416054c Merge branch 'wip/otte/for-main' into 'main'
Fix hangs on Wayland

Closes #5761

See merge request GNOME/gtk!5884
2023-04-28 21:22:12 +00:00
Benjamin Otte b4c859c011 wayland: Set EGL swap interval to 0.
There's no need for EGL to do any timing, we do it in GTK already.

This fixes hangs in Mesa when we hide a surface after a SwapBuffers()
but before the frame callback arrives.
If we then reshow the surface and immediately render to it, Mesa would
still have a frame callback from before the hiding and forever poll()
waiting for the compositor to send the callback.

Fixes #5761
2023-04-28 22:40:39 +02:00
Benjamin Otte 45216e1c88 wayland: Disconnect the frame callback when hiding
Do not leave spurious frame callbacks around wen hiding surfaces.
Instead, store the callback and remove it.
2023-04-28 22:21:42 +02:00
Daniel Boles 7bea2685e1 migrating-3to4: Don't mention removed Box method &
donʼt mention its renamed successor either, as that has its own section
later. We could have another sentence paragraph like ‘In the case of
GtkBox, the pack methods have been renamed to X and lost the trailing
arguments Y’, but that wonʼt help people prepare still on GTK3, which is
the point in the affected section… so just remove the misleading relic.
2023-04-28 21:14:37 +01:00
Matthias Clasen b7d1774c56 Merge branch 'matthiasc/for-main' into 'main'
Cosmetics

See merge request GNOME/gtk!5883
2023-04-28 20:09:17 +00:00
Matthias Clasen 3afd91ea06 Updates 2023-04-28 16:02:18 -04:00
Matthias Clasen d7dd6ca552 Cosmetics 2023-04-28 15:36:37 -04:00
Matthias Clasen 9c40e8b873 Deprecate gtk_widget_get_allocated_baseline 2023-04-28 15:26:16 -04:00
Matthias Clasen b201d66981 Stop using gtk_widget_get_allocated_baseline
Use gtk_widget_get_baseline instead.
2023-04-28 15:25:58 -04:00
Matthias Clasen 3ea289751d Add gtk_widget_get_baseline
This is just a renaming of gtk_widget_get_allocated_baseline
that fits better with gtk_widget_get_width/height.
2023-04-28 15:18:13 -04:00
Matthias Clasen 8205c7032a Deprecate gtk_widget_get_allocation 2023-04-28 15:05:39 -04:00
Matthias Clasen ba379c928b flowbox: Use deprecation guards around get_allocation 2023-04-28 15:05:39 -04:00
Matthias Clasen 5306ef12f4 inspector: Show bounds instead of allocation 2023-04-28 15:05:39 -04:00
Matthias Clasen be62147dee scrolledwindow: Stop using gtk_widget_get_allocation 2023-04-28 15:05:39 -04:00
Matthias Clasen 627ce3d447 textutil: Stop using gtk_widget_get_allocation 2023-04-28 15:05:39 -04:00
Matthias Clasen 79119e64f9 tetview: Stop using gtk_widget_get_allocation 2023-04-28 15:05:39 -04:00
Matthias Clasen 37b2b3cb83 text: Stop using gtk_widget_get_allocation 2023-04-28 15:05:39 -04:00
Boyuan Yang 731c1be9e0 Update Chinese (China) translation 2023-04-28 18:51:56 +00:00
Benjamin Otte 76777cdd18 Merge branch 'wip/otte/texturebuilder' into 'main'
Add GdkGLTextureBuilder

See merge request GNOME/gtk!5862
2023-04-28 15:58:10 +00:00
Matthias Clasen bdec7782b4 Merge branch 'baseline-fixes' into 'main'
boxlayout: Fix baselines a bit

See merge request GNOME/gtk!5879
2023-04-28 14:40:57 +00:00
Matthias Clasen 55f5edffd1 More docs for BASELINE
Add some more details to the docs for GTK_ALIGN_BASELINE.
2023-04-28 09:21:15 -04:00
Matthias Clasen bb961d062a widget: Handle baseline better
When adjusting allocations, treat BASELINE more like CENTER
than like FILL. The results are better, in particular for
controls like entries or switches, which we never want to
scale up vertically, but still want to align to the baseline.
2023-04-28 09:13:49 -04:00
Matthias Clasen 38ffd099eb image: Simplify baseline handling
We guarantee that the out arguments of the measure
vfunc are non-NULL, no need to check.
2023-04-28 09:12:22 -04:00
Matthias Clasen 12af75df9b switch: Fix up baseline handling
We need to report a baseline for baseline alignment
to work...
2023-04-28 08:52:05 -04:00
Matthias Clasen d648a7721e spinbutton: Use a grid layout
A grid layout lets us get the baseline right in
vertical orientation, by setting a baseline row.

It would be nice if the box layout supported this
as well, but currently it doesn't, and adding that
feature isn't trivial.
2023-04-28 08:50:12 -04:00
Matthias Clasen e187587643 boxlayout: Fix baselines a bit
When we are not doing height-for-width, we still
need to line up baselines.
2023-04-28 08:50:12 -04:00
Matthias Clasen 3766f1da8b Add another baseline test client 2023-04-28 08:50:12 -04:00
Matthias Clasen 92a9f8cd7e gldriver: Add a sync when creating textures 2023-04-28 06:23:45 +02:00
Matthias Clasen b9a7e5fa85 gstreamer: Defer the sync
Don't sync right when we receive the buffer,
pass it along with the texture to be executed
later in the renderer.
2023-04-28 06:23:45 +02:00
Matthias Clasen bec0afa61b glarea: Synchronize
Create a fence object and pass it along when
creating the GL texture, so that the GL renderer
can wait for the texture to be ready.
2023-04-28 06:23:40 +02:00
Matthias Clasen bedc3dba7e filechooser: Plug a memory leak 2023-04-27 13:42:03 +02:00
Matthias Clasen 7c4acac135 Add some more valgrind suppressions 2023-04-27 13:42:03 +02:00
Matthias Clasen 0bb6988c0e columnview: Plug a memory leak
g_list_model_get_item strikes again.
2023-04-27 13:42:03 +02:00
Matthias Clasen df3622b295 filechooser: Plug a memory leak
We own references to the columns. Drop them.
2023-04-27 13:42:03 +02:00
Matthias Clasen df9f3fc694 filechoosernative: Plug a memory leak
Unref all the GVariants.
2023-04-27 13:42:03 +02:00
Matthias Clasen 39b3b2444b filedialog: Plug a memory leak
We own a reference to the native dialog,
and we need to drop it when we're done.
2023-04-27 13:42:03 +02:00
Matthias Clasen c237643b24 node-editor: Plug a memory leak 2023-04-27 13:42:03 +02:00
Matthias Clasen cc682a96d9 notebook: Drop an unused variable 2023-04-27 13:42:03 +02:00
Matthias Clasen 051b463c9a Fix various bitfield warnings
clang rightly complains about using gboolean
as type for bitfields, since it is signed.
Avoid that.
2023-04-27 13:42:03 +02:00
Matthias Clasen 8292b846d5 gsk: Synchronize when using textures
Pass the GLsync object from texture into our
command queue, and when executing the queue,
wait on the sync object the first time we
use its associated texture.
2023-04-27 06:57:02 +02:00
Matthias Clasen 6efaa79e3c gltexture: Synchronize when downloading
If the GL texture has a sync object, wait
on it before downloading the data.
2023-04-27 06:57:02 +02:00
Matthias Clasen 92eb845482 gltexture: Optionally take a sync object
Add a new function to TextureBuilder that takes a GLsync that
requires internal code to wait on before using the texture.

Somewhat sneakily, we don't take the sync if syncs are not supported by
the current GL context.
As public API has no code to query the sync for the destroy notify, this
is fine and it means we don't have to do the check every time we want to
call gdk_texture_get_sync() internally.
2023-04-27 06:55:37 +02:00
Matthias Clasen 5071e6154c glcontext: Add a way to check for GLsync 2023-04-27 06:54:49 +02:00
Benjamin Otte 18a4b2475e gltexture: Deprecate gdk_gl_texture_new()
Use GdkGLTextureBuilder instead.
2023-04-27 06:40:47 +02:00
Benjamin Otte 76e5fd0ece glrenderer: Port to GdkGLTextureBuilder 2023-04-27 06:40:47 +02:00
Benjamin Otte fa44d258d0 media-gstreamer: Port to GdkGLTextureBuilder
This is a rudimentary port that does not take advantage of all the cool
new formats that we could support now.
2023-04-27 06:40:47 +02:00
Benjamin Otte 778979cf0e testsuite: Use GLTextureBuilder 2023-04-27 06:40:47 +02:00
Benjamin Otte 053a4d2e9d glarea: Port to GdkGLTextureBuilder 2023-04-27 06:40:47 +02:00
Benjamin Otte aae7b2c8a8 texturebuilder: Pass the destroy notify to the build() function
This is more compatible with bindings that want to create per-object
callbacks and not have their callbacks reused over different build()
calls.
2023-04-27 06:40:47 +02:00
Benjamin Otte e37fbaf13a texturebuilder: Add ::format and ::has-mipmap
We were trying to deduce that previously. Now we have explicit API
2023-04-27 06:40:47 +02:00
Benjamin Otte e4f4cfaf14 gdk: Add GdkGLTextureBuilder
Building GL textures is complicated, so create an object to make them.

So far, this object just contains the functionality of
gdk_gl_texture_new(), but that will change in the future.
2023-04-27 06:40:47 +02:00
Matthias Clasen 9ae0a3865c Merge branch 'matthiasc/for-main' into 'main'
Fix the build with clang

See merge request GNOME/gtk!5876
2023-04-27 04:37:12 +00:00
Benjamin Otte 3b5a2d60c7 Merge branch 'wip/otte/gl-version' into 'main'
Make sure highest possible version GLContext is created

See merge request GNOME/gtk!5870
2023-04-27 00:39:19 +00:00
Benjamin Otte 9254ab8503 wgl: Improve error messages when GL init fails
In particular, we want to get the GL version, when the Windows box/VM
has an unsuitable GL implementation.

This is somewhat helpful in analyzing failures to bring up GL on
machines where users claim GL does work.
2023-04-27 02:19:25 +02:00
Benjamin Otte d6afcee1e4 wgl: Create context during WGL initialization
This way, we can realize it and either print success information about
it or return NULL if that fails.

This makes it more likely that we fail early, which means we can then
initialize EGL.
2023-04-27 02:16:46 +02:00
Benjamin Otte c71ca481c1 win32: Get rid of display->gl_version
We can just query the display's GL context.

And it's not used otherwise anymore.
2023-04-27 02:13:33 +02:00
Benjamin Otte 8ef38c46b5 win32: Refactor context creation
This refactor achieves the following:

 * check GL version against proper matching context version
   In particular, for legacy contexts, we now actually check
 * make sure the actual version is set, even for legacy contexts
 * make sure set_is_legacy() is set properly
2023-04-27 02:13:33 +02:00
Benjamin Otte 4333d754b8 gdk: Add workaround for Visual Studio
apparently casting something to itself makes it not constant.
2023-04-27 02:13:33 +02:00
Benjamin Otte 9f82d537b0 mac: Properly set GLContext.is_legacy() 2023-04-27 02:13:32 +02:00
Benjamin Otte 7c7a3d67ca glcontext: assert all contexts set the version on realize()
Now that all contexts do that, insist that they keep doing it.

And because they keep doing it, we can support querying the GL version
from gdk_gl_context_get_version() without requiring the context to be
made current.
2023-04-27 02:13:32 +02:00
Benjamin Otte d33b82249b mac: Try all different OpenGL profiles
.. and pick the best one that is supported.

Also make sure that the resulting context has at least the desired
version, otherwise bail.
2023-04-27 02:13:32 +02:00
Benjamin Otte 5f833f1d31 glcontext: Compute matching version the simple way
Do it all in one function instead of requiring two different ones.
2023-04-27 02:13:32 +02:00
Benjamin Otte b8958419e6 win32: Make sure highest possible GL version is created
Mirror EGL here.
2023-04-27 02:13:32 +02:00
Benjamin Otte 919c90182f win32: Pass the version properly through the creation stack
We were using major/minor instead of GdkGLVersion.

And we were resetting back to 0 and ignoring the required min version
which we should not do.
2023-04-27 02:13:32 +02:00
Benjamin Otte ab2a548479 glx: Make sure highest possible GL version is created
Mirror EGL here.
2023-04-27 02:13:32 +02:00
Benjamin Otte 34662fc4b0 egl: Make sure highest possible GL version is created
The EGL spec states:

    The context returned must be the specified version, or a later
    version which is backwards compatible with that version.
    Even if a later version is returned, the specified version
    must correspond to a defined version of the client API.

GTK has so far been relying on EGL implementations returning a
later version, because that is what Mesa does.
But ANGLE does not do that and only provides the minimum version, which
means Windows EGL has been forced to use a lower EGL version for no
reason.

So fix this and try versions in order from highest to lowest.
2023-04-27 02:13:32 +02:00
Benjamin Otte 5b376cedcf gdk: Move GdkGLAPI enum into gdkenums.h 2023-04-27 02:13:32 +02:00
Benjamin Otte 3aefed39b1 glcontext: Use GdkGLVersion elsewhere
... and add a convenience API to generate GL versions from strings to
make the gdk_gl_context_check() API nicer.
2023-04-27 02:13:32 +02:00
Benjamin Otte f86429177a gdk: Introduce GdkGLVersion
... and use it.

Makes the code simpler.
2023-04-27 02:13:32 +02:00
Benjamin Otte dacfed3e11 win32: Remove an outdated check
We require GL 3.0, so checking for less than 2.0 makes no sense anymore.
2023-04-27 02:13:32 +02:00
Matthias Clasen 8fb2ee7d67 Fix a crash
Fix an oversight from c87b193d2a.
2023-04-27 00:09:18 +02:00
Benjamin Otte 29e7186829 Merge branch 'wip/otte/treelistmodel-madness' into 'main'
treelistmodel: Be safer during collapsing

See merge request GNOME/gtk!5875
2023-04-26 22:06:40 +00:00
Matthias Clasen 951e3b3d6b Fix the build with clang
This broke our macos ci.
2023-04-26 23:54:43 +02:00
Benjamin Otte 3c76f3fb58 treelistmodel: Delay notifies from TreeListRow
Don't notify during destruction, notify afterwards.
This way we don't call into user code from a half-destructed node.

Note that this changes the order in which those notifies happen when
collapsing a large tree: From parent node before child nodes to child
nodes before parent node.

No actual use case for this, just thought it would be safer.
2023-04-26 23:40:56 +02:00
Benjamin Otte 8766a6fab2 treelistmodel: Be safer during collapsing
While we are collapsing a subtree, some signal handlers may not be
disconnected while we are doing this. By adding this check and not
giving those nodes no longer access to the model, we can stop it from
modifying it while we are trying to collapse stuff.

Fixes some crashes in gnome-builder.
2023-04-26 23:30:37 +02:00
Benjamin Otte f52975c220 Merge branch 'wip/otte/surface-surgery' into 'main'
refactor internal surface API

See merge request GNOME/gtk!5846
2023-04-26 21:03:24 +00:00
Daniel Boles abd4a57031 3to4: Fix we said we replace doubles with doubles,
when what we are replacing are ints!
2023-04-26 21:30:10 +01:00
Benjamin Otte 9d0448756f display: Remove ::create_surface() vfunc
Instead, have a toplevel_type and popup_type in GdkDisplay and
call g_object_new() with those types.
2023-04-26 21:03:34 +02:00
Benjamin Otte 03d7ce3287 wayland: Set default title in toplevel_init() 2023-04-26 21:03:34 +02:00
Benjamin Otte f2083d36a1 macos: Add surface from ::constructed() 2023-04-26 21:03:34 +02:00
Benjamin Otte cb642bec25 gdk: Remove GDK_SURFACE_DRAG enum member
I want to remove the whole enum, but this value was used all over the
place. So removing it first ensures I didn't forget anything.
2023-04-26 21:03:34 +02:00
Benjamin Otte 8c530264f7 wayland: Create drag surface directly
... instead of going through create_surface().
2023-04-26 21:03:34 +02:00
Benjamin Otte d99042dd91 wayland: Remove struct member
It's unused.
2023-04-26 21:03:34 +02:00
Benjamin Otte 486196c979 x11: Add private gdk_x11_drag_surface_new()
... and use it.
2023-04-26 21:03:34 +02:00
Benjamin Otte 83faacabe3 x11: Set frame clock in ::constructed 2023-04-26 21:03:34 +02:00
Benjamin Otte 31aae62f9a x11: Move window construction to ::constructed() 2023-04-26 21:03:34 +02:00
Benjamin Otte 726be8e2b2 broadway: Create gdk_broadway_drag_surface_new()
... and use it.
2023-04-26 21:03:34 +02:00
Benjamin Otte ab0fa08d8e win32: Create gdk_win32_draw_surface_new()
... and use it.
2023-04-26 21:03:34 +02:00
Benjamin Otte 42cea18f3e macos: Set frame clock in ::constructed 2023-04-26 21:03:34 +02:00
Benjamin Otte 44e54e1b4c broadway: Set frame clock in ::constructed
... instead of passing it to g_object_new().
2023-04-26 21:03:34 +02:00
Benjamin Otte a79ae95e7e broadway: Move surface init code into ::constructed() 2023-04-26 21:03:34 +02:00
Benjamin Otte 77fe9116af win32: Set frame clock in constructed()
... instead of passing it as construct argument.
2023-04-26 21:03:34 +02:00
Benjamin Otte 808cde74be wayland: Construct the frame clock in the surface
... instead of passing it to g_object_new().
2023-04-26 21:03:34 +02:00
Benjamin Otte 13120ccf9d surface: Make gdk_surface_set_frame_clock() available
... to backends.

That way, frame clocks can be constructed by the backends' surface
implementations and dont need to be passed in as construct arguments.

Also add an assertion that they are indeed constructed.
2023-04-26 21:03:34 +02:00
Benjamin Otte a306401023 macos: Move native window creation to ::constructed()
That way, it doesn't need a specific init function.

Also chain up last, so that the generic initialization code in
GdkSurface::constructed can access a fully initialized macos surface.
2023-04-26 21:03:34 +02:00
Benjamin Otte 7e18a1cea7 macos: Don't pass sizes to macos_surface_new()
They're 0, 0, 100, 100 always, so just use those values everywhere.
2023-04-26 21:03:34 +02:00
Benjamin Otte 9a6e6be785 macos: Create drag surface directly
Do not go via macos_surface_new().
2023-04-26 21:03:34 +02:00
Benjamin Otte 093a4e83d5 macos: Move construction stuff into ::constructed 2023-04-26 21:03:34 +02:00
Benjamin Otte 428798b53f macos: toplevels have no parent 2023-04-26 21:03:34 +02:00
Benjamin Otte 4fa81cf70f win32: Move surface init code into ::constructed() 2023-04-26 21:03:34 +02:00
Benjamin Otte 9ac31fe0a0 win32: Abort on error
Returning NULL from a function that must not return NULL is not a good
idea.
2023-04-26 21:03:34 +02:00
Benjamin Otte 69fabb3ce9 win32: Remove outdated debug messages
They are not needed anymore as they print stuff that's no decided in
that function anymore.
2023-04-26 21:03:34 +02:00
Benjamin Otte f59c230a96 win32: Move toplevel signal into the toplevel class 2023-04-26 21:03:34 +02:00
Benjamin Otte 80d99b893e broadway: Pass parent as a construct argument 2023-04-26 21:03:34 +02:00
Benjamin Otte cbe89b955a x11: Get rid of sizes when constructing surfaces
Just call XCreateWindow with 0, 0, 1, 1 size.
2023-04-26 21:03:34 +02:00
Benjamin Otte 2d827978a6 x11: Remove unused variable 2023-04-26 21:03:34 +02:00
Benjamin Otte b2e304189e wayland: Move surface initialization into constructed()
That way, it doesn't ned a specific init function.

Also chain up last, so that the generic initialization code can access a
fully initialized wayland surface.
2023-04-26 21:03:34 +02:00
Benjamin Otte 35c2d85468 wayland: Move toplevel-specific code into the toplevel
The display->toplevels tracking belongs to GdkWAylandToplevel.
2023-04-26 21:03:34 +02:00
Benjamin Otte 7ef5f6ef1a display: Remove x/y/w/h from create_surface() 2023-04-26 21:03:34 +02:00
Matthias Clasen 9364da673f Merge branch 'application-signal-cleanup' into 'main'
application: Clean up signal handlers

See merge request GNOME/gtk!5872
2023-04-26 13:11:43 +00:00
Matthias Clasen c87b193d2a application: Clean up signal handlers
This is the right thing to do and might help for #5775.
2023-04-26 14:15:31 +02:00
Matthias Clasen 045ab0f107 Merge branch 'win32-warnings' into 'main'
Fix some win32 warnings

See merge request GNOME/gtk!5868
2023-04-26 06:58:09 +00:00
Matthias Clasen 27d9023ac8 Merge branch 'pathbar-webdav-root' into 'main'
pathbar: Handle webdav where is the root is a path

Closes #2866

See merge request GNOME/gtk!5830
2023-04-26 06:50:10 +00:00
Matthias Clasen 8a82e1b8b4 Merge branch 'matthiasc/for-main' into 'main'
gsk: Don't misuse bitwise operators

See merge request GNOME/gtk!5869
2023-04-26 06:49:32 +00:00
Matthias Clasen 8e695f7c56 Merge branch 'modelbutton-no-click-outside' into 'main'
gtkmodelbutton: Ignore releases outside of the button

Closes #5760

See merge request GNOME/gtk!5852
2023-04-26 05:56:31 +00:00
Fran Dieguez 1f886668ce Update Galician translation
(cherry picked from commit 7470bc01f2)
2023-04-25 23:22:28 +00:00
Sebastian Keller a678e9fdd9 gtkmodelbutton: Ignore releases outside of the button
This is also how regular buttons behave. Otherwise releasing on a
different menu item would register a click on the item that was
originally pressed. In these cases it is better to not register a click
at all.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5760
2023-04-25 19:28:42 +02:00
Matthias Clasen 74c0171edf gsk: Don't misuse bitwise operators
We should use && for booleans, not &=.
2023-04-25 16:43:02 +02:00
Matthias Clasen 248d13d8dc Merge branch 'matthiasc/for-main' into 'main'
gsk: Don't misuse bitwise operators

See merge request GNOME/gtk!5867
2023-04-25 12:48:13 +00:00
Marc-André Lureau 2d11d3f8d3 gtk/win32: fix usage of deprecated function
[106/939] Compiling C object gtk/libgtk.a.p/gtkimcontextime.c.obj
../gtk/gtkimcontextime.c: In function 'gtk_im_context_ime_set_preedit_font':
../gtk/gtkimcontextime.c:780:3: warning: 'gtk_widget_get_style_context' is deprecated [-Wdeprecated-declarations]
  780 |   font_desc = gtk_css_style_get_pango_font (gtk_style_context_lookup_style (gtk_widget_get_style_context (context_ime->client_widget)));

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-04-25 16:37:58 +04:00
Marc-André Lureau ff9cd989c6 gdk/win32: fix defined but not used warnings
[30/1038] Compiling C object gdk/win32/libgdk-win32.a.p/gdkmain-win32.c.obj
../gdk/win32/gdkmain-win32.c:146:1: warning: 'gdk_win32_finalize_ole' defined but not used [-Wunused-function]
  146 | gdk_win32_finalize_ole (void)
      | ^~~~~~~~~~~~~~~~~~~~~~
../gdk/win32/gdkmain-win32.c:113:1: warning: 'gdk_win32_finalize_com' defined but not used [-Wunused-function]
  113 | gdk_win32_finalize_com (void)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-04-25 16:37:58 +04:00
Marc-André Lureau 5b69df96fe gdk/win32: fix hr set but not used
A number of warnings are produced:

[23/1038] Compiling C object gdk/win32/libgdk-win32.a.p/gdkinput-dmanipulation.c.obj
../gdk/win32/gdkinput-dmanipulation.c: In function 'reset_viewport':
../gdk/win32/gdkinput-dmanipulation.c:354:11: warning: variable 'hr' set but not used [-Wunused-but-set-variable]
  354 |   HRESULT hr;
      |           ^~

Try to do something sensible instead.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-04-25 16:37:58 +04:00
Marc-André Lureau d8ead56b9c gdk/win32: fix g_string_free warning
../gdk/win32/gdkclipdrop-win32.c: In function 'transmute_cf_shell_id_list_to_text_uri_list':
C:/msys64/ucrt64/include/glib-2.0/glib/gstring.h:72:5: warning: ignoring return value of 'g_string_free_and_steal' declared with attribute 'warn_unused_result' [-Wunused-result]

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-04-25 16:14:57 +04:00
Marc-André Lureau 0e2d7111eb gdk/win32: fix GDK_NOTE redefined warning
In file included from ../gdk/win32/gdkdrag-win32.c:201:
../gdk/win32/gdkprivate-win32.h:45: warning: "GDK_NOTE" redefined
   45 | #define GDK_NOTE(type,action)                             \
      |
../gdk/win32/gdkdrag-win32.c:40: note: this is the location of the previous definition
   40 | #define GDK_NOTE(a,b)

Fixes: bc159207bd ("gdk: Drop old debug macros")

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-04-25 16:11:11 +04:00
Matthias Clasen 2263db6259 gsk: Don't misuse bitwise operators
We should use || for booleans, not |=.
2023-04-25 13:45:37 +02:00
Matthias Clasen ec318e911c Merge branch 'label_get_active_uri' into 'main'
Fix hovered link URI not returned by gtk_label_get_current_uri

See merge request GNOME/gtk!5864
2023-04-25 11:22:34 +00:00
Matthias Clasen ed69435a1b Merge branch 'icontheme-has-icon-consistency' into 'main'
icontheme: make has_(g)icon consistent with lookup

Closes #5709

See merge request GNOME/gtk!5865
2023-04-25 07:49:12 +00:00
Matthias Clasen e111f688c2 Merge branch 'null-display' into 'main'
gdkdisplaymanager: Add missing nullable to display name

See merge request GNOME/gtk!5866
2023-04-25 07:46:21 +00:00
Takao Fujiwara 26e3824d1d gdkdisplaymanager: Add missing nullable to display name 2023-04-25 12:08:08 +09:00
velsinki e20a5e1bc1 icontheme: make has_(g)icon consistent with lookup
Make `gtk_icon_theme_has_icon` and `gtk_icon_theme_has_gicon` also
consider unthemed icons. This makes their behavior consistent with the
actual (documented) lookup behavior.

Fixes: #5709 and makes the workaround in nautilus@b643a00b obsolete
2023-04-24 23:38:20 +02:00
Chris Mayo 66cfeb3ad1 Fix hovered link URI not returned by gtk_label_get_current_uri
This is needed for a query-tooltip handler, as mentioned in the
documentation, when there has been a hover timeout.

Maintain the previous behaviour when the link is clicked and follow the
existing documentation regarding selectable labels.

A notify::cursor handler can now also be used to retrieve the URI of the
link under the cursor.
2023-04-24 19:35:47 +01:00
Matthias Clasen 63d7756658 Merge branch 'ebassi/button-can-shrink' into 'main'
Add GtkButton:can-shrink

See merge request GNOME/gtk!5552
2023-04-24 12:28:12 +00:00
Emmanuele Bassi e28676869e Add GtkMenuButton:can-shrink
Map the GtkMenuButton property to the underlying GtkButton widget.
2023-04-24 11:09:01 +01:00
Sabri Ünal fabfc1eefa Update Turkish translation 2023-04-23 21:12:44 +00:00
Emmanuele Bassi 4ea818fee6 Add GtkButton:can-shrink
For certain kinds of layouts, especially ones where one or both sizes of
a top level is constrained by physical limits, it's acceptable to have
buttons that rely on the minimum size of their contents, rather than the
natural size. It is left to the application authors, or the localization
teams, to ensure that things like translations and font sizes do not
result in a broken UI.
2023-04-14 15:00:07 +01:00
Olivier Crête c271cd1a3f pathbar: Handle webdav where is the root is a path
Our webdav server has a root which is davs://mynextcloud/remote.php/webdav
When once creates a GFile out of or out of a subdirectory, and one call
g_file_get_parent(), it recurses too far up and try to query
davs://mynextcloud/remote.php which fails, resulting in a broken pathbar.

To fix that, before querying the metadata of each element of the path,
I query the "enclosing mount", then use it's root to compare the GFile
against.

With the right GMount, we can also fix the icon drawing code in the
pathbar for network drives.
2023-04-13 17:54:57 -06:00
Lukáš Tyrychtr 33e5d2c307 GtkShortcutsWindow: Allow a screen reader user to browse the available shortcuts
That required making the shortcuts focusable and with a meaningful
accessibility labels.
2022-09-21 15:34:17 +02:00
Hannes Müller f23c124af2 Harmonize would_drop() replacement for g_log_writer_default_would_drop()
Reuse a better to read would_drop() from ./testsuite/reftests/gtk-reftest.c
in ./tools/gtk-builder-tool.c

Fixed wrong indentation in ./testsuite/reftests/gtk-reftest.c
2022-08-08 20:12:50 +02:00
vanadiae b4b185d53d builder: Clarify default "swapped" value when "object" is set for signals
I encountered this issue where I casted user_data to my self type, but it
showed me they were actually swapped when I set the "object" signal attribute.
After checking the source code which confirms this, it is a good idea to
properly document that convenient behaviour.
2022-02-24 23:04:20 +01:00
132 changed files with 5255 additions and 5153 deletions
+68
View File
@@ -1,6 +1,74 @@
Overview of Changes in 4.11.2, xx-xx-xxxx
=========================================
* GtkGLArea:
- Add an allowed-apis property
* GtkListBox:
- Fix a problem with gtk_list_box_remove_all
* GtkCenterBox:
- Add a shrink-center-last property
* GtkButton, GtkMenuButton:
- Add a can-shrink property
* GtkPopover:
- Fix problems with grabs
* GtkFileChooser:
- Fix a problem with removing files
- Make the date, time and location columns work
- Fix filtering in the save entry popup
- A few memory leak fixes
- Handle webdav in the pathbar
* Dialogs:
- Destroy windows promptly when the async callback finishes
- Detect absence of the OpenURI portal and fall back
* Theme:
- Add explicit style classes to a number of widgets
- Fix some contrast issues in the dark theme
* Accessibility:
- Fix alert dialogs in the a11y tree
* Layout:
- Some fixes to baseline alignment
* GL:
- Add GdkGLTextureBuilder, a more flexible api for creating textures
- Ensure that we work with GLES 2
* Vulkan:
- More fixes to the experimental Vulkan renderer
- Rework glyph caching
* Wayland:
- Don't destroy wl_surfaces on hide
- Plug leaks of compositor-side resources
* Inspector:
- Improve the action list
- Fix a crash
* Tools:
- gtk4-node-editor: Improve scaling
- gtk4-node-editor: Preserve aspect ratio of textures
- gtk4-demo: Make the stylus demo work with mice
* Translation updates
Bulgarian
Chinese (China)
Galician
Hebrew
Polish
Portuguese
Russian
Turkish
Overview of Changes in 4.11.1, 03-04-2023
=========================================
+5 -12
View File
@@ -116,19 +116,12 @@ docs/reference/gtk/html/gtk-building.html
Or [online](https://docs.gtk.org/gtk4/building.html)
Default branch renamed to `main`
--------------------------------
Building from git
-----------------
The default development branch of GTK has been renamed to `main`.
To update your local checkout, use:
```sh
git checkout master
git branch -m master main
git fetch
git branch --unset-upstream
git branch -u origin/main
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
```
The GTK sources are hosted on [gitlab.gnome.org](http://gitlab.gnome.org). The main
development branch is called `main`, and stable branches are named after their minor
version, for example `gtk-4-10`.
How to report bugs
------------------
+10 -4
View File
@@ -109,15 +109,21 @@ static void
apply_transform (CanvasItem *item)
{
GskTransform *transform;
graphene_rect_t bounds;
double x, y;
x = gtk_widget_get_allocated_width (item->label) / 2.0;
y = gtk_widget_get_allocated_height (item->label) / 2.0;
item->r = sqrt (x*x + y*y);
/* Add css padding and margin */
if (!gtk_widget_compute_bounds (item->label, item->label, &bounds))
return;
x = bounds.size.width / 2.;
y = bounds.size.height / 2.;
item->r = sqrt (x * x + y * y);
transform = gsk_transform_translate (NULL, &(graphene_point_t) { item->r, item->r });
transform = gsk_transform_rotate (transform, item->angle + item->delta);
transform = gsk_transform_translate (transform, &(graphene_point_t) { -x, -y });
transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (-x, -y));
gtk_fixed_set_child_transform (GTK_FIXED (item->fixed), item->label, transform);
gsk_transform_unref (transform);
+6 -6
View File
@@ -42,8 +42,8 @@ val_to_xy (GtkFontPlane *plane,
double u, v;
int width, height;
width = gtk_widget_get_allocated_width (GTK_WIDGET (plane));
height = gtk_widget_get_allocated_height (GTK_WIDGET (plane));
width = gtk_widget_get_width (GTK_WIDGET (plane));
height = gtk_widget_get_height (GTK_WIDGET (plane));
u = adjustment_get_normalized_value (plane->width_adj);
v = adjustment_get_normalized_value (plane->weight_adj);
@@ -62,8 +62,8 @@ plane_snapshot (GtkWidget *widget,
cairo_t *cr;
val_to_xy (plane, &x, &y);
width = gtk_widget_get_allocated_width (widget);
height = gtk_widget_get_allocated_height (widget);
width = gtk_widget_get_width (widget);
height = gtk_widget_get_height (widget);
cr = gtk_snapshot_append_cairo (snapshot,
&GRAPHENE_RECT_INIT (0, 0, width, height));
@@ -131,8 +131,8 @@ update_value (GtkFontPlane *plane,
GtkWidget *widget = GTK_WIDGET (plane);
double u, v;
u = CLAMP (x * (1.0 / gtk_widget_get_allocated_width (widget)), 0, 1);
v = CLAMP (1 - y * (1.0 / gtk_widget_get_allocated_height (widget)), 0, 1);
u = CLAMP (x * (1.0 / gtk_widget_get_width (widget)), 0, 1);
v = CLAMP (1 - y * (1.0 / gtk_widget_get_height (widget)), 0, 1);
adjustment_set_normalized_value (plane->width_adj, u);
adjustment_set_normalized_value (plane->weight_adj, v);
+1 -1
View File
@@ -471,7 +471,7 @@ suggestion_entry_size_allocate (GtkWidget *widget,
&(GtkAllocation) { width - arrow_nat, 0, arrow_nat, height },
baseline);
gtk_widget_set_size_request (self->popup, gtk_widget_get_allocated_width (GTK_WIDGET (self)), -1);
gtk_widget_set_size_request (self->popup, gtk_widget_get_width (GTK_WIDGET (self)), -1);
gtk_widget_queue_resize (self->popup);
gtk_popover_present (GTK_POPOVER (self->popup));
+2
View File
@@ -78,6 +78,8 @@ gtk_renderer_paintable_paintable_snapshot (GdkPaintable *paintable,
gdk_paintable_snapshot (GDK_PAINTABLE (texture), snapshot, width, height);
g_object_unref (texture);
gsk_render_node_unref (node);
}
static int
+4
View File
@@ -44,6 +44,10 @@ widgets (although most of the time, the transformation will be a simple 2D trans
The transform to go from one widgets coordinate system to another one can be obtained
with [method@Gtk.Widget.compute_transform].
In addition to a size, widgets can optionally have a **_baseline_** to position text on.
Containers such as [class@Gtk.Box] may position their children to match up their baselines.
[method@Gtk.Widget.get_baseline] returns the y position of the baseline in widget coordinates.
When widget APIs expect positions or areas, they need to be expressed in this coordinate
system, typically called **_widget coordinates_**. GTK provides a number of APIs to translate
between different widgets' coordinate systems, such as [method@Gtk.Widget.compute_point]
+3 -3
View File
@@ -258,7 +258,7 @@ Instead of implementing GtkWidget.destroy, you can implement GObject.dispose.
GTK 4 removes `gtk_container_add()` and `gtk_container_remove()`. While there
is not always a replacement for `gtk_container_remove()` in GTK 3, you can
replace many uses of `gtk_container_add()` with equivalent container-specific
APIs such as `gtk_box_pack_start()` or `gtk_grid_attach()`, and thereby reduce
APIs such as `gtk_grid_attach()`, and thereby reduce
the amount of work you have to do at the time of the switch.
### Review your use of icon resources
@@ -402,9 +402,9 @@ is open, use the [property@Gtk.Window:modal] property of the dialog.
### Adapt to coordinate API changes
A number of coordinate APIs in GTK 3 had `double` variants:
A number of coordinate APIs in GTK 3 had variants taking `int` arguments:
`gdk_device_get_surface_at_position()`, `gdk_surface_get_device_position()`.
These have been changed to use doubles, and the `double` variants
These have been changed to use `double` arguments, and the `int` variants
have been removed. Update your code accordingly.
Any APIs that deal with global (or root) coordinates have been
+16
View File
@@ -119,3 +119,19 @@ it no longer has a resize handle for the window.
These are very specialized widgets that should better live with the application
where they are used.
## Widget size api changes
The functions gtk_widget_get_allocated_width() and gtk_widget_get_allocated_height()
are going away. In most cases, [method@Gtk.Widget.get_width] and [method@Gtk.Widget.get_height]
are suitable replacements. Note that the semantics are slightly different though:
the old functions return the size of the CSS border area, while the new functions return
the size of the widgets content area. In places where this difference matters, you can
use `gtk_widget_compute_bounds (widget, widget, &bounds)` instead.
The function gtk_widget_get_allocation() is also going away. It does not have a direct
replacement, but the previously mentioned alternatives can be used for it too.
gtk_widget_translate_coordinates90 has been replaced by [method@Gtk.Widget.compute_point].
The function gtk_widget_get_allocated_baseline() has been renamed to [method@Gtk.Widget.get_baseline].
+2 -1
View File
@@ -477,6 +477,8 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
object_class->dispose = gdk_broadway_display_dispose;
object_class->finalize = gdk_broadway_display_finalize;
display_class->toplevel_type = GDK_TYPE_BROADWAY_TOPLEVEL;
display_class->popup_type = GDK_TYPE_BROADWAY_POPUP;
display_class->cairo_context_type = GDK_TYPE_BROADWAY_CAIRO_CONTEXT;
display_class->get_name = gdk_broadway_display_get_name;
@@ -488,7 +490,6 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
display_class->get_next_serial = gdk_broadway_display_get_next_serial;
display_class->notify_startup_complete = gdk_broadway_display_notify_startup_complete;
display_class->create_surface = _gdk_broadway_display_create_surface;
display_class->get_keymap = _gdk_broadway_display_get_keymap;
display_class->get_monitors = gdk_broadway_display_get_monitors;
-7
View File
@@ -103,13 +103,6 @@ void _gdk_broadway_display_get_default_cursor_size (GdkDisplay *display,
void _gdk_broadway_display_get_maximal_cursor_size (GdkDisplay *display,
guint *width,
guint *height);
GdkSurface * _gdk_broadway_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type,
GdkSurface *parent,
int x,
int y,
int width,
int height);
GdkKeymap* _gdk_broadway_display_get_keymap (GdkDisplay *display);
void _gdk_broadway_display_consume_all_input (GdkDisplay *display);
BroadwayInputMsg * _gdk_broadway_display_block_for_input (GdkDisplay *display,
+148 -163
View File
@@ -47,19 +47,8 @@
#include <stdio.h>
#include <string.h>
/* Forward declarations */
static void gdk_broadway_surface_finalize (GObject *object);
G_DEFINE_TYPE (GdkBroadwaySurface, gdk_broadway_surface, GDK_TYPE_SURFACE)
GType gdk_broadway_toplevel_get_type (void) G_GNUC_CONST;
GType gdk_broadway_popup_get_type (void) G_GNUC_CONST;
GType gdk_broadway_drag_surface_get_type (void) G_GNUC_CONST;
#define GDK_TYPE_BROADWAY_TOPLEVEL (gdk_broadway_toplevel_get_type ())
#define GDK_TYPE_BROADWAY_POPUP (gdk_broadway_popup_get_type ())
#define GDK_TYPE_BROADWAY_DRAG_SURFACE (gdk_broadway_drag_surface_get_type ())
/* We need to flush in an idle rather than AFTER_PAINT, as the clock
is frozen during e.g. surface resizes so the paint will not happen
and the surface resize request is never flushed. */
@@ -74,6 +63,93 @@ gdk_broadway_surface_init (GdkBroadwaySurface *impl)
{
}
static void
on_frame_clock_after_paint (GdkFrameClock *clock,
GdkSurface *surface)
{
GdkDisplay *display = gdk_surface_get_display (surface);
GdkBroadwaySurface *impl = GDK_BROADWAY_SURFACE (surface);
GdkBroadwayDisplay *broadway_display;
impl->pending_frame_counter = gdk_frame_clock_get_frame_counter (clock);
gdk_surface_freeze_updates (surface);
broadway_display = GDK_BROADWAY_DISPLAY (display);
_gdk_broadway_server_roundtrip (broadway_display->server, impl->id, _gdk_display_get_next_serial (display));
gdk_display_flush (display);
}
static void
on_frame_clock_before_paint (GdkFrameClock *clock,
GdkSurface *surface)
{
GdkFrameTimings *timings = gdk_frame_clock_get_current_timings (clock);
gint64 presentation_time;
gint64 refresh_interval;
if (surface->update_freeze_count > 0)
return;
gdk_frame_clock_get_refresh_info (clock,
timings->frame_time,
&refresh_interval, &presentation_time);
if (presentation_time != 0)
{
timings->predicted_presentation_time = presentation_time + refresh_interval;
}
else
{
timings->predicted_presentation_time = timings->frame_time + refresh_interval / 2 + refresh_interval;
}
}
static void
connect_frame_clock (GdkSurface *surface)
{
GdkFrameClock *frame_clock = gdk_surface_get_frame_clock (surface);
g_signal_connect (frame_clock, "before-paint",
G_CALLBACK (on_frame_clock_before_paint), surface);
g_signal_connect (frame_clock, "after-paint",
G_CALLBACK (on_frame_clock_after_paint), surface);
}
static void
disconnect_frame_clock (GdkSurface *surface)
{
GdkFrameClock *frame_clock = gdk_surface_get_frame_clock (surface);
g_signal_handlers_disconnect_by_func (frame_clock,
on_frame_clock_before_paint, surface);
g_signal_handlers_disconnect_by_func (frame_clock,
on_frame_clock_after_paint, surface);
}
static void
gdk_broadway_surface_constructed (GObject *object)
{
GdkBroadwaySurface *self = GDK_BROADWAY_SURFACE (object);
GdkSurface *surface = GDK_SURFACE (object);
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
if (!surface->parent)
broadway_display->toplevels = g_list_prepend (broadway_display->toplevels, self);
self->id = _gdk_broadway_server_new_surface (broadway_display->server,
self->root_x,
self->root_y,
1, 1);
g_hash_table_insert (broadway_display->id_ht, GINT_TO_POINTER (self->id), surface);
g_object_ref (self);
G_OBJECT_CLASS (gdk_broadway_surface_parent_class)->constructed (object);
connect_frame_clock (surface);
}
static void
gdk_broadway_surface_finalize (GObject *object)
{
@@ -143,154 +219,6 @@ _gdk_broadway_roundtrip_notify (GdkSurface *surface,
}
}
static void
on_frame_clock_after_paint (GdkFrameClock *clock,
GdkSurface *surface)
{
GdkDisplay *display = gdk_surface_get_display (surface);
GdkBroadwaySurface *impl = GDK_BROADWAY_SURFACE (surface);
GdkBroadwayDisplay *broadway_display;
impl->pending_frame_counter = gdk_frame_clock_get_frame_counter (clock);
gdk_surface_freeze_updates (surface);
broadway_display = GDK_BROADWAY_DISPLAY (display);
_gdk_broadway_server_roundtrip (broadway_display->server, impl->id, _gdk_display_get_next_serial (display));
gdk_display_flush (display);
}
static void
on_frame_clock_before_paint (GdkFrameClock *clock,
GdkSurface *surface)
{
GdkFrameTimings *timings = gdk_frame_clock_get_current_timings (clock);
gint64 presentation_time;
gint64 refresh_interval;
if (surface->update_freeze_count > 0)
return;
gdk_frame_clock_get_refresh_info (clock,
timings->frame_time,
&refresh_interval, &presentation_time);
if (presentation_time != 0)
{
timings->predicted_presentation_time = presentation_time + refresh_interval;
}
else
{
timings->predicted_presentation_time = timings->frame_time + refresh_interval / 2 + refresh_interval;
}
}
static void
connect_frame_clock (GdkSurface *surface)
{
GdkFrameClock *frame_clock = gdk_surface_get_frame_clock (surface);
g_signal_connect (frame_clock, "before-paint",
G_CALLBACK (on_frame_clock_before_paint), surface);
g_signal_connect (frame_clock, "after-paint",
G_CALLBACK (on_frame_clock_after_paint), surface);
}
static void
disconnect_frame_clock (GdkSurface *surface)
{
GdkFrameClock *frame_clock = gdk_surface_get_frame_clock (surface);
g_signal_handlers_disconnect_by_func (frame_clock,
on_frame_clock_before_paint, surface);
g_signal_handlers_disconnect_by_func (frame_clock,
on_frame_clock_after_paint, surface);
}
GdkSurface *
_gdk_broadway_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type,
GdkSurface *parent,
int x,
int y,
int width,
int height)
{
GdkBroadwayDisplay *broadway_display;
GdkFrameClock *frame_clock;
GdkSurface *surface;
GdkBroadwaySurface *impl;
GType type;
if (parent)
frame_clock = g_object_ref (gdk_surface_get_frame_clock (parent));
else
frame_clock = _gdk_frame_clock_idle_new ();
switch (surface_type)
{
case GDK_SURFACE_TOPLEVEL:
type = GDK_TYPE_BROADWAY_TOPLEVEL;
break;
case GDK_SURFACE_POPUP:
type = GDK_TYPE_BROADWAY_POPUP;
break;
case GDK_SURFACE_DRAG:
type = GDK_TYPE_BROADWAY_DRAG_SURFACE;
break;
default:
g_assert_not_reached ();
break;
}
surface = g_object_new (type,
"display", display,
"frame-clock", frame_clock,
NULL);
g_object_unref (frame_clock);
surface->parent = parent;
surface->x = x;
surface->y = y;
surface->width = width;
surface->height = height;
broadway_display = GDK_BROADWAY_DISPLAY (display);
impl = GDK_BROADWAY_SURFACE (surface);
impl->root_x = x;
impl->root_y = y;
if (parent)
{
impl->root_x += GDK_BROADWAY_SURFACE (parent)->root_x;
impl->root_y += GDK_BROADWAY_SURFACE (parent)->root_y;
}
impl->id = _gdk_broadway_server_new_surface (broadway_display->server,
impl->root_x,
impl->root_y,
surface->width,
surface->height);
g_hash_table_insert (broadway_display->id_ht, GINT_TO_POINTER(impl->id), surface);
g_object_ref (surface);
if (!surface->parent)
broadway_display->toplevels = g_list_prepend (broadway_display->toplevels, impl);
connect_frame_clock (surface);
/* We treat the real parent as a default transient for to get stacking right */
if (parent)
{
impl->transient_for = GDK_BROADWAY_SURFACE (parent)->id;
_gdk_broadway_server_surface_set_transient_for (broadway_display->server, impl->id, impl->transient_for);
}
return surface;
}
static void
_gdk_broadway_surface_destroy (GdkSurface *surface,
gboolean foreign_destroy)
@@ -1097,6 +1025,14 @@ _gdk_broadway_moveresize_configure_done (GdkDisplay *display,
return TRUE;
}
static GdkSurface *
gdk_broadway_drag_surface_new (GdkDisplay *display)
{
return g_object_new (GDK_TYPE_BROADWAY_DRAG_SURFACE,
"display", display,
NULL);
}
static void
create_moveresize_surface (MoveResizeData *mv_resize,
guint32 timestamp)
@@ -1108,11 +1044,9 @@ create_moveresize_surface (MoveResizeData *mv_resize,
g_assert (mv_resize->moveresize_emulation_surface == NULL);
mv_resize->moveresize_emulation_surface =
_gdk_broadway_display_create_surface (mv_resize->display,
GDK_SURFACE_DRAG,
NULL,
-100, -100, 1, 1);
gdk_broadway_drag_surface_new (mv_resize->display);
gdk_broadway_surface_move_resize_internal (mv_resize->moveresize_emulation_surface, TRUE, -100, -100, 1, 1);
gdk_broadway_surface_show (mv_resize->moveresize_emulation_surface, FALSE);
seat = gdk_display_get_default_seat (mv_resize->display);
@@ -1242,6 +1176,7 @@ gdk_broadway_surface_class_init (GdkBroadwaySurfaceClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkSurfaceClass *impl_class = GDK_SURFACE_CLASS (klass);
object_class->constructed = gdk_broadway_surface_constructed;
object_class->finalize = gdk_broadway_surface_finalize;
impl_class->hide = gdk_broadway_surface_hide;
@@ -1279,6 +1214,25 @@ gdk_broadway_popup_init (GdkBroadwayPopup *popup)
{
}
static void
gdk_broadway_popup_constructed (GObject *object)
{
GdkBroadwaySurface *self = GDK_BROADWAY_SURFACE (object);
GdkSurface *surface = GDK_SURFACE (self);
GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (surface));
self->root_x = GDK_BROADWAY_SURFACE (surface->parent)->root_x;
self->root_y = GDK_BROADWAY_SURFACE (surface->parent)->root_y;
gdk_surface_set_frame_clock (surface, gdk_surface_get_frame_clock (surface->parent));
G_OBJECT_CLASS (gdk_broadway_popup_parent_class)->constructed (object);
/* We treat the real parent as a default transient for to get stacking right */
self->transient_for = GDK_BROADWAY_SURFACE (surface->parent)->id;
_gdk_broadway_server_surface_set_transient_for (broadway_display->server, self->id, self->transient_for);
}
static void
gdk_broadway_popup_get_property (GObject *object,
guint prop_id,
@@ -1334,6 +1288,7 @@ gdk_broadway_popup_class_init (GdkBroadwayPopupClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->constructed = gdk_broadway_popup_constructed;
object_class->get_property = gdk_broadway_popup_get_property;
object_class->set_property = gdk_broadway_popup_set_property;
@@ -1404,6 +1359,19 @@ gdk_broadway_toplevel_init (GdkBroadwayToplevel *toplevel)
{
}
static void
gdk_broadway_toplevel_constructed (GObject *object)
{
GdkSurface *surface = GDK_SURFACE (object);
GdkFrameClock *frame_clock;
frame_clock = _gdk_frame_clock_idle_new ();
gdk_surface_set_frame_clock (surface, frame_clock);
g_object_unref (frame_clock);
G_OBJECT_CLASS (gdk_broadway_toplevel_parent_class)->constructed (object);
}
static void
gdk_broadway_toplevel_set_property (GObject *object,
guint prop_id,
@@ -1507,6 +1475,7 @@ gdk_broadway_toplevel_class_init (GdkBroadwayToplevelClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->constructed = gdk_broadway_toplevel_constructed;
object_class->get_property = gdk_broadway_toplevel_get_property;
object_class->set_property = gdk_broadway_toplevel_set_property;
@@ -1667,9 +1636,25 @@ gdk_broadway_drag_surface_init (GdkBroadwayDragSurface *surface)
{
}
static void
gdk_broadway_drag_surface_constructed (GObject *object)
{
GdkSurface *surface = GDK_SURFACE (object);
GdkFrameClock *frame_clock;
frame_clock = _gdk_frame_clock_idle_new ();
gdk_surface_set_frame_clock (surface, frame_clock);
g_object_unref (frame_clock);
G_OBJECT_CLASS (gdk_broadway_drag_surface_parent_class)->constructed (object);
}
static void
gdk_broadway_drag_surface_class_init (GdkBroadwayDragSurfaceClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->constructed = gdk_broadway_drag_surface_constructed;
}
static gboolean
+8
View File
@@ -32,6 +32,14 @@ G_BEGIN_DECLS
/* Surface implementation for Broadway
*/
GType gdk_broadway_toplevel_get_type (void) G_GNUC_CONST;
GType gdk_broadway_popup_get_type (void) G_GNUC_CONST;
GType gdk_broadway_drag_surface_get_type (void) G_GNUC_CONST;
#define GDK_TYPE_BROADWAY_TOPLEVEL (gdk_broadway_toplevel_get_type ())
#define GDK_TYPE_BROADWAY_POPUP (gdk_broadway_popup_get_type ())
#define GDK_TYPE_BROADWAY_DRAG_SURFACE (gdk_broadway_drag_surface_get_type ())
struct _GdkBroadwaySurface
{
GdkSurface parent_instance;
-15
View File
@@ -1196,21 +1196,6 @@ _gdk_display_unpause_events (GdkDisplay *display)
display->event_pause_count--;
}
GdkSurface *
gdk_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type,
GdkSurface *parent,
int x,
int y,
int width,
int height)
{
return GDK_DISPLAY_GET_CLASS (display)->create_surface (display,
surface_type,
parent,
x, y, width, height);
}
/*< private >
* gdk_display_get_keymap:
* @display: the `GdkDisplay`
+1 -1
View File
@@ -369,7 +369,7 @@ gdk_display_manager_list_displays (GdkDisplayManager *manager)
/**
* gdk_display_manager_open_display:
* @manager: a `GdkDisplayManager`
* @name: the name of the display to open
* @name: (nullable): the name of the display to open
*
* Opens a display.
*
+3 -16
View File
@@ -114,6 +114,8 @@ struct _GdkDisplayClass
{
GObjectClass parent_class;
GType toplevel_type; /* Type for GdkToplevel, must be set */
GType popup_type; /* Type for GdkPopup, must be set */
GType cairo_context_type; /* type for GdkCairoContext, must be set */
GType vk_context_type; /* type for GdkVulkanContext, must be set if vk_extension_name != NULL */
const char *vk_extension_name; /* Name of required windowing vulkan extension or %NULL (default) if Vulkan isn't supported */
@@ -134,15 +136,7 @@ struct _GdkDisplayClass
const char *startup_id);
const char * (*get_startup_notification_id) (GdkDisplay *display);
GdkSurface * (*create_surface) (GdkDisplay *display,
GdkSurfaceType surface_type,
GdkSurface *parent,
int x,
int y,
int width,
int height);
GdkKeymap * (*get_keymap) (GdkDisplay *display);
GdkKeymap * (*get_keymap) (GdkDisplay *display);
GdkGLContext * (* init_gl) (GdkDisplay *display,
GError **error);
@@ -207,13 +201,6 @@ void _gdk_display_pointer_info_foreach (GdkDisplay *display
gulong _gdk_display_get_next_serial (GdkDisplay *display);
void _gdk_display_pause_events (GdkDisplay *display);
void _gdk_display_unpause_events (GdkDisplay *display);
GdkSurface * gdk_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type,
GdkSurface *parent,
int x,
int y,
int width,
int height);
GdkGLContext * gdk_display_get_gl_context (GdkDisplay *display);
+14
View File
@@ -32,6 +32,20 @@
G_BEGIN_DECLS
/**
* GdkGLAPI:
* @GDK_GL_API_GL: The OpenGL API
* @GDK_GL_API_GLES: The OpenGL ES API
*
* The list of the different APIs that GdkGLContext can potentially support.
*
* Since: 4.6
*/
typedef enum { /*< underscore_name=GDK_GL_API >*/
GDK_GL_API_GL = 1 << 0,
GDK_GL_API_GLES = 1 << 1
} GdkGLAPI;
/* Currently, these are the same values numerically as in the
* X protocol. If you change that, gdksurface-x11.c/gdk_surface_set_geometry_hints()
* will need fixing.
+86 -94
View File
@@ -82,6 +82,7 @@
#include "gdkmemoryformatprivate.h"
#include "gdkmemorytextureprivate.h"
#include "gdkprofilerprivate.h"
#include "gdkglversionprivate.h"
#include "gdkprivate.h"
@@ -99,14 +100,13 @@
#define DEFAULT_ALLOWED_APIS GDK_GL_API_GL | GDK_GL_API_GLES
typedef struct {
int major;
int minor;
int gl_version;
GdkGLVersion required;
GdkGLVersion gl_version;
guint has_khr_debug : 1;
guint use_khr_debug : 1;
guint has_half_float : 1;
guint has_fence_sync : 1;
guint has_sync : 1;
guint has_unpack_subimage : 1;
guint has_debug_output : 1;
guint extensions_checked : 1;
@@ -288,8 +288,11 @@ gdk_gl_context_create_egl_context (GdkGLContext *context,
EGLConfig egl_config;
EGLContext ctx;
EGLint context_attribs[N_EGL_ATTRS], i = 0, flags = 0;
gsize major_idx, minor_idx;
gboolean debug_bit, forward_bit;
int min_major, min_minor, major = 0, minor = 0;
GdkGLVersion version;
const GdkGLVersion* supported_versions;
gsize j;
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
if (!gdk_gl_context_is_api_allowed (context, api, NULL))
@@ -297,11 +300,7 @@ gdk_gl_context_create_egl_context (GdkGLContext *context,
/* We will use the default version matching the context status
* unless the user requested a version which makes sense */
gdk_gl_context_get_matching_version (api, legacy,
&min_major, &min_minor);
gdk_gl_context_get_clipped_version (context,
min_major, min_minor,
&major, &minor);
gdk_gl_context_get_matching_version (context, api, legacy, &version);
if (!eglBindAPI (gdk_api_to_egl_api (api)))
return 0;
@@ -332,9 +331,9 @@ gdk_gl_context_create_egl_context (GdkGLContext *context,
flags &= ~EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
context_attribs[i++] = EGL_CONTEXT_MAJOR_VERSION;
context_attribs[i++] = major;
major_idx = i++;
context_attribs[i++] = EGL_CONTEXT_MINOR_VERSION;
context_attribs[i++] = minor;
minor_idx = i++;
context_attribs[i++] = EGL_CONTEXT_FLAGS_KHR;
context_attribs[i++] = flags;
@@ -343,23 +342,33 @@ gdk_gl_context_create_egl_context (GdkGLContext *context,
GDK_DISPLAY_DEBUG (display, OPENGL,
"Creating EGL context version %d.%d (debug:%s, forward:%s, legacy:%s, es:%s)",
major, minor,
gdk_gl_version_get_major (&version), gdk_gl_version_get_minor (&version),
debug_bit ? "yes" : "no",
forward_bit ? "yes" : "no",
legacy ? "yes" : "no",
api == GDK_GL_API_GLES ? "yes" : "no");
ctx = eglCreateContext (egl_display,
egl_config,
share ? share_priv->egl_context : EGL_NO_CONTEXT,
context_attribs);
supported_versions = gdk_gl_versions_get_for_api (api);
for (j = 0; gdk_gl_version_greater_equal (&supported_versions[j], &version); j++)
{
context_attribs [major_idx] = gdk_gl_version_get_major (&supported_versions[j]);
context_attribs [minor_idx] = gdk_gl_version_get_minor (&supported_versions[j]);
ctx = eglCreateContext (egl_display,
egl_config,
share ? share_priv->egl_context : EGL_NO_CONTEXT,
context_attribs);
if (ctx != NULL)
break;
}
if (ctx == NULL)
return 0;
return 0;
GDK_DISPLAY_DEBUG (display, OPENGL, "Created EGL context[%p]", ctx);
priv->egl_context = ctx;
gdk_gl_context_set_version (context, &supported_versions[j]);
gdk_gl_context_set_is_legacy (context, legacy);
if (epoxy_has_egl_extension (egl_display, "EGL_KHR_swap_buffers_with_damage"))
@@ -621,7 +630,7 @@ gdk_gl_context_real_begin_frame (GdkDrawContext *draw_context,
glViewport (0, 0, ww, wh);
#ifdef HAVE_EGL
if (priv->egl_context && gdk_gl_context_check_version (context, 0, 0, 3, 0))
if (priv->egl_context && gdk_gl_context_check_version (context, NULL, "3.0"))
glDrawBuffers (1, (GLenum[1]) { gdk_gl_context_get_use_es (context) ? GL_BACK : GL_BACK_LEFT });
#endif
}
@@ -987,36 +996,33 @@ gdk_gl_context_get_forward_compatible (GdkGLContext *context)
}
void
gdk_gl_context_get_matching_version (GdkGLAPI api,
gboolean legacy,
int *major,
int *minor)
gdk_gl_context_get_matching_version (GdkGLContext *context,
GdkGLAPI api,
gboolean legacy,
GdkGLVersion *out_version)
{
int maj, min;
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
GdkGLVersion min_version;
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
if (api == GDK_GL_API_GL)
{
if (legacy)
{
maj = GDK_GL_MIN_GL_LEGACY_VERSION_MAJOR;
min = GDK_GL_MIN_GL_LEGACY_VERSION_MINOR;
}
min_version = GDK_GL_MIN_GL_LEGACY_VERSION;
else
{
maj = GDK_GL_MIN_GL_VERSION_MAJOR;
min = GDK_GL_MIN_GL_VERSION_MINOR;
}
min_version = GDK_GL_MIN_GL_VERSION;
}
else
{
maj = GDK_GL_MIN_GLES_VERSION_MAJOR;
min = GDK_GL_MIN_GLES_VERSION_MINOR;
min_version = GDK_GL_MIN_GLES_VERSION;
}
if (major != NULL)
*major = maj;
if (minor != NULL)
*minor = min;
if (gdk_gl_version_greater_equal (&priv->required, &min_version))
*out_version = priv->required;
else
*out_version = min_version;
}
/**
@@ -1045,22 +1051,17 @@ gdk_gl_context_set_required_version (GdkGLContext *context,
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
g_return_if_fail (!gdk_gl_context_is_realized (context));
priv->major = major;
priv->minor = minor;
priv->required = GDK_GL_VERSION_INIT (major, minor);
}
gboolean
gdk_gl_context_check_version (GdkGLContext *self,
int required_gl_major,
int required_gl_minor,
int required_gles_major,
int required_gles_minor)
gdk_gl_context_check_gl_version (GdkGLContext *self,
const GdkGLVersion *required_gl,
const GdkGLVersion *required_gles)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (self);
g_return_val_if_fail (GDK_IS_GL_CONTEXT (self), FALSE);
g_return_val_if_fail (required_gl_minor < 10, FALSE);
g_return_val_if_fail (required_gles_minor < 10, FALSE);
if (!gdk_gl_context_is_realized (self))
return FALSE;
@@ -1068,10 +1069,10 @@ gdk_gl_context_check_version (GdkGLContext *self,
switch (priv->api)
{
case GDK_GL_API_GL:
return priv->gl_version >= required_gl_major * 10 + required_gl_minor;
return required_gl == NULL || gdk_gl_version_greater_equal (&priv->gl_version, required_gl);
case GDK_GL_API_GLES:
return priv->gl_version >= required_gles_major * 10 + required_gles_minor;
return required_gles == NULL || gdk_gl_version_greater_equal (&priv->gl_version, required_gles);
default:
g_return_val_if_reached (FALSE);
@@ -1102,33 +1103,9 @@ gdk_gl_context_get_required_version (GdkGLContext *context,
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
if (major != NULL)
*major = priv->major;
*major = gdk_gl_version_get_major (&priv->required);
if (minor != NULL)
*minor = priv->minor;
}
void
gdk_gl_context_get_clipped_version (GdkGLContext *context,
int min_major,
int min_minor,
int *major,
int *minor)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
int maj = min_major, min = min_minor;
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
if (priv->major > maj || (priv->major == maj && priv->minor > min))
{
maj = priv->major;
min = priv->minor;
}
if (major != NULL)
*major = maj;
if (minor != NULL)
*minor = min;
*minor = gdk_gl_version_get_minor (&priv->required);
}
/**
@@ -1165,6 +1142,15 @@ gdk_gl_context_is_legacy (GdkGLContext *context)
return priv->is_legacy;
}
void
gdk_gl_context_set_version (GdkGLContext *context,
const GdkGLVersion *version)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
priv->gl_version = *version;
}
void
gdk_gl_context_set_is_legacy (GdkGLContext *context,
gboolean is_legacy)
@@ -1500,11 +1486,23 @@ gdk_gl_context_realize (GdkGLContext *context,
priv->api = GDK_GL_CONTEXT_GET_CLASS (context)->realize (context, error);
if (priv->api)
g_object_notify_by_pspec (G_OBJECT (context), properties[PROP_API]);
{
g_assert (gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (0, 0)));
g_object_notify_by_pspec (G_OBJECT (context), properties[PROP_API]);
}
return priv->api;
}
void
gdk_gl_version_init_epoxy (GdkGLVersion *version)
{
int epoxy_version = epoxy_gl_version ();
*version = GDK_GL_VERSION_INIT (epoxy_version / 10, epoxy_version % 10);
}
static void
gdk_gl_context_check_extensions (GdkGLContext *context)
{
@@ -1518,8 +1516,6 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
if (priv->extensions_checked)
return;
priv->gl_version = epoxy_gl_version ();
priv->has_debug_output = epoxy_has_gl_extension ("GL_ARB_debug_output") ||
epoxy_has_gl_extension ("GL_KHR_debug");
@@ -1545,7 +1541,7 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
priv->has_khr_debug = epoxy_has_gl_extension ("GL_KHR_debug");
/* We asked for a core profile, but we didn't get one, so we're in legacy mode */
if (priv->gl_version < 32)
if (!gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (3, 2)))
priv->is_legacy = TRUE;
}
@@ -1555,12 +1551,12 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
glGetIntegerv (GL_MAX_LABEL_LENGTH, &priv->max_debug_label_length);
}
priv->has_half_float = gdk_gl_context_check_version (context, 3, 0, 3, 0) ||
priv->has_half_float = gdk_gl_context_check_version (context, "3.0", "3.0") ||
epoxy_has_gl_extension ("OES_vertex_half_float");
priv->has_fence_sync = gdk_gl_context_check_version (context, 3, 2, 3, 0) ||
epoxy_has_gl_extension ("GL_ARB_sync") ||
epoxy_has_gl_extension ("GK_APPLE_sync");
priv->has_sync = gdk_gl_context_check_version (context, "3.2", "3.0") ||
epoxy_has_gl_extension ("GL_ARB_sync") ||
epoxy_has_gl_extension ("GK_APPLE_sync");
#ifdef G_ENABLE_DEBUG
{
@@ -1574,16 +1570,16 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
" - GL_KHR_debug: %s\n"
" - GL_EXT_unpack_subimage: %s\n"
" - half float: %s\n"
" - fence sync: %s",
" - sync: %s",
gdk_gl_context_get_use_es (context) ? "OpenGL ES" : "OpenGL",
priv->gl_version / 10, priv->gl_version % 10,
gdk_gl_version_get_major (&priv->gl_version), gdk_gl_version_get_minor (&priv->gl_version),
priv->is_legacy ? "legacy" : "core",
glGetString (GL_SHADING_LANGUAGE_VERSION),
max_texture_size,
priv->has_khr_debug ? "yes" : "no",
priv->has_unpack_subimage ? "yes" : "no",
priv->has_half_float ? "yes" : "no",
priv->has_fence_sync ? "yes" : "no");
priv->has_sync ? "yes" : "no");
}
#endif
@@ -1705,10 +1701,6 @@ gdk_gl_context_get_shared_context (GdkGLContext *context)
* Retrieves the OpenGL version of the @context.
*
* The @context must be realized prior to calling this function.
*
* If the @context has never been made current, the version cannot
* be known and it will return 0 for both @major and @minor.
*
*/
void
gdk_gl_context_get_version (GdkGLContext *context,
@@ -1721,9 +1713,9 @@ gdk_gl_context_get_version (GdkGLContext *context,
g_return_if_fail (gdk_gl_context_is_realized (context));
if (major != NULL)
*major = priv->gl_version / 10;
*major = gdk_gl_version_get_major (&priv->gl_version);
if (minor != NULL)
*minor = priv->gl_version % 10;
*minor = gdk_gl_version_get_minor (&priv->gl_version);
}
/**
@@ -1816,11 +1808,11 @@ gdk_gl_context_has_vertex_half_float (GdkGLContext *self)
}
gboolean
gdk_gl_context_has_fence_sync (GdkGLContext *self)
gdk_gl_context_has_sync (GdkGLContext *self)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (self);
return priv->has_fence_sync;
return priv->has_sync;
}
/* This is currently private! */
+2 -15
View File
@@ -24,25 +24,12 @@
#error "Only <gdk/gdk.h> can be included directly."
#endif
#include <gdk/gdkversionmacros.h>
#include <gdk/gdkenums.h>
#include <gdk/gdktypes.h>
#include <gdk/gdkversionmacros.h>
G_BEGIN_DECLS
/**
* GdkGLAPI:
* @GDK_GL_API_GL: The OpenGL API
* @GDK_GL_API_GLES: The OpenGL ES API
*
* The list of the different APIs that GdkGLContext can potentially support.
*
* Since: 4.6
*/
typedef enum { /*< underscore_name=GDK_GL_API >*/
GDK_GL_API_GL = 1 << 0,
GDK_GL_API_GLES = 1 << 1
} GdkGLAPI;
#define GDK_TYPE_GL_CONTEXT (gdk_gl_context_get_type ())
#define GDK_GL_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_GL_CONTEXT, GdkGLContext))
#define GDK_IS_GL_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_GL_CONTEXT))
+26 -40
View File
@@ -22,29 +22,10 @@
#include "gdkglcontext.h"
#include "gdkdrawcontextprivate.h"
#include "gdkglversionprivate.h"
G_BEGIN_DECLS
/* Version requirements for EGL contexts.
*
* If you add support for EGL to your backend, please require this.
*/
#define GDK_EGL_MIN_VERSION_MAJOR (1)
#define GDK_EGL_MIN_VERSION_MINOR (4)
/* Minimum OpenGL versions supported by GTK.
* Backends should make sure to never create a context of a previous version.
*
* The macros refer to OpenGL; OpenGL with OPENGL_COMPATIBILITY_PROFILE_BIT as
* OPENGL_PROFILE_MASK; and OpenGL ES respectively
*/
#define GDK_GL_MIN_GL_VERSION_MAJOR (3)
#define GDK_GL_MIN_GL_VERSION_MINOR (2)
#define GDK_GL_MIN_GL_LEGACY_VERSION_MAJOR (3)
#define GDK_GL_MIN_GL_LEGACY_VERSION_MINOR (0)
#define GDK_GL_MIN_GLES_VERSION_MAJOR (2)
#define GDK_GL_MIN_GLES_VERSION_MINOR (0)
typedef enum {
GDK_GL_NONE = 0,
GDK_GL_EGL,
@@ -118,26 +99,31 @@ void gdk_gl_context_clear_current_if_surface (GdkSurface
GdkGLContext * gdk_gl_context_new (GdkDisplay *display,
GdkSurface *surface);
gboolean gdk_gl_context_is_api_allowed (GdkGLContext *self,
GdkGLAPI api,
GError **error);
void gdk_gl_context_set_is_legacy (GdkGLContext *context,
gboolean is_legacy);
gboolean gdk_gl_context_is_api_allowed (GdkGLContext *self,
GdkGLAPI api,
GError **error);
void gdk_gl_context_set_version (GdkGLContext *context,
const GdkGLVersion *version);
void gdk_gl_context_set_is_legacy (GdkGLContext *context,
gboolean is_legacy);
gboolean gdk_gl_context_check_gl_version (GdkGLContext *context,
const GdkGLVersion *gl_version,
const GdkGLVersion *gles_version);
gboolean gdk_gl_context_check_version (GdkGLContext *context,
int required_gl_major,
int required_gl_minor,
int required_gles_major,
int required_gles_minor);
void gdk_gl_context_get_clipped_version (GdkGLContext *context,
int min_major,
int min_minor,
int *major,
int *minor);
void gdk_gl_context_get_matching_version (GdkGLAPI api,
gboolean legacy,
int *major,
int *minor);
static inline gboolean
gdk_gl_context_check_version (GdkGLContext *context,
const char *gl_version,
const char *gles_version)
{
return gdk_gl_context_check_gl_version (context,
gl_version ? &GDK_GL_VERSION_STRING (gl_version) : NULL,
gles_version ? &GDK_GL_VERSION_STRING (gles_version) : NULL);
}
void gdk_gl_context_get_matching_version (GdkGLContext *context,
GdkGLAPI api,
gboolean legacy,
GdkGLVersion *out_version);
gboolean gdk_gl_context_has_unpack_subimage (GdkGLContext *context);
void gdk_gl_context_push_debug_group (GdkGLContext *context,
@@ -162,7 +148,7 @@ gboolean gdk_gl_context_use_es_bgra (GdkGLContext
gboolean gdk_gl_context_has_vertex_half_float (GdkGLContext *self) G_GNUC_PURE;
gboolean gdk_gl_context_has_fence_sync (GdkGLContext *self) G_GNUC_PURE;
gboolean gdk_gl_context_has_sync (GdkGLContext *self) G_GNUC_PURE;
double gdk_gl_context_get_scale (GdkGLContext *self);
+4 -3
View File
@@ -194,7 +194,7 @@ gdk_gl_texture_do_download (GdkGLTexture *self,
glGenFramebuffers (1, &fbo);
glBindFramebuffer (GL_FRAMEBUFFER, fbo);
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, self->id, 0);
if (gdk_gl_context_check_version (context, 4, 3, 3, 1))
if (gdk_gl_context_check_version (context, "4.3", "3.1"))
{
gdk_gl_context_get_version (context, &major, &minor);
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_FORMAT, &gl_read_format);
@@ -348,7 +348,8 @@ gdk_gl_texture_new_from_builder (GdkGLTextureBuilder *builder,
self->id = gdk_gl_texture_builder_get_id (builder);
GDK_TEXTURE (self)->format = gdk_gl_texture_builder_get_format (builder);
self->has_mipmap = gdk_gl_texture_builder_get_has_mipmap (builder);
self->sync = gdk_gl_texture_builder_get_sync (builder);
if (gdk_gl_context_has_sync (self->context))
self->sync = gdk_gl_texture_builder_get_sync (builder);
self->destroy = destroy;
self->data = data;
@@ -369,7 +370,7 @@ gdk_gl_texture_determine_format (GdkGLTexture *self)
if (context == NULL ||
!gdk_gl_context_is_shared (self->context, context) ||
/* ... or glGetTexLevelParameter() isn't supported */
!gdk_gl_context_check_version (context, 0, 0, 3, 1))
!gdk_gl_context_check_version (context, NULL, "3.1"))
{
texture->format = GDK_MEMORY_DEFAULT;
self->has_mipmap = FALSE;
+8 -7
View File
@@ -250,9 +250,9 @@ gdk_gl_texture_builder_class_init (GdkGLTextureBuilderClass *klass)
/**
* GdkGLTextureBuilder:sync: (attributes org.gdk.Property.get=gdk_gl_texture_builder_get_sync org.gdk.Property.set=gdk_gl_texture_builder_set_sync)
*
* An optional GLSync object.
* An optional `GLSync` object.
*
* If this is not `NULL, you have to call `glWaitSync` on it before using the texture.
* If this is set, GTK will wait on it before using the texture.
*
* Since: 4.12
*/
@@ -521,12 +521,9 @@ gdk_gl_texture_builder_set_has_mipmap (GdkGLTextureBuilder *self,
* gdk_gl_texture_builder_get_sync: (attributes org.gdk.Method.get_property=sync)
* @self: a `GdkGLTextureBuilder`
*
* Gets the GLSync object associated with the texture builder.
* Gets the `GLsync` previously set via gdk_gl_texture_builder_set_sync().
*
* If this function is returning something other than `NULL`, you have to
* call `glWaitSync` on the returned object before using the texture.
*
* Returns: (nullable): the GLSync object
* Returns: (nullable): the `GLSync`
*
* Since: 4.12
*/
@@ -545,8 +542,12 @@ gdk_gl_texture_builder_get_sync (GdkGLTextureBuilder *self)
*
* Sets the GLSync object to use for the texture.
*
* GTK will wait on this object before using the created `GdkTexture`.
*
* The `destroy` function that is passed to [method@Gdk.GLTextureBuilder.build]
* is responsible for freeing the sync object when it is no longer needed.
* The texture builder does not destroy it and it is the callers
* responsibility to make sure it doesn't leak.
*
* Since: 4.12
*/
+138
View File
@@ -0,0 +1,138 @@
/* GDK - The GIMP Drawing Kit
*
* gdkglcontextprivate.h: GL context abstraction
*
* Copyright © 2014 Emmanuele Bassi
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <gdkenums.h>
G_BEGIN_DECLS
/* Version requirements for EGL contexts.
*
* If you add support for EGL to your backend, please require this.
*/
#define GDK_EGL_MIN_VERSION_MAJOR (1)
#define GDK_EGL_MIN_VERSION_MINOR (4)
/* Minimum OpenGL versions supported by GTK.
* Backends should make sure to never create a context of a previous version.
*
* The macros refer to OpenGL; OpenGL with OPENGL_COMPATIBILITY_PROFILE_BIT as
* OPENGL_PROFILE_MASK; and OpenGL ES respectively
*/
#define GDK_GL_MIN_GL_VERSION GDK_GL_VERSION_INIT (3, 2)
#define GDK_GL_MIN_GL_LEGACY_VERSION GDK_GL_VERSION_INIT (3, 0)
#define GDK_GL_MIN_GLES_VERSION GDK_GL_VERSION_INIT (2, 0)
typedef struct _GdkGLVersion GdkGLVersion;
struct _GdkGLVersion
{
int major;
int minor;
};
#define GDK_GL_VERSION_INIT(maj,min) { maj, min }
static const GdkGLVersion supported_gl_versions[] = {
GDK_GL_VERSION_INIT (4, 6),
GDK_GL_VERSION_INIT (4, 5),
GDK_GL_VERSION_INIT (4, 4),
GDK_GL_VERSION_INIT (4, 3),
GDK_GL_VERSION_INIT (4, 2),
GDK_GL_VERSION_INIT (4, 1),
GDK_GL_VERSION_INIT (4, 0),
GDK_GL_VERSION_INIT (3, 3),
GDK_GL_VERSION_INIT (3, 2),
GDK_GL_VERSION_INIT (3, 1),
GDK_GL_VERSION_INIT (3, 0),
GDK_GL_VERSION_INIT (0, 0)
};
static const GdkGLVersion supported_gles_versions[] = {
GDK_GL_VERSION_INIT (3, 2),
GDK_GL_VERSION_INIT (3, 1),
GDK_GL_VERSION_INIT (3, 0),
GDK_GL_VERSION_INIT (2, 0),
GDK_GL_VERSION_INIT (0, 0)
};
#undef GDK_GL_VERSION_INIT
#define GDK_GL_VERSION_INIT(maj,min) (GdkGLVersion) { maj, min }
#define GDK_GL_VERSION_STRING(str) GDK_GL_VERSION_INIT(str[0] - '0', str[2] - '0')
static inline const GdkGLVersion *
gdk_gl_versions_get_for_api (GdkGLAPI api)
{
switch (api)
{
case GDK_GL_API_GL:
return supported_gl_versions;
case GDK_GL_API_GLES:
return supported_gles_versions;
default:
g_assert_not_reached ();
return NULL;
}
}
static inline int
gdk_gl_version_get_major (const GdkGLVersion *self)
{
return self->major;
}
static inline int
gdk_gl_version_get_minor (const GdkGLVersion *self)
{
return self->minor;
}
static inline int
gdk_gl_version_compare (const GdkGLVersion *a,
const GdkGLVersion *b)
{
if (a->major > b->major)
return 1;
if (a->major < b->major)
return -1;
if (a->minor > b->minor)
return 1;
if (a->minor < b->minor)
return -1;
return 0;
}
static inline gboolean
gdk_gl_version_greater_equal (const GdkGLVersion *a,
const GdkGLVersion *b)
{
return gdk_gl_version_compare (a, b) >= 0;
}
/* in gdkglcontext.c */
void gdk_gl_version_init_epoxy (GdkGLVersion *version);
G_END_DECLS
+57
View File
@@ -0,0 +1,57 @@
#pragma once
#include "gdkrectangle.h"
#include <math.h>
G_BEGIN_DECLS
/*
* gdk_rectangle_transform_affine:
* @src: the rectangle to transform
* @scale_x: scale factor in the X direction. The scale factor
* may be negative or 0.
* @scale_y: scale factor in the Y direction. The scale factor
* may be negative or 0.
* @offset_x: offset of result in X direction.
* @offset_y: offset of result in Y direction.
* @dest: (out caller-allocates): destination rectangle, may be
* identical to @src
*
* Does an affine transform of the source rectangle and stores the
* result in the dest rectangle. If the destination rectangle does
* not fit on integer bounds, the result will be enlarged to make it
* fit.
* (Fun fact: This means with a scale of 0 and an offset of 0.5,
* the resulting rect will have a width of 1.)
*
* The width and height of the result will be positive, even if the
* src rectangle or the scale were negative.
*
* This function can be used with the output of
* gsk_transform_to_affine().
**/
static inline void
gdk_rectangle_transform_affine (const GdkRectangle *src,
float scale_x,
float scale_y,
float offset_x,
float offset_y,
GdkRectangle *dest)
{
float x1, x2, y1, y2;
x1 = offset_x + src->x * scale_x;
x2 = offset_x + (src->x + src->width) * scale_x;
y1 = offset_y + src->y * scale_y;
y2 = offset_y + (src->y + src->height) * scale_y;
dest->x = floorf (MIN (x1, x2));
dest->y = floorf (MIN (y1, y2));
dest->width = ceilf (MAX (x1, x2)) - dest->x;
dest->height = ceilf (MAX (y1, y2)) - dest->y;
}
G_END_DECLS
+22 -23
View File
@@ -115,9 +115,6 @@ static void gdk_surface_get_property (GObject *object,
static void update_cursor (GdkDisplay *display,
GdkDevice *device);
static void gdk_surface_set_frame_clock (GdkSurface *surface,
GdkFrameClock *clock);
static void gdk_surface_queue_set_is_mapped (GdkSurface *surface,
gboolean is_mapped);
@@ -496,11 +493,22 @@ gdk_surface_real_get_scale (GdkSurface *surface)
return 1.0;
}
static void
gdk_surface_constructed (GObject *object)
{
G_GNUC_UNUSED GdkSurface *surface = GDK_SURFACE (object);
g_assert (surface->frame_clock != NULL);
G_OBJECT_CLASS (gdk_surface_parent_class)->constructed (object);
}
static void
gdk_surface_class_init (GdkSurfaceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructed = gdk_surface_constructed;
object_class->finalize = gdk_surface_finalize;
object_class->set_property = gdk_surface_set_property;
object_class->get_property = gdk_surface_get_property;
@@ -845,21 +853,6 @@ _gdk_surface_update_size (GdkSurface *surface)
g_object_notify (G_OBJECT (surface), "height");
}
static GdkSurface *
gdk_surface_new (GdkDisplay *display,
GdkSurfaceType surface_type,
GdkSurface *parent,
int x,
int y,
int width,
int height)
{
return gdk_display_create_surface (display,
surface_type,
parent,
x, y, width, height);
}
/**
* gdk_surface_new_toplevel: (constructor)
* @display: the display to create the surface on
@@ -873,8 +866,9 @@ gdk_surface_new_toplevel (GdkDisplay *display)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
return gdk_surface_new (display, GDK_SURFACE_TOPLEVEL,
NULL, 0, 0, 1, 1);
return g_object_new (GDK_DISPLAY_GET_CLASS (display)->toplevel_type,
"display", display,
NULL);
}
/**
@@ -894,11 +888,16 @@ gdk_surface_new_popup (GdkSurface *parent,
gboolean autohide)
{
GdkSurface *surface;
GdkDisplay *display;
g_return_val_if_fail (GDK_IS_SURFACE (parent), NULL);
surface = gdk_surface_new (parent->display, GDK_SURFACE_POPUP,
parent, 0, 0, 100, 100);
display = gdk_surface_get_display (parent);
surface = g_object_new (GDK_DISPLAY_GET_CLASS (display)->popup_type,
"display", display,
"parent", parent,
NULL);
surface->autohide = autohide;
@@ -2457,7 +2456,7 @@ gdk_surface_resume_events (GdkFrameClock *clock,
}
}
static void
void
gdk_surface_set_frame_clock (GdkSurface *surface,
GdkFrameClock *clock)
{
+2 -7
View File
@@ -26,13 +26,6 @@
G_BEGIN_DECLS
typedef enum
{
GDK_SURFACE_TOPLEVEL,
GDK_SURFACE_POPUP,
GDK_SURFACE_DRAG
} GdkSurfaceType;
struct _GdkSurface
{
GObject parent_instance;
@@ -285,6 +278,8 @@ void gdk_surface_get_geometry (GdkSurface *surface,
int *width,
int *height);
void gdk_surface_set_frame_clock (GdkSurface *surface,
GdkFrameClock *clock);
void gdk_surface_set_egl_native_window (GdkSurface *self,
gpointer native_window);
void gdk_surface_ensure_egl_surface (GdkSurface *self,
+2
View File
@@ -121,6 +121,8 @@ GdkMonitor *_gdk_macos_display_get_monitor_at_coords (GdkMacosDisp
GdkMonitor *_gdk_macos_display_get_monitor_at_display_coords (GdkMacosDisplay *self,
int x,
int y);
void _gdk_macos_display_surface_added (GdkMacosDisplay *self,
GdkMacosSurface *surface);
GdkEvent *_gdk_macos_display_translate (GdkMacosDisplay *self,
NSEvent *event);
void _gdk_macos_display_feedback_init (GdkMacosDisplay *self);
+5 -25
View File
@@ -36,8 +36,10 @@
#include "gdkmacosglcontext-private.h"
#include "gdkmacoskeymap-private.h"
#include "gdkmacosmonitor-private.h"
#include "gdkmacospopupsurface-private.h"
#include "gdkmacosseat-private.h"
#include "gdkmacossurface-private.h"
#include "gdkmacostoplevelsurface-private.h"
#include "gdkmacosutils-private.h"
G_DEFINE_TYPE (GdkMacosDisplay, gdk_macos_display, GDK_TYPE_DISPLAY)
@@ -333,7 +335,7 @@ gdk_macos_display_queue_events (GdkDisplay *display)
}
}
static void
void
_gdk_macos_display_surface_added (GdkMacosDisplay *self,
GdkMacosSurface *surface)
{
@@ -539,29 +541,6 @@ _gdk_macos_display_surface_resigned_main (GdkMacosDisplay *self,
_gdk_macos_display_clear_sorting (self);
}
static GdkSurface *
gdk_macos_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type,
GdkSurface *parent,
int x,
int y,
int width,
int height)
{
GdkMacosDisplay *self = (GdkMacosDisplay *)display;
GdkMacosSurface *surface;
g_assert (GDK_IS_MACOS_DISPLAY (self));
g_assert (!parent || GDK_IS_MACOS_SURFACE (parent));
surface = _gdk_macos_surface_new (self, surface_type, parent, x, y, width, height);
if (surface != NULL)
_gdk_macos_display_surface_added (self, surface);
return GDK_SURFACE (surface);
}
static GdkKeymap *
gdk_macos_display_get_keymap (GdkDisplay *display)
{
@@ -617,10 +596,11 @@ gdk_macos_display_class_init (GdkMacosDisplayClass *klass)
object_class->finalize = gdk_macos_display_finalize;
display_class->toplevel_type = GDK_TYPE_MACOS_TOPLEVEL_SURFACE;
display_class->popup_type = GDK_TYPE_MACOS_POPUP_SURFACE;
display_class->cairo_context_type = GDK_TYPE_MACOS_CAIRO_CONTEXT;
display_class->beep = gdk_macos_display_beep;
display_class->create_surface = gdk_macos_display_create_surface;
display_class->flush = gdk_macos_display_flush;
display_class->get_keymap = gdk_macos_display_get_keymap;
display_class->get_monitors = gdk_macos_display_get_monitors;
+1 -6
View File
@@ -31,12 +31,7 @@ typedef struct _GdkMacosDragSurfaceClass GdkMacosDragSurfaceClass;
#define GDK_IS_MACOS_DRAG_SURFACE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MACOS_DRAG_SURFACE))
GType _gdk_macos_drag_surface_get_type (void);
GdkMacosSurface *_gdk_macos_drag_surface_new (GdkMacosDisplay *display,
GdkFrameClock *frame_clock,
int x,
int y,
int width,
int height);
GdkMacosSurface *_gdk_macos_drag_surface_new (GdkMacosDisplay *display);
G_END_DECLS
+38 -28
View File
@@ -25,6 +25,8 @@
#include "gdkmacosdisplay-private.h"
#include "gdkmacosutils-private.h"
#include "gdk/gdkframeclockidleprivate.h"
struct _GdkMacosDragSurface
{
GdkMacosSurface parent_instance;
@@ -62,27 +64,15 @@ G_DEFINE_TYPE_WITH_CODE (GdkMacosDragSurface, _gdk_macos_drag_surface, GDK_TYPE_
G_IMPLEMENT_INTERFACE (GDK_TYPE_DRAG_SURFACE, drag_surface_iface_init))
static void
_gdk_macos_drag_surface_class_init (GdkMacosDragSurfaceClass *klass)
{
}
static void
_gdk_macos_drag_surface_init (GdkMacosDragSurface *self)
{
}
GdkMacosSurface *
_gdk_macos_drag_surface_new (GdkMacosDisplay *display,
GdkFrameClock *frame_clock,
int x,
int y,
int width,
int height)
_gdk_macos_drag_surface_constructed (GObject *object)
{
GDK_BEGIN_MACOS_ALLOC_POOL;
GdkMacosWindow *window;
GdkMacosSurface *self;
GdkMacosSurface *self = GDK_MACOS_SURFACE (object);
GdkSurface *surface = GDK_SURFACE (self);
GdkMacosDisplay *display = GDK_MACOS_DISPLAY (gdk_surface_get_display (GDK_SURFACE (self)));
GdkFrameClock *frame_clock;
NSScreen *screen;
NSUInteger style_mask;
NSRect content_rect;
@@ -90,18 +80,15 @@ _gdk_macos_drag_surface_new (GdkMacosDisplay *display,
int nx;
int ny;
g_return_val_if_fail (GDK_IS_MACOS_DISPLAY (display), NULL);
g_return_val_if_fail (!frame_clock || GDK_IS_FRAME_CLOCK (frame_clock), NULL);
style_mask = NSWindowStyleMaskBorderless;
_gdk_macos_display_to_display_coords (display, x, y, &nx, &ny);
_gdk_macos_display_to_display_coords (display, 0, 0, &nx, &ny);
screen = _gdk_macos_display_get_screen_at_display_coords (display, nx, ny);
screen_rect = [screen frame];
nx -= screen_rect.origin.x;
ny -= screen_rect.origin.y;
content_rect = NSMakeRect (nx, ny - height, width, height);
content_rect = NSMakeRect (nx, ny - 1, 1, 1);
window = [[GdkMacosWindow alloc] initWithContentRect:content_rect
styleMask:style_mask
@@ -113,13 +100,36 @@ _gdk_macos_drag_surface_new (GdkMacosDisplay *display,
[window setBackgroundColor:[NSColor clearColor]];
[window setDecorated:NO];
self = g_object_new (GDK_TYPE_MACOS_DRAG_SURFACE,
"display", display,
"frame-clock", frame_clock,
"native", window,
NULL);
_gdk_macos_surface_set_native (self, window);
frame_clock = _gdk_frame_clock_idle_new ();
gdk_surface_set_frame_clock (surface, frame_clock);
g_object_unref (frame_clock);
GDK_END_MACOS_ALLOC_POOL;
return g_steal_pointer (&self);
G_OBJECT_CLASS (_gdk_macos_drag_surface_parent_class)->constructed (object);
}
static void
_gdk_macos_drag_surface_class_init (GdkMacosDragSurfaceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructed = _gdk_macos_drag_surface_constructed;
}
static void
_gdk_macos_drag_surface_init (GdkMacosDragSurface *self)
{
}
GdkMacosSurface *
_gdk_macos_drag_surface_new (GdkMacosDisplay *display)
{
g_return_val_if_fail (GDK_IS_MACOS_DISPLAY (display), NULL);
return g_object_new (GDK_TYPE_MACOS_DRAG_SURFACE,
"display", display,
NULL);
}
+40 -15
View File
@@ -323,12 +323,12 @@ gdk_macos_gl_context_release (GdkMacosGLContext *self)
}
static CGLPixelFormatObj
create_pixel_format (int major,
int minor,
GError **error)
create_pixel_format (GdkGLVersion *version,
gboolean *out_legacy,
GError **error)
{
CGLPixelFormatAttribute attrs[] = {
kCGLPFAOpenGLProfile, (CGLPixelFormatAttribute)kCGLOGLPVersion_Legacy,
kCGLPFAOpenGLProfile, 0,
kCGLPFAAllowOfflineRenderers, /* allow sharing across GPUs */
kCGLPFADepthSize, 0,
kCGLPFAStencilSize, 0,
@@ -339,14 +339,28 @@ create_pixel_format (int major,
CGLPixelFormatObj format = NULL;
GLint n_format = 1;
if (major == 3 && minor == 2)
attrs[1] = (CGLPixelFormatAttribute)kCGLOGLPVersion_GL3_Core;
else if (major == 4 && minor == 1)
attrs[1] = (CGLPixelFormatAttribute)kCGLOGLPVersion_GL4_Core;
*out_legacy = FALSE;
if (gdk_gl_version_get_major (version) >= 4)
{
attrs[1] = (CGLPixelFormatAttribute)kCGLOGLPVersion_GL4_Core;
if (CGLChoosePixelFormat (attrs, &format, &n_format))
return g_steal_pointer (&format);
}
if (gdk_gl_version_greater_equal (version, &GDK_GL_MIN_GL_VERSION))
{
attrs[1] = (CGLPixelFormatAttribute)kCGLOGLPVersion_GL3_Core;
if (CGLChoosePixelFormat (attrs, &format, &n_format))
return g_steal_pointer (&format);
}
attrs[1] = (CGLPixelFormatAttribute) kCGLOGLPVersion_Legacy;
if (!CHECK (error, CGLChoosePixelFormat (attrs, &format, &n_format)))
return NULL;
*out_legacy = TRUE;
return g_steal_pointer (&format);
}
@@ -366,7 +380,8 @@ gdk_macos_gl_context_real_realize (GdkGLContext *context,
GLint validate = 0;
GLint renderer_id = 0;
GLint swapRect[4];
int major, minor;
GdkGLVersion min_version, version;
gboolean legacy;
g_assert (GDK_IS_MACOS_GL_CONTEXT (self));
@@ -378,10 +393,10 @@ gdk_macos_gl_context_real_realize (GdkGLContext *context,
existing = CGLGetCurrentContext ();
gdk_gl_context_get_clipped_version (context,
GDK_GL_MIN_GL_VERSION_MAJOR,
GDK_GL_MIN_GL_VERSION_MINOR,
&major, &minor);
gdk_gl_context_get_matching_version (context,
GDK_GL_API_GL,
FALSE,
&version);
display = gdk_gl_context_get_display (context);
shared = gdk_display_get_gl_context (display);
@@ -400,9 +415,9 @@ gdk_macos_gl_context_real_realize (GdkGLContext *context,
GDK_DISPLAY_DEBUG (display, OPENGL,
"Creating CGLContextObj (version %d.%d)",
major, minor);
gdk_gl_version_get_major (&min_version), gdk_gl_version_get_minor (&min_version));
if (!(pixelFormat = create_pixel_format (major, minor, error)))
if (!(pixelFormat = create_pixel_format (&min_version, &legacy, error)))
return 0;
if (!CHECK (error, CGLCreateContext (pixelFormat, shared_gl_context, &cgl_context)))
@@ -414,6 +429,13 @@ gdk_macos_gl_context_real_realize (GdkGLContext *context,
CGLSetCurrentContext (cgl_context);
CGLReleasePixelFormat (pixelFormat);
gdk_gl_version_init_epoxy (&version);
if (!gdk_gl_version_greater_equal (&version, &min_version))
{
CGLReleaseContext (cgl_context);
return 0;
}
if (validate)
CHECK (NULL, CGLEnable (cgl_context, kCGLCEStateValidation));
@@ -445,6 +467,9 @@ gdk_macos_gl_context_real_realize (GdkGLContext *context,
cgl_context,
get_renderer_name (renderer_id));
gdk_gl_context_set_version (context, &version);
gdk_gl_context_set_is_legacy (context, legacy);
self->cgl_context = g_steal_pointer (&cgl_context);
if (existing != NULL)
+1 -5
View File
@@ -33,11 +33,7 @@ typedef struct _GdkMacosPopupSurfaceClass GdkMacosPopupSurfaceClass;
GType _gdk_macos_popup_surface_get_type (void);
GdkMacosSurface *_gdk_macos_popup_surface_new (GdkMacosDisplay *display,
GdkSurface *parent,
GdkFrameClock *frame_clock,
int x,
int y,
int width,
int height);
GdkFrameClock *frame_clock);
void _gdk_macos_popup_surface_attach_to_parent (GdkMacosPopupSurface *self);
void _gdk_macos_popup_surface_detach_from_parent (GdkMacosPopupSurface *self);
void _gdk_macos_popup_surface_reposition (GdkMacosPopupSurface *self);
+31 -41
View File
@@ -284,38 +284,14 @@ _gdk_macos_popup_surface_set_property (GObject *object,
}
static void
_gdk_macos_popup_surface_class_init (GdkMacosPopupSurfaceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkSurfaceClass *surface_class = GDK_SURFACE_CLASS (klass);
object_class->finalize = _gdk_macos_popup_surface_finalize;
object_class->get_property = _gdk_macos_popup_surface_get_property;
object_class->set_property = _gdk_macos_popup_surface_set_property;
surface_class->hide = _gdk_macos_popup_surface_hide;
gdk_popup_install_properties (object_class, LAST_PROP);
}
static void
_gdk_macos_popup_surface_init (GdkMacosPopupSurface *self)
{
}
GdkMacosSurface *
_gdk_macos_popup_surface_new (GdkMacosDisplay *display,
GdkSurface *parent,
GdkFrameClock *frame_clock,
int x,
int y,
int width,
int height)
_gdk_macos_popup_surface_constructed (GObject *object)
{
GDK_BEGIN_MACOS_ALLOC_POOL;
GdkMacosWindow *window;
GdkMacosSurface *self;
GdkMacosPopupSurface *self = GDK_MACOS_POPUP_SURFACE (object);
GdkSurface *surface = GDK_SURFACE (self);
GdkMacosDisplay *display = GDK_MACOS_DISPLAY (gdk_surface_get_display (GDK_SURFACE (self)));
NSScreen *screen;
NSUInteger style_mask;
NSRect content_rect;
@@ -323,19 +299,15 @@ _gdk_macos_popup_surface_new (GdkMacosDisplay *display,
int nx;
int ny;
g_return_val_if_fail (GDK_IS_MACOS_DISPLAY (display), NULL);
g_return_val_if_fail (!frame_clock || GDK_IS_FRAME_CLOCK (frame_clock), NULL);
g_return_val_if_fail (!parent || GDK_IS_MACOS_SURFACE (parent), NULL);
style_mask = NSWindowStyleMaskBorderless;
_gdk_macos_display_to_display_coords (display, x, y, &nx, &ny);
_gdk_macos_display_to_display_coords (display, 0, 0, &nx, &ny);
screen = _gdk_macos_display_get_screen_at_display_coords (display, nx, ny);
screen_rect = [screen frame];
nx -= screen_rect.origin.x;
ny -= screen_rect.origin.y;
content_rect = NSMakeRect (nx, ny - height, width, height);
content_rect = NSMakeRect (nx, ny - 100, 100, 100);
window = [[GdkMacosWindow alloc] initWithContentRect:content_rect
styleMask:style_mask
@@ -349,16 +321,34 @@ _gdk_macos_popup_surface_new (GdkMacosDisplay *display,
[window setExcludedFromWindowsMenu:YES];
[window setLevel:NSPopUpMenuWindowLevel];
self = g_object_new (GDK_TYPE_MACOS_POPUP_SURFACE,
"display", display,
"frame-clock", frame_clock,
"native", window,
"parent", parent,
NULL);
_gdk_macos_surface_set_native (GDK_MACOS_SURFACE (self), window);
gdk_surface_set_frame_clock (surface, gdk_surface_get_frame_clock (surface->parent));
GDK_END_MACOS_ALLOC_POOL;
return g_steal_pointer (&self);
G_OBJECT_CLASS (_gdk_macos_popup_surface_parent_class)->constructed (object);
}
static void
_gdk_macos_popup_surface_class_init (GdkMacosPopupSurfaceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkSurfaceClass *surface_class = GDK_SURFACE_CLASS (klass);
object_class->constructed = _gdk_macos_popup_surface_constructed;
object_class->finalize = _gdk_macos_popup_surface_finalize;
object_class->get_property = _gdk_macos_popup_surface_get_property;
object_class->set_property = _gdk_macos_popup_surface_set_property;
surface_class->hide = _gdk_macos_popup_surface_hide;
gdk_popup_install_properties (object_class, LAST_PROP);
}
static void
_gdk_macos_popup_surface_init (GdkMacosPopupSurface *self)
{
}
void
+2 -7
View File
@@ -84,14 +84,9 @@ struct _GdkMacosSurfaceClass
GdkSurfaceClass parent_class;
};
GdkMacosSurface *_gdk_macos_surface_new (GdkMacosDisplay *display,
GdkSurfaceType surface_type,
GdkSurface *parent,
int x,
int y,
int width,
int height);
NSWindow *_gdk_macos_surface_get_native (GdkMacosSurface *self);
void _gdk_macos_surface_set_native (GdkMacosSurface *self,
GdkMacosWindow *window);
CGDirectDisplayID _gdk_macos_surface_get_screen_id (GdkMacosSurface *self);
const char *_gdk_macos_surface_get_title (GdkMacosSurface *self);
void _gdk_macos_surface_set_title (GdkMacosSurface *self,
+20 -83
View File
@@ -31,7 +31,7 @@
#include "gdkdeviceprivate.h"
#include "gdkdisplay.h"
#include "gdkeventsprivate.h"
#include "gdkframeclockidleprivate.h"
#include "gdkframeclockprivate.h"
#include "gdkseatprivate.h"
#include "gdksurfaceprivate.h"
@@ -43,8 +43,8 @@
#include "gdkmacosglcontext-private.h"
#include "gdkmacosmonitor-private.h"
#include "gdkmacospopupsurface-private.h"
#include "gdkmacostoplevelsurface-private.h"
#include "gdkmacosutils-private.h"
#include "gdkmacostoplevelsurface-private.h"
G_DEFINE_ABSTRACT_TYPE (GdkMacosSurface, gdk_macos_surface, GDK_TYPE_SURFACE)
@@ -416,10 +416,6 @@ gdk_macos_surface_drag_begin (GdkSurface *surface,
GdkMacosSurface *drag_surface;
GdkMacosDrag *drag;
GdkCursor *cursor;
double px;
double py;
int sx;
int sy;
g_assert (GDK_IS_MACOS_SURFACE (self));
g_assert (GDK_IS_MACOS_TOPLEVEL_SURFACE (self) ||
@@ -427,12 +423,7 @@ gdk_macos_surface_drag_begin (GdkSurface *surface,
g_assert (GDK_IS_MACOS_DEVICE (device));
g_assert (GDK_IS_CONTENT_PROVIDER (content));
gdk_macos_device_query_state (device, surface, NULL, &px, &py, NULL);
_gdk_macos_surface_get_root_coords (GDK_MACOS_SURFACE (surface), &sx, &sy);
drag_surface = _gdk_macos_surface_new (GDK_MACOS_DISPLAY (surface->display),
GDK_SURFACE_DRAG,
NULL,
sx, sy, 1, 1);
drag_surface = _gdk_macos_drag_surface_new (GDK_MACOS_DISPLAY (surface->display));
drag = g_object_new (GDK_TYPE_MACOS_DRAG,
"drag-surface", drag_surface,
"surface", surface,
@@ -527,8 +518,14 @@ gdk_macos_surface_constructed (GObject *object)
G_CONNECT_SWAPPED);
}
gdk_surface_freeze_updates (GDK_SURFACE (self));
_gdk_macos_surface_monitor_changed (self);
if (self->window != NULL)
_gdk_macos_surface_configure (self);
_gdk_macos_display_surface_added (GDK_MACOS_DISPLAY (gdk_surface_get_display (GDK_SURFACE (self))),
self);
}
static void
@@ -550,26 +547,6 @@ gdk_macos_surface_get_property (GObject *object,
}
}
static void
gdk_macos_surface_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GdkMacosSurface *self = GDK_MACOS_SURFACE (object);
switch (prop_id)
{
case PROP_NATIVE:
self->window = g_value_get_pointer (value);
[self->window setGdkSurface:self];
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
gdk_macos_surface_class_init (GdkMacosSurfaceClass *klass)
{
@@ -578,7 +555,6 @@ gdk_macos_surface_class_init (GdkMacosSurfaceClass *klass)
object_class->constructed = gdk_macos_surface_constructed;
object_class->get_property = gdk_macos_surface_get_property;
object_class->set_property = gdk_macos_surface_set_property;
surface_class->destroy = gdk_macos_surface_destroy;
surface_class->drag_begin = gdk_macos_surface_drag_begin;
@@ -597,7 +573,7 @@ gdk_macos_surface_class_init (GdkMacosSurfaceClass *klass)
*/
properties [PROP_NATIVE] =
g_param_spec_pointer ("native", NULL, NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, LAST_PROP, properties);
}
@@ -611,55 +587,6 @@ gdk_macos_surface_init (GdkMacosSurface *self)
self->monitors = g_ptr_array_new_with_free_func (g_object_unref);
}
GdkMacosSurface *
_gdk_macos_surface_new (GdkMacosDisplay *display,
GdkSurfaceType surface_type,
GdkSurface *parent,
int x,
int y,
int width,
int height)
{
GdkFrameClock *frame_clock;
GdkMacosSurface *ret;
g_return_val_if_fail (GDK_IS_MACOS_DISPLAY (display), NULL);
if (parent != NULL)
frame_clock = g_object_ref (parent->frame_clock);
else
frame_clock = _gdk_frame_clock_idle_new ();
switch (surface_type)
{
case GDK_SURFACE_TOPLEVEL:
ret = _gdk_macos_toplevel_surface_new (display, parent, frame_clock, x, y, width, height);
break;
case GDK_SURFACE_POPUP:
ret = _gdk_macos_popup_surface_new (display, parent, frame_clock, x, y, width, height);
break;
case GDK_SURFACE_DRAG:
ret = _gdk_macos_drag_surface_new (display, frame_clock, x, y, width, height);
break;
default:
g_warn_if_reached ();
ret = NULL;
}
if (ret != NULL)
{
gdk_surface_freeze_updates (GDK_SURFACE (ret));
_gdk_macos_surface_monitor_changed (ret);
}
g_object_unref (frame_clock);
return g_steal_pointer (&ret);
}
void
_gdk_macos_surface_get_shadow (GdkMacosSurface *self,
int *top,
@@ -755,6 +682,16 @@ _gdk_macos_surface_get_native (GdkMacosSurface *self)
return (NSWindow *)self->window;
}
void
_gdk_macos_surface_set_native (GdkMacosSurface *self,
GdkMacosWindow *window)
{
g_assert (self->window == NULL);
self->window = window;
[self->window setGdkSurface:self];
}
/**
* gdk_macos_surface_get_native_window: (attributes org.gtk.Method.get_property=native)
* @self: a #GdkMacosSurface
@@ -45,13 +45,6 @@ struct _GdkMacosToplevelSurfaceClass
};
GType _gdk_macos_toplevel_surface_get_type (void);
GdkMacosSurface *_gdk_macos_toplevel_surface_new (GdkMacosDisplay *display,
GdkSurface *parent,
GdkFrameClock *frame_clock,
int x,
int y,
int width,
int height);
void _gdk_macos_toplevel_surface_attach_to_parent (GdkMacosToplevelSurface *self);
void _gdk_macos_toplevel_surface_detach_from_parent (GdkMacosToplevelSurface *self);
+49 -60
View File
@@ -23,6 +23,7 @@
#include "gdkmacostoplevelsurface-private.h"
#include "gdkframeclockidleprivate.h"
#include "gdkseatprivate.h"
#include "gdktoplevelprivate.h"
@@ -625,12 +626,60 @@ _gdk_macos_toplevel_surface_set_property (GObject *object,
}
}
static void
_gdk_macos_toplevel_surface_constructed (GObject *object)
{
GDK_BEGIN_MACOS_ALLOC_POOL;
GdkMacosWindow *window;
GdkMacosToplevelSurface *self = GDK_MACOS_TOPLEVEL_SURFACE (object);
GdkSurface *surface = GDK_SURFACE (self);
GdkMacosDisplay *display = GDK_MACOS_DISPLAY (gdk_surface_get_display (surface));
GdkFrameClock *frame_clock;
NSUInteger style_mask;
NSRect content_rect;
NSRect visible_frame;
NSScreen *screen;
int nx;
int ny;
style_mask = (NSWindowStyleMaskTitled |
NSWindowStyleMaskClosable |
NSWindowStyleMaskMiniaturizable |
NSWindowStyleMaskResizable);
_gdk_macos_display_to_display_coords (display, 0, 100, &nx, &ny);
screen = _gdk_macos_display_get_screen_at_display_coords (display, nx, ny);
visible_frame = [screen visibleFrame];
content_rect = NSMakeRect (nx - visible_frame.origin.x, ny - visible_frame.origin.y, 100, 100);
window = [[GdkMacosWindow alloc] initWithContentRect:content_rect
styleMask:style_mask
backing:NSBackingStoreBuffered
defer:NO
screen:screen];
/* Allow NSWindow to go fullscreen */
[window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
_gdk_macos_surface_set_native (GDK_MACOS_SURFACE (self), window);
frame_clock = _gdk_frame_clock_idle_new ();
gdk_surface_set_frame_clock (surface, frame_clock);
g_object_unref (frame_clock);
GDK_END_MACOS_ALLOC_POOL;
G_OBJECT_CLASS (_gdk_macos_toplevel_surface_parent_class)->constructed (object);
}
static void
_gdk_macos_toplevel_surface_class_init (GdkMacosToplevelSurfaceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkSurfaceClass *surface_class = GDK_SURFACE_CLASS (klass);
object_class->constructed = _gdk_macos_toplevel_surface_constructed;
object_class->get_property = _gdk_macos_toplevel_surface_get_property;
object_class->set_property = _gdk_macos_toplevel_surface_set_property;
@@ -648,66 +697,6 @@ _gdk_macos_toplevel_surface_init (GdkMacosToplevelSurface *self)
self->decorated = TRUE;
}
GdkMacosSurface *
_gdk_macos_toplevel_surface_new (GdkMacosDisplay *display,
GdkSurface *parent,
GdkFrameClock *frame_clock,
int x,
int y,
int width,
int height)
{
GDK_BEGIN_MACOS_ALLOC_POOL;
GdkMacosWindow *window;
GdkMacosSurface *self;
NSUInteger style_mask;
NSRect content_rect;
NSRect visible_frame;
NSScreen *screen;
int nx;
int ny;
g_return_val_if_fail (GDK_IS_MACOS_DISPLAY (display), NULL);
g_return_val_if_fail (!frame_clock || GDK_IS_FRAME_CLOCK (frame_clock), NULL);
g_return_val_if_fail (!parent || GDK_IS_MACOS_SURFACE (parent), NULL);
style_mask = (NSWindowStyleMaskTitled |
NSWindowStyleMaskClosable |
NSWindowStyleMaskMiniaturizable |
NSWindowStyleMaskResizable);
if (parent != NULL)
{
x += GDK_MACOS_SURFACE (parent)->root_x;
y += GDK_MACOS_SURFACE (parent)->root_y;
}
_gdk_macos_display_to_display_coords (display, x, y + height, &nx, &ny);
screen = _gdk_macos_display_get_screen_at_display_coords (display, nx, ny);
visible_frame = [screen visibleFrame];
content_rect = NSMakeRect (nx - visible_frame.origin.x, ny - visible_frame.origin.y, width, height);
window = [[GdkMacosWindow alloc] initWithContentRect:content_rect
styleMask:style_mask
backing:NSBackingStoreBuffered
defer:NO
screen:screen];
/* Allow NSWindow to go fullscreen */
[window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
self = g_object_new (GDK_TYPE_MACOS_TOPLEVEL_SURFACE,
"display", display,
"frame-clock", frame_clock,
"native", window,
NULL);
GDK_END_MACOS_ALLOC_POOL;
return g_steal_pointer (&self);
}
void
_gdk_macos_toplevel_surface_attach_to_parent (GdkMacosToplevelSurface *self)
{
+2 -1
View File
@@ -967,6 +967,8 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass *class)
object_class->dispose = gdk_wayland_display_dispose;
object_class->finalize = gdk_wayland_display_finalize;
display_class->toplevel_type = GDK_TYPE_WAYLAND_TOPLEVEL;
display_class->popup_type = GDK_TYPE_WAYLAND_POPUP;
display_class->cairo_context_type = GDK_TYPE_WAYLAND_CAIRO_CONTEXT;
#ifdef GDK_RENDERING_VULKAN
@@ -987,7 +989,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
display_class->get_startup_notification_id = gdk_wayland_display_get_startup_notification_id;
G_GNUC_END_IGNORE_DEPRECATIONS
display_class->notify_startup_complete = gdk_wayland_display_notify_startup_complete;
display_class->create_surface = _gdk_wayland_display_create_surface;
display_class->get_keymap = _gdk_wayland_display_get_keymap;
display_class->init_gl = gdk_wayland_display_init_gl;
+5 -4
View File
@@ -24,6 +24,7 @@
#include "gdkdisplay-wayland.h"
#include <glib/gi18n-lib.h>
#include "gdkseat-wayland.h"
#include "gdksurface-wayland-private.h"
#include "gdkdeviceprivate.h"
@@ -46,7 +47,6 @@ struct _GdkWaylandDrag
{
GdkDrag drag;
GdkSurface *dnd_surface;
struct wl_surface *dnd_wl_surface;
struct wl_data_source *data_source;
struct wl_data_offer *offer;
uint32_t serial;
@@ -382,8 +382,9 @@ _gdk_wayland_surface_drag_begin (GdkSurface *surface,
drag = GDK_DRAG (drag_wayland);
drag_wayland->dnd_surface = _gdk_wayland_display_create_surface (display, GDK_SURFACE_DRAG, NULL, 0, 0, 100, 100);
drag_wayland->dnd_wl_surface = gdk_wayland_surface_get_wl_surface (drag_wayland->dnd_surface);
drag_wayland->dnd_surface = g_object_new (GDK_TYPE_WAYLAND_DRAG_SURFACE,
"display", display,
NULL);
gdk_wayland_drag_create_data_source (drag);
@@ -395,7 +396,7 @@ _gdk_wayland_surface_drag_begin (GdkSurface *surface,
wl_data_device_start_drag (gdk_wayland_device_get_data_device (device),
drag_wayland->data_source,
gdk_wayland_surface_get_wl_surface (surface),
drag_wayland->dnd_wl_surface,
gdk_wayland_surface_get_wl_surface (drag_wayland->dnd_surface),
_gdk_wayland_seat_get_implicit_grab_serial (seat, NULL));
cursor = gdk_drag_get_cursor (drag, gdk_drag_get_selected_action (drag));
+16
View File
@@ -101,11 +101,27 @@ gdk_wayland_drag_surface_compute_size (GdkSurface *surface)
return FALSE;
}
static void
gdk_wayland_drag_surface_constructed (GObject *object)
{
GdkSurface *surface = GDK_SURFACE (object);
GdkFrameClock *frame_clock;
frame_clock = _gdk_frame_clock_idle_new ();
gdk_surface_set_frame_clock (surface, frame_clock);
g_object_unref (frame_clock);
G_OBJECT_CLASS (gdk_wayland_drag_surface_parent_class)->constructed (object);
}
static void
gdk_wayland_drag_surface_class_init (GdkWaylandDragSurfaceClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GdkSurfaceClass *surface_class = GDK_SURFACE_CLASS (class);
object_class->constructed = gdk_wayland_drag_surface_constructed;
surface_class->compute_size = gdk_wayland_drag_surface_compute_size;
}
+3
View File
@@ -75,6 +75,9 @@ gdk_wayland_gl_context_end_frame (GdkDrawContext *draw_context,
WL_SURFACE_OFFSET_SINCE_VERSION)
wl_surface_offset (impl->display_server.wl_surface, dx, dy);
/* We should do ths when setting up the EGLSurface, but we don't make_current then */
eglSwapInterval (gdk_display_get_egl_display (gdk_draw_context_get_display (draw_context)), 0);
GDK_DRAW_CONTEXT_CLASS (gdk_wayland_gl_context_parent_class)->end_frame (draw_context, painted);
gdk_wayland_surface_notify_committed (surface);
+12
View File
@@ -1040,6 +1040,17 @@ gdk_wayland_popup_init (GdkWaylandPopup *popup)
{
}
static void
gdk_wayland_popup_constructed (GObject *object)
{
GdkWaylandPopup *self = GDK_WAYLAND_POPUP (object);
GdkSurface *surface = GDK_SURFACE (self);
gdk_surface_set_frame_clock (surface, gdk_surface_get_frame_clock (gdk_popup_get_parent (GDK_POPUP (self))));
G_OBJECT_CLASS (gdk_wayland_popup_parent_class)->constructed (object);
}
static void
gdk_wayland_popup_get_property (GObject *object,
guint prop_id,
@@ -1097,6 +1108,7 @@ gdk_wayland_popup_class_init (GdkWaylandPopupClass *class)
GdkSurfaceClass *surface_class = GDK_SURFACE_CLASS (class);
GdkWaylandSurfaceClass *wayland_surface_class = GDK_WAYLAND_SURFACE_CLASS (class);
object_class->constructed = gdk_wayland_popup_constructed;
object_class->get_property = gdk_wayland_popup_get_property;
object_class->set_property = gdk_wayland_popup_set_property;
-8
View File
@@ -157,14 +157,6 @@ void gdk_wayland_drop_set_source_actions (GdkDrop
void gdk_wayland_drop_set_action (GdkDrop *drop,
uint32_t action);
GdkSurface * _gdk_wayland_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type,
GdkSurface *parent,
int x,
int y,
int width,
int height);
void _gdk_wayland_display_create_seat (GdkWaylandDisplay *display,
guint32 id,
struct wl_seat *seat);
+1 -1
View File
@@ -42,11 +42,11 @@ struct _GdkWaylandSurface
} display_server;
struct wl_event_queue *event_queue;
struct wl_callback *frame_callback;
unsigned int initial_configure_received : 1;
unsigned int has_uncommitted_ack_configure : 1;
unsigned int mapped : 1;
unsigned int awaiting_frame : 1;
unsigned int awaiting_frame_frozen : 1;
int pending_buffer_offset_x;
+66 -150
View File
@@ -28,6 +28,7 @@
#include "gdkmonitor-wayland.h"
#include "gdkpopupprivate.h"
#include "gdkprivate-wayland.h"
#include "gdkrectangleprivate.h"
#include "gdkseat-wayland.h"
#include "gdksurfaceprivate.h"
#include "gdktoplevelprivate.h"
@@ -107,20 +108,6 @@ fill_presentation_time_from_frame_time (GdkFrameTimings *timings,
}
}
static const char *
get_default_title (void)
{
const char *title;
title = g_get_application_name ();
if (!title)
title = g_get_prgname ();
if (!title)
title = "";
return title;
}
static gboolean
is_realized_shell_surface (GdkWaylandSurface *impl)
{
@@ -286,17 +273,13 @@ frame_callback (void *data,
gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "wayland", "frame event");
GDK_DISPLAY_DEBUG (GDK_DISPLAY (display_wayland), EVENTS, "frame %p", surface);
wl_callback_destroy (callback);
g_assert (impl->frame_callback == callback);
g_assert (!GDK_SURFACE_DESTROYED (surface));
if (GDK_SURFACE_DESTROYED (surface))
return;
if (!impl->awaiting_frame)
return;
g_clear_pointer (&impl->frame_callback, wl_callback_destroy);
GDK_WAYLAND_SURFACE_GET_CLASS (impl)->handle_frame (impl);
impl->awaiting_frame = FALSE;
if (impl->awaiting_frame_frozen)
{
impl->awaiting_frame_frozen = FALSE;
@@ -384,20 +367,17 @@ gdk_wayland_surface_request_layout (GdkSurface *surface)
void
gdk_wayland_surface_request_frame (GdkSurface *surface)
{
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
struct wl_callback *callback;
GdkWaylandSurface *self = GDK_WAYLAND_SURFACE (surface);
GdkFrameClock *clock;
if (impl->awaiting_frame)
return;
g_assert (self->frame_callback == NULL);
clock = gdk_surface_get_frame_clock (surface);
callback = wl_surface_frame (impl->display_server.wl_surface);
wl_proxy_set_queue ((struct wl_proxy *) callback, NULL);
wl_callback_add_listener (callback, &frame_listener, surface);
impl->pending_frame_counter = gdk_frame_clock_get_frame_counter (clock);
impl->awaiting_frame = TRUE;
self->frame_callback = wl_surface_frame (self->display_server.wl_surface);
wl_proxy_set_queue ((struct wl_proxy *) self->frame_callback, NULL);
wl_callback_add_listener (self->frame_callback, &frame_listener, surface);
self->pending_frame_counter = gdk_frame_clock_get_frame_counter (clock);
}
gboolean
@@ -436,9 +416,10 @@ on_frame_clock_after_paint (GdkFrameClock *clock,
gdk_wayland_surface_notify_committed (surface);
}
if (impl->awaiting_frame &&
if (impl->frame_callback &&
impl->pending_frame_counter == gdk_frame_clock_get_frame_counter (clock))
{
g_assert (!impl->awaiting_frame_frozen);
impl->awaiting_frame_frozen = TRUE;
gdk_surface_freeze_updates (surface);
}
@@ -488,6 +469,7 @@ gdk_wayland_surface_attach_image (GdkSurface *surface,
{
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
cairo_rectangle_int_t rect;
uint32_t wl_surface_version;
int i, n;
if (GDK_SURFACE_DESTROYED (surface))
@@ -495,14 +477,15 @@ gdk_wayland_surface_attach_image (GdkSurface *surface,
g_assert (_gdk_wayland_is_shm_surface (cairo_surface));
wl_surface_version = wl_surface_get_version (impl->display_server.wl_surface);
/* Attach this new buffer to the surface */
wl_surface_attach (impl->display_server.wl_surface,
_gdk_wayland_shm_surface_get_wl_buffer (cairo_surface),
0, 0);
if ((impl->pending_buffer_offset_x || impl->pending_buffer_offset_y) &&
wl_surface_get_version (impl->display_server.wl_surface) >=
WL_SURFACE_OFFSET_SINCE_VERSION)
wl_surface_version >= WL_SURFACE_OFFSET_SINCE_VERSION)
wl_surface_offset (impl->display_server.wl_surface,
impl->pending_buffer_offset_x,
impl->pending_buffer_offset_y);
@@ -513,7 +496,16 @@ gdk_wayland_surface_attach_image (GdkSurface *surface,
for (i = 0; i < n; i++)
{
cairo_region_get_rectangle (damage, i, &rect);
wl_surface_damage (impl->display_server.wl_surface, rect.x, rect.y, rect.width, rect.height);
if (wl_surface_version >= WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION)
{
float scale = gdk_surface_get_scale (surface);
gdk_rectangle_transform_affine (&rect, scale, scale, 0, 0, &rect);
wl_surface_damage_buffer (impl->display_server.wl_surface, rect.x, rect.y, rect.width, rect.height);
}
else
{
wl_surface_damage (impl->display_server.wl_surface, rect.x, rect.y, rect.width, rect.height);
}
}
}
@@ -525,21 +517,6 @@ gdk_wayland_surface_beep (GdkSurface *surface)
return TRUE;
}
static void
gdk_wayland_surface_constructed (GObject *object)
{
GdkSurface *surface = GDK_SURFACE (object);
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
GdkWaylandDisplay *display_wayland =
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
G_OBJECT_CLASS (gdk_wayland_surface_parent_class)->constructed (object);
impl->event_queue = wl_display_create_queue (display_wayland->wl_display);
display_wayland->event_queues = g_list_prepend (display_wayland->event_queues,
impl->event_queue);
}
static void
gdk_wayland_surface_dispose (GObject *object)
{
@@ -814,6 +791,45 @@ gdk_wayland_surface_create_wl_surface (GdkSurface *surface)
self->display_server.wl_surface = wl_surface;
}
static void
gdk_wayland_surface_constructed (GObject *object)
{
GdkSurface *surface = GDK_SURFACE (object);
GdkWaylandSurface *self = GDK_WAYLAND_SURFACE (surface);
GdkDisplay *display = gdk_surface_get_display (surface);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
GdkFrameClock *frame_clock = gdk_surface_get_frame_clock (surface);
self->event_queue = wl_display_create_queue (display_wayland->wl_display);
display_wayland->event_queues = g_list_prepend (display_wayland->event_queues,
self->event_queue);
/* More likely to be right than just assuming 1 */
if (wl_compositor_get_version (display_wayland->compositor) >= WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION)
{
GdkMonitor *monitor = g_list_model_get_item (gdk_display_get_monitors (display), 0);
if (monitor)
{
guint32 monitor_scale = gdk_monitor_get_scale_factor (monitor);
if (monitor_scale != 1)
{
self->scale = GDK_FRACTIONAL_SCALE_INIT_INT (monitor_scale);
self->buffer_scale_dirty = TRUE;
}
g_object_unref (monitor);
}
}
gdk_wayland_surface_create_wl_surface (surface);
g_signal_connect (frame_clock, "before-paint", G_CALLBACK (on_frame_clock_before_paint), surface);
g_signal_connect (frame_clock, "after-paint", G_CALLBACK (on_frame_clock_after_paint), surface);
G_OBJECT_CLASS (gdk_wayland_surface_parent_class)->constructed (object);
}
static void
gdk_wayland_surface_destroy_wl_surface (GdkWaylandSurface *self)
{
@@ -831,100 +847,6 @@ gdk_wayland_surface_destroy_wl_surface (GdkWaylandSurface *self)
g_clear_pointer (&self->display_server.outputs, g_slist_free);
}
GdkSurface *
_gdk_wayland_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type,
GdkSurface *parent,
int x,
int y,
int width,
int height)
{
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
GdkSurface *surface;
GdkFrameClock *frame_clock;
if (parent)
frame_clock = g_object_ref (gdk_surface_get_frame_clock (parent));
else
frame_clock = _gdk_frame_clock_idle_new ();
switch (surface_type)
{
case GDK_SURFACE_TOPLEVEL:
g_warn_if_fail (parent == NULL);
surface = g_object_new (GDK_TYPE_WAYLAND_TOPLEVEL,
"display", display,
"frame-clock", frame_clock,
"title", get_default_title (),
NULL);
display_wayland->toplevels = g_list_prepend (display_wayland->toplevels, surface);
break;
case GDK_SURFACE_POPUP:
g_warn_if_fail (parent != NULL);
surface = g_object_new (GDK_TYPE_WAYLAND_POPUP,
"parent", parent,
"display", display,
"frame-clock", frame_clock,
NULL);
break;
case GDK_SURFACE_DRAG:
g_warn_if_fail (parent == NULL);
surface = g_object_new (GDK_TYPE_WAYLAND_DRAG_SURFACE,
"display", display,
"frame-clock", frame_clock,
NULL);
break;
default:
g_assert_not_reached ();
break;
}
if (width > 65535)
{
g_warning ("Native Surfaces wider than 65535 pixels are not supported");
width = 65535;
}
if (height > 65535)
{
g_warning ("Native Surfaces taller than 65535 pixels are not supported");
height = 65535;
}
surface->x = x;
surface->y = y;
surface->width = width;
surface->height = height;
/* More likely to be right than just assuming 1 */
if (wl_compositor_get_version (display_wayland->compositor) >= WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION)
{
GdkMonitor *monitor = g_list_model_get_item (gdk_display_get_monitors (display), 0);
if (monitor)
{
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
guint32 monitor_scale = gdk_monitor_get_scale_factor (monitor);
if (monitor_scale != 1)
{
impl->scale = GDK_FRACTIONAL_SCALE_INIT_INT (monitor_scale);
impl->buffer_scale_dirty = TRUE;
}
g_object_unref (monitor);
}
}
gdk_wayland_surface_create_wl_surface (surface);
g_signal_connect (frame_clock, "before-paint", G_CALLBACK (on_frame_clock_before_paint), surface);
g_signal_connect (frame_clock, "after-paint", G_CALLBACK (on_frame_clock_after_paint), surface);
g_object_unref (frame_clock);
return surface;
}
static void
maybe_notify_mapped (GdkSurface *surface)
{
@@ -1057,7 +979,7 @@ gdk_wayland_surface_hide_surface (GdkSurface *surface)
unmap_popups_for_surface (surface);
impl->awaiting_frame = FALSE;
g_clear_pointer (&impl->frame_callback, wl_callback_destroy);
if (impl->awaiting_frame_frozen)
{
impl->awaiting_frame_frozen = FALSE;
@@ -1216,11 +1138,8 @@ static void
gdk_wayland_surface_destroy (GdkSurface *surface,
gboolean foreign_destroy)
{
GdkWaylandDisplay *display;
GdkFrameClock *frame_clock;
g_return_if_fail (GDK_IS_SURFACE (surface));
/* Wayland surfaces can't be externally destroyed; we may possibly
* eventually want to use this path at display close-down
*/
@@ -1233,9 +1152,6 @@ gdk_wayland_surface_destroy (GdkSurface *surface,
frame_clock = gdk_surface_get_frame_clock (surface);
g_signal_handlers_disconnect_by_func (frame_clock, on_frame_clock_before_paint, surface);
g_signal_handlers_disconnect_by_func (frame_clock, on_frame_clock_after_paint, surface);
display = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
display->toplevels = g_list_remove (display->toplevels, surface);
}
static void
+46 -14
View File
@@ -823,6 +823,20 @@ gdk_wayland_surface_create_xdg_toplevel (GdkWaylandToplevel *wayland_toplevel)
wl_surface_commit (wayland_surface->display_server.wl_surface);
}
static const char *
get_default_title (void)
{
const char *title;
title = g_get_application_name ();
if (!title)
title = g_get_prgname ();
if (!title)
title = "";
return title;
}
static void
gdk_wayland_toplevel_init (GdkWaylandToplevel *toplevel)
{
@@ -830,6 +844,8 @@ gdk_wayland_toplevel_init (GdkWaylandToplevel *toplevel)
toplevel->shortcuts_inhibitors = g_hash_table_new (NULL, NULL);
toplevel->saved_width = -1;
toplevel->saved_height = -1;
toplevel->title = g_strdup (get_default_title ());
}
static void
@@ -1259,28 +1275,43 @@ gdk_wayland_toplevel_get_property (GObject *object,
static void
gdk_wayland_toplevel_finalize (GObject *object)
{
GdkWaylandToplevel *wayland_toplevel;
GdkWaylandToplevel *self = GDK_WAYLAND_TOPLEVEL (object);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (GDK_SURFACE (object)));
g_return_if_fail (GDK_IS_WAYLAND_TOPLEVEL (object));
display_wayland->toplevels = g_list_remove (display_wayland->toplevels, self);
wayland_toplevel = GDK_WAYLAND_TOPLEVEL (object);
if (gdk_wayland_toplevel_is_exported (self))
gdk_wayland_toplevel_unexport_handle (GDK_TOPLEVEL (self));
if (gdk_wayland_toplevel_is_exported (wayland_toplevel))
gdk_wayland_toplevel_unexport_handle (GDK_TOPLEVEL (wayland_toplevel));
g_free (self->application.application_id);
g_free (self->application.app_menu_path);
g_free (self->application.menubar_path);
g_free (self->application.window_object_path);
g_free (self->application.application_object_path);
g_free (self->application.unique_bus_name);
g_free (wayland_toplevel->application.application_id);
g_free (wayland_toplevel->application.app_menu_path);
g_free (wayland_toplevel->application.menubar_path);
g_free (wayland_toplevel->application.window_object_path);
g_free (wayland_toplevel->application.application_object_path);
g_free (wayland_toplevel->application.unique_bus_name);
g_free (wayland_toplevel->title);
g_clear_pointer (&wayland_toplevel->shortcuts_inhibitors, g_hash_table_unref);
g_free (self->title);
g_clear_pointer (&self->shortcuts_inhibitors, g_hash_table_unref);
G_OBJECT_CLASS (gdk_wayland_toplevel_parent_class)->finalize (object);
}
static void
gdk_wayland_toplevel_constructed (GObject *object)
{
GdkSurface *surface = GDK_SURFACE (object);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
GdkFrameClock *frame_clock;
frame_clock = _gdk_frame_clock_idle_new ();
gdk_surface_set_frame_clock (surface, frame_clock);
g_object_unref (frame_clock);
display_wayland->toplevels = g_list_prepend (display_wayland->toplevels, object);
G_OBJECT_CLASS (gdk_wayland_toplevel_parent_class)->constructed (object);
}
static void
gdk_wayland_toplevel_class_init (GdkWaylandToplevelClass *class)
{
@@ -1291,6 +1322,7 @@ gdk_wayland_toplevel_class_init (GdkWaylandToplevelClass *class)
object_class->get_property = gdk_wayland_toplevel_get_property;
object_class->set_property = gdk_wayland_toplevel_set_property;
object_class->finalize = gdk_wayland_toplevel_finalize;
object_class->constructed = gdk_wayland_toplevel_constructed;
surface_class->compute_size = gdk_wayland_toplevel_compute_size;
+1 -3
View File
@@ -2546,13 +2546,11 @@ transmute_cf_shell_id_list_to_text_uri_list (const guchar *data,
ILFree (file_id_full);
}
*set_data = (guchar *) result->str;
if (set_data_length)
*set_data_length = result->len;
*set_data = (guchar *) g_string_free (result, FALSE);
if (set_data_destroy)
*set_data_destroy = g_free;
g_string_free (result, FALSE);
}
void
+1 -5
View File
@@ -427,11 +427,7 @@ wintab_init_check (GdkDeviceManagerWin32 *device_manager)
ndevices, ncursors));
#endif
/* Create a dummy window to receive wintab events */
wintab_window =
_gdk_win32_display_create_surface (display,
GDK_SURFACE_DRAG,
NULL,
-100, -100, 2, 2);
wintab_window = gdk_win32_drag_surface_new (display);
g_object_ref (wintab_window);
+7 -7
View File
@@ -28,6 +28,7 @@
#include "gdkdisplay-win32.h"
#include "gdkdevicemanager-win32.h"
#include "gdkglcontext-win32.h"
#include "gdksurface-win32.h"
#include "gdkwin32display.h"
#include "gdkwin32screen.h"
#include "gdkwin32surface.h"
@@ -1181,6 +1182,7 @@ gdk_win32_display_init_gl (GdkDisplay *display,
{
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display);
HDC init_gl_hdc = NULL;
GdkGLContext *context;
if (display_win32->dummy_context_wgl.hdc == NULL)
display_win32->dummy_context_wgl.hdc = GetDC (display_win32->hwnd);
@@ -1215,12 +1217,9 @@ gdk_win32_display_init_gl (GdkDisplay *display,
}
#endif
if (gdk_win32_display_init_wgl (display, error))
{
return g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_WGL,
"display", display,
NULL);
}
context = gdk_win32_display_init_wgl (display, error);
if (context)
return context;
#ifdef HAVE_EGL
g_clear_error (error);
@@ -1268,6 +1267,8 @@ gdk_win32_display_class_init (GdkWin32DisplayClass *klass)
object_class->dispose = gdk_win32_display_dispose;
object_class->finalize = gdk_win32_display_finalize;
display_class->toplevel_type = GDK_TYPE_WIN32_TOPLEVEL;
display_class->popup_type = GDK_TYPE_WIN32_POPUP;
display_class->cairo_context_type = GDK_TYPE_WIN32_CAIRO_CONTEXT;
display_class->get_name = gdk_win32_display_get_name;
@@ -1281,7 +1282,6 @@ gdk_win32_display_class_init (GdkWin32DisplayClass *klass)
display_class->get_next_serial = gdk_win32_display_get_next_serial;
display_class->notify_startup_complete = gdk_win32_display_notify_startup_complete;
display_class->create_surface = _gdk_win32_display_create_surface;
display_class->get_keymap = _gdk_win32_display_get_keymap;
+2 -1
View File
@@ -24,6 +24,8 @@
#include "gdkwin32screen.h"
#include "gdkwin32cursor.h"
#include "gdkglversionprivate.h"
#ifdef HAVE_EGL
# include <epoxy/egl.h>
#endif
@@ -124,7 +126,6 @@ struct _GdkWin32Display
/* WGL/OpenGL Items */
GdkWin32GLDummyContextWGL dummy_context_wgl;
guint gl_version;
GListModel *monitors;
+1 -16
View File
@@ -37,8 +37,6 @@
#include <math.h>
#include <string.h>
#define GDK_NOTE(a,b)
/*
* Support for OLE-2 drag and drop added at Archaeopteryx Software, 2001
* For more information, do not contact Stephan R.A. Deibel (sdeibel@archaeopteryx.com),
@@ -1646,19 +1644,6 @@ _gdk_win32_dnd_exit (void)
CoUninitialize ();
}
static GdkSurface *
create_drag_surface (GdkDisplay *display)
{
GdkSurface *surface;
surface = _gdk_win32_display_create_surface (display,
GDK_SURFACE_DRAG,
NULL,
0, 0, 100, 100);
return surface;
}
GdkDrag *
_gdk_win32_surface_drag_begin (GdkSurface *surface,
GdkDevice *device,
@@ -1698,7 +1683,7 @@ _gdk_win32_surface_drag_begin (GdkSurface *surface,
g_set_object (&drag_win32->grab_surface, surface);
drag_win32->drag_surface = create_drag_surface (gdk_surface_get_display (surface));
drag_win32->drag_surface = gdk_win32_drag_surface_new (gdk_surface_get_display (surface));
if (!drag_context_grab (drag))
{
+195 -190
View File
@@ -247,16 +247,17 @@ gdk_init_dummy_wgl_context (GdkWin32Display *display_win32)
return best_idx;
}
gboolean
GdkGLContext *
gdk_win32_display_init_wgl (GdkDisplay *display,
GError **error)
{
int best_idx = 0;
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display);
GdkGLContext *context;
HDC hdc;
if (!gdk_gl_backend_can_be_used (GDK_GL_WGL, error))
return FALSE;
return NULL;
/* acquire and cache dummy Window (HWND & HDC) and
* dummy GL Context, it is used to query functions
@@ -275,25 +276,7 @@ gdk_win32_display_init_wgl (GdkDisplay *display,
GDK_GL_ERROR_NOT_AVAILABLE,
_("No GL implementation is available"));
return FALSE;
}
display_win32->gl_version = epoxy_gl_version ();
/* We must have OpenGL/WGL 2.0 or later, or have the GL_ARB_shader_objects extension */
if (display_win32->gl_version < 20)
{
if (!epoxy_has_gl_extension ("GL_ARB_shader_objects"))
{
wglMakeCurrent (NULL, NULL);
wglDeleteContext (display_win32->dummy_context_wgl.hglrc);
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_NOT_AVAILABLE,
_("No GL implementation is available"));
return FALSE;
}
return NULL;
}
display_win32->hasWglARBCreateContext =
@@ -307,45 +290,92 @@ gdk_win32_display_init_wgl (GdkDisplay *display,
display_win32->hasWglARBmultisample =
epoxy_has_wgl_extension (hdc, "WGL_ARB_multisample");
GDK_NOTE (OPENGL,
g_print ("WGL API version %d.%d found\n"
" - Vendor: %s\n"
" - Checked extensions:\n"
"\t* WGL_ARB_pixel_format: %s\n"
"\t* WGL_ARB_create_context: %s\n"
"\t* WGL_EXT_swap_control: %s\n"
"\t* WGL_OML_sync_control: %s\n"
"\t* WGL_ARB_multisample: %s\n",
display_win32->gl_version / 10,
display_win32->gl_version % 10,
glGetString (GL_VENDOR),
display_win32->hasWglARBPixelFormat ? "yes" : "no",
display_win32->hasWglARBCreateContext ? "yes" : "no",
display_win32->hasWglEXTSwapControl ? "yes" : "no",
display_win32->hasWglOMLSyncControl ? "yes" : "no",
display_win32->hasWglARBmultisample ? "yes" : "no"));
context = g_object_new (GDK_TYPE_WIN32_GL_CONTEXT_WGL,
"display", display,
NULL);
if (!gdk_gl_context_realize (context, error))
{
g_object_unref (context);
return NULL;
}
#if G_ENABLE_DEBUG
{
int major, minor;
gdk_gl_context_get_version (context, &major, &minor);
GDK_NOTE (OPENGL, g_print ("WGL API version %d.%d found\n"
" - Vendor: %s\n"
" - Checked extensions:\n"
"\t* WGL_ARB_pixel_format: %s\n"
"\t* WGL_ARB_create_context: %s\n"
"\t* WGL_EXT_swap_control: %s\n"
"\t* WGL_OML_sync_control: %s\n"
"\t* WGL_ARB_multisample: %s\n",
major, minor,
glGetString (GL_VENDOR),
display_win32->hasWglARBPixelFormat ? "yes" : "no",
display_win32->hasWglARBCreateContext ? "yes" : "no",
display_win32->hasWglEXTSwapControl ? "yes" : "no",
display_win32->hasWglOMLSyncControl ? "yes" : "no",
display_win32->hasWglARBmultisample ? "yes" : "no"));
}
#endif
wglMakeCurrent (NULL, NULL);
return TRUE;
return context;
}
/* Setup the legacy context after creating it */
static gboolean
ensure_legacy_wgl_context (HDC hdc,
HGLRC hglrc_legacy,
GdkGLContext *share)
ensure_legacy_wgl_context (HDC hdc,
HGLRC hglrc_legacy,
GdkGLContext *share,
GdkGLVersion *version,
GError **error)
{
GdkWin32GLContextWGL *context_wgl;
GdkGLVersion legacy_version;
GDK_NOTE (OPENGL,
g_print ("Creating legacy WGL context (version:%d.%d)\n",
gdk_gl_version_get_major (version),
gdk_gl_version_get_minor (version)));
if (!wglMakeCurrent (hdc, hglrc_legacy))
return FALSE;
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_NOT_AVAILABLE,
_("Unable to create a GL context"));
return FALSE;
}
gdk_gl_version_init_epoxy (&legacy_version);
if (!gdk_gl_version_greater_equal (&legacy_version, version))
{
g_set_error (error, GDK_GL_ERROR,
GDK_GL_ERROR_NOT_AVAILABLE,
_("WGL version %d.%d is too low, need at least %d.%d"),
gdk_gl_version_get_major (&legacy_version),
gdk_gl_version_get_minor (&legacy_version),
gdk_gl_version_get_major (version),
gdk_gl_version_get_minor (version));
return FALSE;
}
*version = legacy_version;
if (share != NULL)
{
context_wgl = GDK_WIN32_GL_CONTEXT_WGL (share);
return wglShareLists (hglrc_legacy, context_wgl->wgl_context);
if (!wglShareLists (hglrc_legacy, context_wgl->wgl_context))
{
g_set_error (error, GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
_("GL implementation cannot share GL contexts"));
return FALSE;
}
}
return TRUE;
@@ -356,130 +386,138 @@ create_wgl_context_with_attribs (HDC hdc,
HGLRC hglrc_base,
GdkGLContext *share,
int flags,
int major,
int minor,
gboolean *is_legacy)
gboolean is_legacy,
GdkGLVersion *version)
{
HGLRC hglrc;
GdkWin32GLContextWGL *context_wgl;
const GdkGLVersion *supported_versions = gdk_gl_versions_get_for_api (GDK_GL_API_GL);
guint i;
/* if we have wglCreateContextAttribsARB(), create a
* context with the compatibility profile if a legacy
* context is requested, or when we go into fallback mode
*/
int profile = *is_legacy ? WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB :
WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
GDK_NOTE (OPENGL,
g_print ("Creating %s WGL context (version:%d.%d, debug:%s, forward:%s)\n",
is_legacy ? "core" : "compat",
gdk_gl_version_get_major (version),
gdk_gl_version_get_minor (version),
(flags & WGL_CONTEXT_DEBUG_BIT_ARB) ? "yes" : "no",
(flags & WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB) ? "yes" : "no"));
int attribs[] = {
WGL_CONTEXT_PROFILE_MASK_ARB, profile,
WGL_CONTEXT_MAJOR_VERSION_ARB, *is_legacy ? 3 : major,
WGL_CONTEXT_MINOR_VERSION_ARB, *is_legacy ? 0 : minor,
WGL_CONTEXT_FLAGS_ARB, flags,
0
};
for (i = 0; gdk_gl_version_greater_equal (&supported_versions[i], version); i++)
{
/* if we have wglCreateContextAttribsARB(), create a
* context with the compatibility profile if a legacy
* context is requested, or when we go into fallback mode
*/
int profile = is_legacy ? WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB :
WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
if (share != NULL)
context_wgl = GDK_WIN32_GL_CONTEXT_WGL (share);
int attribs[] = {
WGL_CONTEXT_PROFILE_MASK_ARB, profile,
WGL_CONTEXT_MAJOR_VERSION_ARB, gdk_gl_version_get_major (&supported_versions[i]),
WGL_CONTEXT_MINOR_VERSION_ARB, gdk_gl_version_get_minor (&supported_versions[i]),
WGL_CONTEXT_FLAGS_ARB, flags,
0
};
hglrc = wglCreateContextAttribsARB (hdc,
share != NULL ? context_wgl->wgl_context : NULL,
attribs);
if (share != NULL)
context_wgl = GDK_WIN32_GL_CONTEXT_WGL (share);
return hglrc;
hglrc = wglCreateContextAttribsARB (hdc,
share != NULL ? context_wgl->wgl_context : NULL,
attribs);
if (hglrc)
{
*version = supported_versions[i];
return hglrc;
}
}
return NULL;
}
static HGLRC
create_wgl_context (HDC hdc,
GdkGLContext *share,
int flags,
int major,
int minor,
gboolean *is_legacy,
gboolean hasWglARBCreateContext)
create_wgl_context (GdkGLContext *context,
HDC hdc,
gboolean hasWglARBCreateContext,
GdkGLContext *share,
int flags,
gboolean legacy,
GError **error)
{
/* We need a legacy context for *all* cases */
HGLRC hglrc_base = wglCreateContext (hdc);
gboolean success = TRUE;
HGLRC hglrc_base, hglrc;
GdkGLVersion version;
/* Save up the HDC and HGLRC that we are currently using, to restore back to it when we are done here */
HDC hdc_current = wglGetCurrentDC ();
HGLRC hglrc_current = wglGetCurrentContext ();
/* if we have no wglCreateContextAttribsARB(), return the legacy context when all is set */
if (*is_legacy && !hasWglARBCreateContext)
hglrc_base = wglCreateContext (hdc);
if (hglrc_base == NULL ||
!wglMakeCurrent (hdc, hglrc_base))
{
if (ensure_legacy_wgl_context (hdc, hglrc_base, share))
{
wglMakeCurrent (hdc_current, hglrc_current);
return hglrc_base;
}
success = FALSE;
goto gl_fail;
g_clear_pointer (&hglrc_base, wglDeleteContext);
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_NOT_AVAILABLE,
_("Unable to create a GL context"));
return 0;
}
else
hglrc = NULL;
if (hasWglARBCreateContext)
{
HGLRC hglrc = NULL;
if (!wglMakeCurrent (hdc, hglrc_base))
if (!legacy)
{
success = FALSE;
goto gl_fail;
gdk_gl_context_get_matching_version (context,
GDK_GL_API_GL,
FALSE,
&version);
hglrc = create_wgl_context_with_attribs (hdc,
hglrc_base,
share,
flags,
FALSE,
&version);
}
hglrc = create_wgl_context_with_attribs (hdc,
hglrc_base,
share,
flags,
major,
minor,
is_legacy);
/* return the legacy context we have if it could be setup properly, in case the 3.0+ context creation failed */
if (hglrc == NULL)
{
if (!(*is_legacy))
{
/* If we aren't using a legacy context in the beginning, try again with a compatibility profile 3.0 context */
hglrc = create_wgl_context_with_attribs (hdc,
hglrc_base,
share,
flags,
0, 0,
is_legacy);
*is_legacy = TRUE;
}
if (hglrc == NULL)
{
if (!ensure_legacy_wgl_context (hdc, hglrc_base, share))
success = FALSE;
}
if (success)
GDK_NOTE (OPENGL, g_print ("Using legacy context as fallback\n"));
legacy = TRUE;
gdk_gl_context_get_matching_version (context,
GDK_GL_API_GL,
TRUE,
&version);
hglrc = create_wgl_context_with_attribs (hdc,
hglrc_base,
share,
flags,
TRUE,
&version);
}
}
gl_fail:
if (hglrc == NULL)
{
legacy = TRUE;
gdk_gl_context_get_matching_version (context,
GDK_GL_API_GL,
TRUE,
&version);
if (ensure_legacy_wgl_context (hdc, hglrc_base, share, &version, error))
hglrc = g_steal_pointer (&hglrc_base);
}
if (!success)
{
wglMakeCurrent (NULL, NULL);
wglDeleteContext (hglrc_base);
return NULL;
}
if (hglrc)
{
gdk_gl_context_set_version (context, &version);
gdk_gl_context_set_is_legacy (context, legacy);
}
wglMakeCurrent (hdc_current, hglrc_current);
g_clear_pointer (&hglrc_base, wglDeleteContext);
if (hglrc != NULL)
{
wglDeleteContext (hglrc_base);
return hglrc;
}
wglMakeCurrent (hdc_current, hglrc_current);
return hglrc_base;
}
return hglrc;
}
static gboolean
@@ -525,8 +563,6 @@ gdk_win32_gl_context_wgl_realize (GdkGLContext *context,
/* request flags and specific versions for core (3.2+) WGL context */
int flags = 0;
int major = 0;
int minor = 0;
HGLRC hglrc;
int pixel_format;
HDC hdc;
@@ -542,24 +578,6 @@ gdk_win32_gl_context_wgl_realize (GdkGLContext *context,
debug_bit = gdk_gl_context_get_debug_enabled (context);
compat_bit = gdk_gl_context_get_forward_compatible (context);
/*
* We may need a Core GL 4.1+ context in order to use the GL support in
* the GStreamer media widget backend (such as on Intel drivers), but
* wglCreateContextAttribsARB() may only give us the GL context version
* that we ask for here, and nothing more. So, improve things here by
* asking for the GL version that is reported to us via epoxy_gl_version(),
* rather than the default GL core 3.2 context.
*/
gdk_gl_context_get_clipped_version (context,
display_win32->gl_version / 10,
display_win32->gl_version % 10,
&major, &minor);
if (surface != NULL)
hdc = GDK_WIN32_SURFACE (surface)->hdc;
else
hdc = display_win32->dummy_context_wgl.hdc;
/*
* A legacy context cannot be shared with core profile ones, so this means we
* must stick to a legacy context if the shared context is a legacy context
@@ -568,6 +586,11 @@ gdk_win32_gl_context_wgl_realize (GdkGLContext *context,
? TRUE
: share != NULL && gdk_gl_context_is_legacy (share);
if (surface != NULL)
hdc = GDK_WIN32_SURFACE (surface)->hdc;
else
hdc = display_win32->dummy_context_wgl.hdc;
if (!set_wgl_pixformat_for_hdc (hdc,
&pixel_format,
display_win32))
@@ -587,30 +610,15 @@ gdk_win32_gl_context_wgl_realize (GdkGLContext *context,
if (compat_bit)
flags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
GDK_NOTE (OPENGL,
g_print ("Creating %s WGL context (version:%d.%d, debug:%s, forward:%s, legacy: %s)\n",
compat_bit ? "core" : "compat",
major,
minor,
debug_bit ? "yes" : "no",
compat_bit ? "yes" : "no",
legacy_bit ? "yes" : "no"));
hglrc = create_wgl_context (hdc,
hglrc = create_wgl_context (context,
hdc,
display_win32->hasWglARBCreateContext,
share,
flags,
major,
minor,
&legacy_bit,
display_win32->hasWglARBCreateContext);
legacy_bit,
error);
if (hglrc == NULL)
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_NOT_AVAILABLE,
_("Unable to create a GL context"));
return 0;
}
return 0;
GDK_NOTE (OPENGL,
g_print ("Created WGL context[%p], pixel_format=%d\n",
@@ -619,9 +627,6 @@ gdk_win32_gl_context_wgl_realize (GdkGLContext *context,
context_wgl->wgl_context = hglrc;
/* Ensure that any other context is created with a legacy bit set */
gdk_gl_context_set_is_legacy (context, legacy_bit);
return GDK_GL_API_GL;
}
@@ -715,10 +720,11 @@ gdk_win32_gl_context_wgl_init (GdkWin32GLContextWGL *wgl_context)
*/
gboolean
gdk_win32_display_get_wgl_version (GdkDisplay *display,
int *major,
int *minor)
int *major,
int *minor)
{
GdkWin32Display *display_win32;
GdkGLContext *context;
g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
if (!GDK_IS_WIN32_DISPLAY (display))
@@ -727,12 +733,11 @@ gdk_win32_display_get_wgl_version (GdkDisplay *display,
if (!gdk_gl_backend_can_be_used (GDK_GL_WGL, NULL))
return FALSE;
display_win32 = GDK_WIN32_DISPLAY (display);
context = gdk_display_get_gl_context (display);
if (context == NULL)
return FALSE;
if (major != NULL)
*major = display_win32->gl_version / 10;
if (minor != NULL)
*minor = display_win32->gl_version % 10;
gdk_gl_context_get_version (context, major, minor);
return TRUE;
}
+4 -4
View File
@@ -64,10 +64,10 @@ struct _GdkWin32GLContextClass
typedef struct _GdkWin32GLContextWGL GdkWin32GLContextWGL;
gboolean gdk_win32_display_init_wgl (GdkDisplay *display,
GError **error);
void gdk_win32_gl_context_wgl_bind_surface (GdkWin32GLContextWGL *ctx,
GdkWin32Surface *win32_surface);
GdkGLContext * gdk_win32_display_init_wgl (GdkDisplay *display,
GError **error);
void gdk_win32_gl_context_wgl_bind_surface (GdkWin32GLContextWGL *ctx,
GdkWin32Surface *win32_surface);
GType gdk_win32_gl_context_wgl_get_type (void) G_GNUC_CONST;
+7 -6
View File
@@ -354,12 +354,13 @@ reset_viewport (IDirectManipulationViewport *viewport)
HRESULT hr;
hr = IDirectManipulationViewport_GetPrimaryContent (viewport, iid, (void**)&content);
HR_CHECK (hr);
HR_CHECK_GOTO (hr, failed);
hr = IDirectManipulationContent_SyncContentTransform (content, identity,
G_N_ELEMENTS (identity));
HR_CHECK (hr);
HR_CHECK_GOTO (hr, failed);
failed:
IUnknown_Release (content);
}
@@ -384,7 +385,7 @@ create_viewport (GdkSurface *surface,
{
DIRECTMANIPULATION_CONFIGURATION configuration = 0;
HWND hwnd = GDK_SURFACE_HWND (surface);
IDirectManipulationViewportEventHandler *handler;
IDirectManipulationViewportEventHandler *handler = NULL;
DWORD cookie = 0;
HRESULT hr;
@@ -500,7 +501,7 @@ void gdk_dmanipulation_initialize_surface (GdkSurface *surface)
hr = IDirectManipulationManager_Activate (dmanipulation_manager,
GDK_SURFACE_HWND (surface));
HR_CHECK (hr);
HR_CHECK_RETURN (hr);
}
void gdk_dmanipulation_finalize_surface (GdkSurface *surface)
@@ -536,11 +537,11 @@ void gdk_dmanipulation_maybe_add_contact (GdkSurface *surface,
hr = IDirectManipulationViewport_SetContact (surface_win32->dmanipulation_viewport_pan,
pointer_id);
HR_CHECK (hr);
HR_CHECK_RETURN (hr);
hr = IDirectManipulationViewport_SetContact (surface_win32->dmanipulation_viewport_zoom,
pointer_id);
HR_CHECK (hr);
HR_CHECK_RETURN (hr);
}
}
-20
View File
@@ -109,16 +109,6 @@ gdk_win32_ensure_com (void)
return co_initialized;
}
static void
gdk_win32_finalize_com (void)
{
if (co_initialized)
{
CoUninitialize ();
co_initialized = FALSE;
}
}
gboolean
gdk_win32_ensure_ole (void)
{
@@ -142,16 +132,6 @@ gdk_win32_ensure_ole (void)
return ole_initialized;
}
static void
gdk_win32_finalize_ole (void)
{
if (ole_initialized)
{
OleUninitialize ();
ole_initialized = FALSE;
}
}
void
_gdk_win32_api_failed (const char *where,
const char *api)
-9
View File
@@ -276,7 +276,6 @@ void _gdk_other_api_failed (const char *where,
#define HR_CHECK_RETURN(hr) { if G_UNLIKELY (FAILED (hr)) return; }
#define HR_CHECK_RETURN_VAL(hr, val) { if G_UNLIKELY (FAILED (hr)) return val; }
#define HR_CHECK(hr)
#define HR_CHECK_GOTO(hr, label) { if G_UNLIKELY (FAILED (hr)) goto label; }
extern LRESULT CALLBACK _gdk_win32_surface_procedure (HWND, UINT, WPARAM, LPARAM);
@@ -382,14 +381,6 @@ GdkModifierType _gdk_win32_keymap_get_mod_mask (GdkWin32Keymap *keymap);
GdkKeymap *_gdk_win32_display_get_keymap (GdkDisplay *display);
GdkSurface *_gdk_win32_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type,
GdkSurface *parent,
int x,
int y,
int width,
int height);
/* stray GdkSurfaceImplWin32 members */
void _gdk_win32_surface_register_dnd (GdkSurface *window);
void _gdk_win32_surface_unregister_dnd (GdkSurface *window);
+87 -189
View File
@@ -135,14 +135,6 @@ static void gdk_win32_impl_frame_clock_after_paint (GdkFrameClock *clock,
G_DEFINE_TYPE (GdkWin32Surface, gdk_win32_surface, GDK_TYPE_SURFACE)
GType gdk_win32_toplevel_get_type (void) G_GNUC_CONST;
GType gdk_win32_popup_get_type (void) G_GNUC_CONST;
GType gdk_win32_drag_surface_get_type (void) G_GNUC_CONST;
#define GDK_TYPE_WIN32_TOPLEVEL (gdk_win32_toplevel_get_type ())
#define GDK_TYPE_WIN32_POPUP (gdk_win32_popup_get_type ())
#define GDK_TYPE_WIN32_DRAG_SURFACE (gdk_win32_drag_surface_get_type ())
static void
gdk_win32_surface_init (GdkWin32Surface *impl)
{
@@ -212,10 +204,6 @@ gdk_surface_win32_finalize (GObject *object)
g_assert (surface->transient_owner == NULL);
g_assert (surface->transient_children == NULL);
g_signal_handlers_disconnect_by_func (GDK_SURFACE (object),
gdk_win32_toplevel_state_callback,
NULL);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -334,7 +322,7 @@ get_default_title (void)
* get its own class
*/
static ATOM
RegisterGdkClass (GdkSurfaceType wtype)
RegisterGdkClass (GType wtype)
{
static ATOM klassTOPLEVEL = 0;
static ATOM klassTEMP = 0;
@@ -407,10 +395,8 @@ RegisterGdkClass (GdkSurfaceType wtype)
/* MSDN: CS_OWNDC is needed for OpenGL contexts */
wcl.style |= CS_OWNDC;
switch (wtype)
if (wtype != GDK_TYPE_WIN32_DRAG_SURFACE)
{
case GDK_SURFACE_TOPLEVEL:
case GDK_SURFACE_POPUP:
if (0 == klassTOPLEVEL)
{
wcl.lpszClassName = L"gdkSurfaceToplevel";
@@ -419,9 +405,9 @@ RegisterGdkClass (GdkSurfaceType wtype)
klassTOPLEVEL = RegisterClassExW (&wcl);
}
klass = klassTOPLEVEL;
break;
case GDK_SURFACE_DRAG:
}
else
{
if (klassTEMP == 0)
{
wcl.lpszClassName = L"gdkSurfaceTemp";
@@ -431,12 +417,6 @@ RegisterGdkClass (GdkSurfaceType wtype)
}
klass = klassTEMP;
break;
default:
g_assert_not_reached ();
break;
}
if (klass == 0)
@@ -447,86 +427,20 @@ RegisterGdkClass (GdkSurfaceType wtype)
return klass;
}
/*
* Create native windows.
*
* With the default Gdk the created windows are mostly toplevel windows.
*
* Placement of the window is derived from the passed in window,
* except for toplevel window where OS/Window Manager placement
* is used.
*
* [1] http://mail.gnome.org/archives/gtk-devel-list/2010-August/msg00214.html
*/
GdkSurface *
_gdk_win32_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type,
GdkSurface *parent,
int x,
int y,
int width,
int height)
static void
gdk_win32_surface_constructed (GObject *object)
{
HWND hwndNew;
GdkWin32Surface *impl = GDK_WIN32_SURFACE (object);
GdkSurface *surface = GDK_SURFACE (impl);
GdkDisplay *display = gdk_surface_get_display (surface);
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display);
GdkFrameClock *frame_clock;
HANDLE owner;
ATOM klass = 0;
DWORD dwStyle = 0, dwExStyle;
RECT rect;
GdkWin32Surface *impl;
GdkWin32Display *display_win32;
GdkSurface *surface;
const char *title;
wchar_t *wtitle;
int window_width, window_height;
int window_x, window_y;
int real_x = 0, real_y = 0;
GdkFrameClock *frame_clock;
g_return_val_if_fail (display == _gdk_display, NULL);
GDK_NOTE (MISC,
g_print ("_gdk_surface_new: %s\n", (surface_type == GDK_SURFACE_TOPLEVEL ? "TOPLEVEL" :
(surface_type == GDK_SURFACE_DRAG? "TEMP" :
(surface_type == GDK_SURFACE_DRAG ? "POPUP" : "???")))));
display_win32 = GDK_WIN32_DISPLAY (display);
if (parent)
frame_clock = g_object_ref (gdk_surface_get_frame_clock (parent));
else
frame_clock = _gdk_frame_clock_idle_new ();
switch (surface_type)
{
case GDK_SURFACE_TOPLEVEL:
impl = g_object_new (GDK_TYPE_WIN32_TOPLEVEL,
"display", display,
"frame-clock", frame_clock,
NULL);
break;
case GDK_SURFACE_POPUP:
impl = g_object_new (GDK_TYPE_WIN32_POPUP,
"parent", parent,
"display", display,
"frame-clock", frame_clock,
NULL);
break;
case GDK_SURFACE_DRAG:
impl = g_object_new (GDK_TYPE_WIN32_DRAG_SURFACE,
"display", display,
"frame-clock", frame_clock,
NULL);
break;
default:
g_assert_not_reached ();
break;
}
surface = GDK_SURFACE (impl);
surface->x = x;
surface->y = y;
surface->width = width;
surface->height = height;
impl->surface_scale = gdk_win32_display_get_monitor_scale_factor (display_win32, NULL, NULL);
@@ -536,86 +450,60 @@ _gdk_win32_display_create_surface (GdkDisplay *display,
/* MSDN: We need WS_CLIPCHILDREN and WS_CLIPSIBLINGS for GL Context Creation */
dwStyle = WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
switch (surface_type)
if (G_OBJECT_TYPE (impl) == GDK_TYPE_WIN32_TOPLEVEL)
{
case GDK_SURFACE_TOPLEVEL:
dwStyle |= WS_OVERLAPPEDWINDOW;
break;
case GDK_SURFACE_DRAG:
dwExStyle |= WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
/* fall through */
case GDK_SURFACE_POPUP:
dwStyle |= WS_POPUP;
/* Only popup and temp windows are fit to use the Owner Window mechanism */
if (parent != NULL)
owner = GDK_SURFACE_HWND (parent);
break;
default:
g_assert_not_reached ();
frame_clock = _gdk_frame_clock_idle_new ();
}
rect.left = x * impl->surface_scale;
rect.top = y * impl->surface_scale;
rect.right = rect.left + width * impl->surface_scale;
rect.bottom = rect.top + height * impl->surface_scale;
AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle);
real_x = x * impl->surface_scale;
real_y = y * impl->surface_scale;
if (surface_type == GDK_SURFACE_TOPLEVEL)
else if (G_OBJECT_TYPE (impl) == GDK_TYPE_WIN32_DRAG_SURFACE)
{
/* We initially place it at default so that we can get the
default window positioning if we want */
window_x = window_y = CW_USEDEFAULT;
dwExStyle |= WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
dwStyle |= WS_POPUP;
frame_clock = _gdk_frame_clock_idle_new ();
}
else if (G_OBJECT_TYPE (impl) == GDK_TYPE_WIN32_POPUP)
{
GdkSurface *parent = gdk_popup_get_parent (GDK_POPUP (impl));
dwStyle |= WS_POPUP;
owner = GDK_SURFACE_HWND (parent);
frame_clock = g_object_ref (gdk_surface_get_frame_clock (parent));
}
else
{
/* TEMP: Put these where requested */
window_x = real_x;
window_y = real_y;
g_assert_not_reached ();
}
window_width = rect.right - rect.left;
window_height = rect.bottom - rect.top;
gdk_surface_set_frame_clock (surface, frame_clock);
g_object_unref (frame_clock);
title = get_default_title ();
if (!title || !*title)
title = "";
klass = RegisterGdkClass (surface_type);
klass = RegisterGdkClass (G_OBJECT_TYPE (impl));
wtitle = g_utf8_to_utf16 (title, -1, NULL, NULL, NULL);
hwndNew = CreateWindowExW (dwExStyle,
MAKEINTRESOURCEW (klass),
wtitle,
dwStyle,
window_x, window_y,
window_width, window_height,
owner,
NULL,
_gdk_dll_hinstance,
surface);
impl->handle = hwndNew;
impl->handle = CreateWindowExW (dwExStyle,
MAKEINTRESOURCEW (klass),
wtitle,
dwStyle,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
owner,
NULL,
_gdk_dll_hinstance,
surface);
if (impl->handle == NULL)
{
WIN32_API_FAILED ("CreateWindowExW");
g_error ("Fatal error: CreateWindowExW failed.");
}
GetWindowRect (hwndNew, &rect);
GetWindowRect (impl->handle, &rect);
impl->initial_x = rect.left;
impl->initial_y = rect.top;
/* Now we know the initial position, move to actually specified position */
if (real_x != window_x || real_y != window_y)
{
API_CALL (SetWindowPos, (hwndNew,
SWP_NOZORDER_SPECIFIED,
real_x, real_y, 0, 0,
SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER));
}
g_object_ref (impl);
/* Take note: we're inserting a pointer into a heap-allocated
* object (impl). Inserting a pointer to a stack variable
@@ -627,26 +515,11 @@ _gdk_win32_display_create_surface (GdkDisplay *display,
*/
gdk_win32_handle_table_insert (&GDK_SURFACE_HWND (impl), impl);
GDK_NOTE (MISC, g_print ("... \"%s\" %dx%d@%+d%+d %p = %p\n",
title,
window_width, window_height,
surface->x,
surface->y,
owner,
hwndNew));
g_free (wtitle);
if (impl->handle == NULL)
{
WIN32_API_FAILED ("CreateWindowExW");
g_object_unref (impl);
return NULL;
}
gdk_surface_set_egl_native_window (surface, (void *) impl->handle);
if (surface_type != GDK_SURFACE_DRAG)
if (G_OBJECT_TYPE (impl) != GDK_TYPE_WIN32_DRAG_SURFACE)
{
if (display_win32->tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINPOINTER)
gdk_winpointer_initialize_surface (surface);
@@ -663,18 +536,10 @@ _gdk_win32_display_create_surface (GdkDisplay *display,
G_CALLBACK (gdk_win32_impl_frame_clock_after_paint),
impl);
g_object_unref (frame_clock);
impl->hdc = GetDC (impl->handle);
impl->inhibit_configure = TRUE;
if (surface_type == GDK_SURFACE_TOPLEVEL)
{
g_signal_connect (surface, "notify::state",
G_CALLBACK (gdk_win32_toplevel_state_callback),
NULL);
}
return surface;
G_OBJECT_CLASS (parent_class)->constructed (object);
}
static void
@@ -4636,6 +4501,7 @@ gdk_win32_surface_class_init (GdkWin32SurfaceClass *klass)
parent_class = g_type_class_peek_parent (klass);
object_class->constructed = gdk_win32_surface_constructed;
object_class->dispose = gdk_surface_win32_dispose;
object_class->finalize = gdk_surface_win32_finalize;
@@ -4824,15 +4690,20 @@ G_DEFINE_TYPE_WITH_CODE (GdkWin32Toplevel, gdk_win32_toplevel, GDK_TYPE_WIN32_SU
gdk_win32_toplevel_iface_init))
static void
gdk_win32_toplevel_init (GdkWin32Toplevel *toplevel)
gdk_win32_toplevel_constructed (GObject *object)
{
g_signal_connect (object, "notify::state",
G_CALLBACK (gdk_win32_toplevel_state_callback),
NULL);
G_OBJECT_CLASS (gdk_win32_toplevel_parent_class)->constructed (object);
}
static void
gdk_win32_toplevel_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GdkSurface *surface = GDK_SURFACE (object);
@@ -4891,9 +4762,9 @@ gdk_win32_toplevel_set_property (GObject *object,
static void
gdk_win32_toplevel_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GdkSurface *surface = GDK_SURFACE (object);
@@ -4942,17 +4813,36 @@ gdk_win32_toplevel_get_property (GObject *object,
}
}
static void
gdk_win32_toplevel_finalize (GObject *object)
{
GdkWin32Surface *self = GDK_WIN32_SURFACE (object);
g_signal_handlers_disconnect_by_func (self,
gdk_win32_toplevel_state_callback,
NULL);
G_OBJECT_CLASS (gdk_win32_toplevel_parent_class)->finalize (object);
}
static void
gdk_win32_toplevel_class_init (GdkWin32ToplevelClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->constructed = gdk_win32_toplevel_constructed;
object_class->finalize = gdk_win32_toplevel_finalize;
object_class->get_property = gdk_win32_toplevel_get_property;
object_class->set_property = gdk_win32_toplevel_set_property;
gdk_toplevel_install_properties (object_class, 1);
}
static void
gdk_win32_toplevel_init (GdkWin32Toplevel *toplevel)
{
}
static void
gdk_win32_toplevel_present (GdkToplevel *toplevel,
GdkToplevelLayout *layout)
@@ -5228,3 +5118,11 @@ _gdk_win32_surface_invalidate_egl_framebuffer (GdkSurface *surface)
}
#endif
}
GdkSurface *
gdk_win32_drag_surface_new (GdkDisplay *display)
{
return g_object_new (GDK_TYPE_WIN32_DRAG_SURFACE,
"display", display,
NULL);
}
+10
View File
@@ -39,6 +39,14 @@
G_BEGIN_DECLS
GType gdk_win32_toplevel_get_type (void) G_GNUC_CONST;
GType gdk_win32_popup_get_type (void) G_GNUC_CONST;
GType gdk_win32_drag_surface_get_type (void) G_GNUC_CONST;
#define GDK_TYPE_WIN32_TOPLEVEL (gdk_win32_toplevel_get_type ())
#define GDK_TYPE_WIN32_POPUP (gdk_win32_popup_get_type ())
#define GDK_TYPE_WIN32_DRAG_SURFACE (gdk_win32_drag_surface_get_type ())
typedef enum
{
GDK_DECOR_ALL = 1 << 0,
@@ -364,6 +372,8 @@ void gdk_win32_surface_move_resize (GdkSurface *window,
int width,
int height);
GdkSurface *gdk_win32_drag_surface_new (GdkDisplay *display);
RECT
gdk_win32_surface_handle_queued_move_resize (GdkDrawContext *draw_context);
+3 -6
View File
@@ -1391,11 +1391,7 @@ gdk_x11_display_init_leader_surface (GdkX11Display *self)
gdk_event_init (display);
self->leader_gdk_surface =
_gdk_x11_display_create_surface (display,
GDK_SURFACE_DRAG,
NULL,
-100, -100, 1, 1);
self->leader_gdk_surface = gdk_x11_drag_surface_new (display);
(_gdk_x11_surface_get_toplevel (self->leader_gdk_surface))->is_leader = TRUE;
self->leader_window = GDK_SURFACE_XID (self->leader_gdk_surface);
@@ -3032,6 +3028,8 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class)
object_class->dispose = gdk_x11_display_dispose;
object_class->finalize = gdk_x11_display_finalize;
display_class->toplevel_type = GDK_TYPE_X11_TOPLEVEL;
display_class->popup_type = GDK_TYPE_X11_POPUP;
display_class->cairo_context_type = GDK_TYPE_X11_CAIRO_CONTEXT;
#ifdef GDK_RENDERING_VULKAN
display_class->vk_context_type = GDK_TYPE_X11_VULKAN_CONTEXT;
@@ -3052,7 +3050,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
display_class->get_startup_notification_id = gdk_x11_display_get_startup_notification_id;
G_GNUC_END_IGNORE_DEPRECATIONS
display_class->notify_startup_complete = gdk_x11_display_notify_startup_complete;
display_class->create_surface = _gdk_x11_display_create_surface;
display_class->get_keymap = gdk_x11_display_get_keymap;
display_class->init_gl = gdk_x11_display_init_gl;
+2 -18
View File
@@ -1255,19 +1255,6 @@ gdk_drag_do_leave (GdkX11Drag *drag_x11)
}
}
static GdkSurface *
create_drag_surface (GdkDisplay *display)
{
GdkSurface *surface;
surface = _gdk_x11_display_create_surface (display,
GDK_SURFACE_DRAG,
NULL,
0, 0, 100, 100);
return surface;
}
static Window
_gdk_x11_display_get_drag_protocol (GdkDisplay *display,
Window xid,
@@ -2001,10 +1988,7 @@ _gdk_x11_surface_drag_begin (GdkSurface *surface,
display = gdk_surface_get_display (surface);
ipc_surface = _gdk_x11_display_create_surface (display,
GDK_SURFACE_DRAG,
NULL,
-99, -99, 1, 1);
ipc_surface = gdk_x11_drag_surface_new (display);
drag = (GdkDrag *) g_object_new (GDK_TYPE_X11_DRAG,
"surface", ipc_surface,
@@ -2038,7 +2022,7 @@ _gdk_x11_surface_drag_begin (GdkSurface *surface,
gdk_surface_set_is_mapped (x11_drag->ipc_surface, TRUE);
gdk_x11_surface_show (x11_drag->ipc_surface, FALSE);
x11_drag->drag_surface = create_drag_surface (display);
x11_drag->drag_surface = gdk_x11_drag_surface_new (display);
if (!drag_grab (drag))
{
+45 -25
View File
@@ -477,8 +477,11 @@ gdk_x11_context_create_glx_context (GdkGLContext *context,
GdkSurface *surface = gdk_gl_context_get_surface (context);
GLXContext ctx;
int context_attribs[N_GLX_ATTRS], i = 0, flags = 0;
int min_major, min_minor, major, minor;
gsize major_idx, minor_idx;
GdkGLVersion version;
const GdkGLVersion* supported_versions;
gboolean debug_bit, compat_bit;
gsize j;
if (!gdk_gl_context_is_api_allowed (context, api, NULL))
return 0;
@@ -488,10 +491,7 @@ gdk_x11_context_create_glx_context (GdkGLContext *context,
/* We will use the default version matching the context status
* unless the user requested a version which makes sense */
gdk_gl_context_get_matching_version (api, legacy,
&min_major, &min_minor);
gdk_gl_context_get_clipped_version (context, min_major, min_minor,
&major, &minor);
gdk_gl_context_get_matching_version (context, api, legacy, &version);
debug_bit = gdk_gl_context_get_debug_enabled (context);
compat_bit = gdk_gl_context_get_forward_compatible (context);
@@ -511,9 +511,9 @@ gdk_x11_context_create_glx_context (GdkGLContext *context,
context_attribs[i++] = GLX_CONTEXT_ES2_PROFILE_BIT_EXT;
context_attribs[i++] = GLX_CONTEXT_MAJOR_VERSION_ARB;
context_attribs[i++] = major;
major_idx = i++;
context_attribs[i++] = GLX_CONTEXT_MINOR_VERSION_ARB;
context_attribs[i++] = minor;
minor_idx = i++;
context_attribs[i++] = GLX_CONTEXT_FLAGS_ARB;
context_attribs[i++] = flags;
@@ -522,7 +522,7 @@ gdk_x11_context_create_glx_context (GdkGLContext *context,
GDK_DISPLAY_DEBUG (display, OPENGL,
"Creating GLX context version %d.%d (debug:%s, forward:%s, legacy:%s, es:%s)",
major, minor,
gdk_gl_version_get_major (&version), gdk_gl_version_get_minor (&version),
debug_bit ? "yes" : "no",
compat_bit ? "yes" : "no",
legacy ? "yes" : "no",
@@ -533,25 +533,44 @@ gdk_x11_context_create_glx_context (GdkGLContext *context,
gdk_x11_display_error_trap_push (display);
/* If we don't have access to GLX_ARB_create_context_profile, then
* we have to fall back to the old GLX 1.3 API.
*/
if (legacy && !display_x11->has_glx_create_context)
ctx = glXCreateNewContext (gdk_x11_display_get_xdisplay (display),
display_x11->glx_config,
GLX_RGBA_TYPE,
share_glx != NULL ? share_glx->glx_context : NULL,
TRUE);
supported_versions = gdk_gl_versions_get_for_api (api);
for (j = 0; gdk_gl_version_greater_equal (&supported_versions[j], &version); j++)
{
context_attribs [major_idx] = gdk_gl_version_get_major (&supported_versions[j]);
context_attribs [minor_idx] = gdk_gl_version_get_minor (&supported_versions[j]);
else
ctx = glXCreateContextAttribsARB (gdk_x11_display_get_xdisplay (display),
display_x11->glx_config,
share_glx != NULL ? share_glx->glx_context : NULL,
True,
context_attribs);
/* If we don't have access to GLX_ARB_create_context_profile, then
* we have to fall back to the old GLX 1.3 API.
*/
if (legacy && !display_x11->has_glx_create_context)
ctx = glXCreateNewContext (gdk_x11_display_get_xdisplay (display),
display_x11->glx_config,
GLX_RGBA_TYPE,
share_glx != NULL ? share_glx->glx_context : NULL,
TRUE);
if (gdk_x11_display_error_trap_pop (display) || ctx == NULL)
return 0;
else
ctx = glXCreateContextAttribsARB (gdk_x11_display_get_xdisplay (display),
display_x11->glx_config,
share_glx != NULL ? share_glx->glx_context : NULL,
True,
context_attribs);
if (ctx)
break;
}
if (ctx == NULL)
{
gdk_x11_display_error_trap_pop_ignored (display);
return 0;
}
if (gdk_x11_display_error_trap_pop (display))
{
glXDestroyContext (dpy, ctx);
return 0;
}
GDK_DISPLAY_DEBUG (display, OPENGL,
"Realized GLX context[%p], %s, version: %d.%d",
@@ -561,6 +580,7 @@ gdk_x11_context_create_glx_context (GdkGLContext *context,
display_x11->glx_version % 10);
context_glx->glx_context = ctx;
gdk_gl_context_set_version (context, &supported_versions[j]);
gdk_gl_context_set_is_legacy (context, legacy);
#ifdef HAVE_XDAMAGE
-7
View File
@@ -173,13 +173,6 @@ void _gdk_x11_display_get_maximal_cursor_size (GdkDisplay *display,
guint *width,
guint *height);
GdkSurface * _gdk_x11_display_create_surface (GdkDisplay *display,
GdkSurfaceType surface_type,
GdkSurface *parent,
int x,
int y,
int width,
int height);
GList * gdk_x11_display_get_toplevel_windows (GdkDisplay *display);
void _gdk_x11_precache_atoms (GdkDisplay *display,
+452 -464
View File
File diff suppressed because it is too large Load Diff
+10
View File
@@ -36,6 +36,14 @@
G_BEGIN_DECLS
GType gdk_x11_toplevel_get_type (void) G_GNUC_CONST;
GType gdk_x11_popup_get_type (void) G_GNUC_CONST;
GType gdk_x11_drag_surface_get_type (void) G_GNUC_CONST;
#define GDK_TYPE_X11_TOPLEVEL (gdk_x11_toplevel_get_type ())
#define GDK_TYPE_X11_POPUP (gdk_x11_popup_get_type ())
#define GDK_TYPE_X11_DRAG_SURFACE (gdk_x11_drag_surface_get_type ())
typedef struct _GdkToplevelX11 GdkToplevelX11;
typedef struct _GdkXPositionInfo GdkXPositionInfo;
@@ -191,6 +199,8 @@ struct _GdkToplevelX11
#endif
};
GdkSurface *gdk_x11_drag_surface_new (GdkDisplay *display);
GdkToplevelX11 *_gdk_x11_surface_get_toplevel (GdkSurface *window);
GdkCursor *_gdk_x11_surface_get_cursor (GdkSurface *window);
+6 -6
View File
@@ -493,7 +493,7 @@ gsk_gl_command_queue_new (GdkGLContext *context,
}
}
self->has_samplers = gdk_gl_context_check_version (context, 3, 3, 3, 0);
self->has_samplers = gdk_gl_context_check_version (context, "3.3", "3.0");
/* create the samplers */
if (self->has_samplers)
@@ -1022,10 +1022,10 @@ gsk_gl_command_queue_execute (GskGLCommandQueue *self,
guint program = 0;
guint width = 0;
guint height = 0;
G_GNUC_UNUSED guint n_binds = 0;
guint n_fbos = 0;
G_GNUC_UNUSED guint n_uniforms = 0;
guint n_programs = 0;
G_GNUC_UNUSED unsigned int n_binds = 0;
G_GNUC_UNUSED unsigned int n_fbos = 0;
G_GNUC_UNUSED unsigned int n_uniforms = 0;
G_GNUC_UNUSED unsigned int n_programs = 0;
guint vao_id;
guint vbo_id;
int textures[4];
@@ -1533,7 +1533,7 @@ gsk_gl_command_queue_do_upload_texture_chunk (GskGLCommandQueue *self,
glTexSubImage2D (GL_TEXTURE_2D, 0, x, y, width, height, gl_format, gl_type, data);
}
else if (stride % bpp == 0 &&
(gdk_gl_context_check_version (self->context, 0, 0, 3, 0) || gdk_gl_context_has_unpack_subimage (self->context)))
(gdk_gl_context_check_version (self->context, NULL, "3.0") || gdk_gl_context_has_unpack_subimage (self->context)))
{
glPixelStorei (GL_UNPACK_ROW_LENGTH, stride / bpp);
+1 -1
View File
@@ -1604,7 +1604,7 @@ gsk_gl_driver_create_gdk_texture (GskGLDriver *self,
state = g_new0 (GskGLTextureState, 1);
state->texture_id = texture_id;
state->context = g_object_ref (self->command_queue->context);
if (gdk_gl_context_has_fence_sync (self->command_queue->context))
if (gdk_gl_context_has_sync (self->command_queue->context))
state->sync = glFenceSync (GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
g_hash_table_steal (self->textures, GUINT_TO_POINTER (texture_id));
+3 -3
View File
@@ -18,9 +18,9 @@ struct _GskGLProfiler
GLuint gl_queries[N_QUERIES];
GLuint active_query;
gboolean has_queries : 1;
gboolean has_timer : 1;
gboolean first_frame : 1;
unsigned int has_queries : 1;
unsigned int has_timer : 1;
unsigned int first_frame : 1;
};
enum {
+1 -1
View File
@@ -373,7 +373,7 @@ gsk_gl_renderer_render_texture (GskRenderer *renderer,
}
if (gsk_render_node_prefers_high_depth (root) &&
gdk_gl_context_check_version (self->context, 3, 0, 3, 0))
gdk_gl_context_check_version (self->context, "3.0", "3.0"))
format = GL_RGBA32F;
else
format = GL_RGBA8;
+1 -1
View File
@@ -4422,7 +4422,7 @@ get_framebuffer_format (GdkGLContext *context,
{
int size;
if (!gdk_gl_context_check_version (context, 0, 0, 3, 0))
if (!gdk_gl_context_check_version (context, NULL, "3.0"))
return GL_RGBA8;
glBindFramebuffer (GL_FRAMEBUFFER, framebuffer);
+4 -4
View File
@@ -9,7 +9,7 @@ typedef struct {
char *description;
gint64 value;
gint64 n_samples;
gboolean can_reset : 1;
unsigned int can_reset : 1;
} NamedCounter;
typedef struct {
@@ -21,9 +21,9 @@ typedef struct {
gint64 max_value;
gint64 avg_value;
gint64 n_samples;
gboolean in_flight : 1;
gboolean can_reset : 1;
gboolean invert : 1;
unsigned int in_flight : 1;
unsigned int can_reset : 1;
unsigned int invert : 1;
} NamedTimer;
typedef struct {
+1 -1
View File
@@ -83,7 +83,7 @@ typedef struct
GskDebugFlags debug_flags;
gboolean is_realized : 1;
unsigned int is_realized : 1;
} GskRendererPrivate;
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GskRenderer, gsk_renderer, G_TYPE_OBJECT)
+37 -6
View File
@@ -32,6 +32,7 @@
#include "gdk/gdktextureprivate.h"
#include "gdk/gdkmemoryformatprivate.h"
#include "gdk/gdkprivate.h"
#include "gdk/gdkrectangleprivate.h"
#include <cairo.h>
#ifdef CAIRO_HAS_SVG_SURFACE
@@ -74,6 +75,25 @@ _graphene_rect_init_from_clip_extents (graphene_rect_t *rect,
graphene_rect_init (rect, x1c, y1c, x2c - x1c, y2c - y1c);
}
static void
region_union_region_affine (cairo_region_t *region,
const cairo_region_t *sub,
float scale_x,
float scale_y,
float offset_x,
float offset_y)
{
cairo_rectangle_int_t rect;
int i;
for (i = 0; i < cairo_region_num_rectangles (sub); i++)
{
cairo_region_get_rectangle (sub, i, &rect);
gdk_rectangle_transform_affine (&rect, scale_x, scale_y, offset_x, offset_y, &rect);
cairo_region_union_rectangle (region, &rect);
}
}
/* {{{ GSK_COLOR_NODE */
/**
@@ -3146,14 +3166,14 @@ gsk_container_node_new (GskRenderNode **children,
for (guint i = 1; i < n_children; i++)
{
self->children[i] = gsk_render_node_ref (children[i]);
self->disjoint &= !graphene_rect_intersection (&bounds, &(children[i]->bounds), NULL);
self->disjoint = self->disjoint && !graphene_rect_intersection (&bounds, &(children[i]->bounds), NULL);
graphene_rect_union (&bounds, &(children[i]->bounds), &bounds);
node->prefers_high_depth |= gsk_render_node_prefers_high_depth (children[i]);
node->offscreen_for_opacity |= children[i]->offscreen_for_opacity;
node->prefers_high_depth = node->prefers_high_depth || gsk_render_node_prefers_high_depth (children[i]);
node->offscreen_for_opacity = node->offscreen_for_opacity || children[i]->offscreen_for_opacity;
}
graphene_rect_init_from_rect (&node->bounds, &bounds);
node->offscreen_for_opacity |= !self->disjoint;
node->offscreen_for_opacity = node->offscreen_for_opacity || !self->disjoint;
}
return node;
@@ -3354,11 +3374,22 @@ gsk_transform_node_diff (GskRenderNode *node1,
}
break;
case GSK_TRANSFORM_CATEGORY_2D_AFFINE:
{
cairo_region_t *sub;
float scale_x, scale_y, dx, dy;
gsk_transform_to_affine (self1->transform, &scale_x, &scale_y, &dx, &dy);
sub = cairo_region_create ();
gsk_render_node_diff (self1->child, self2->child, sub);
region_union_region_affine (region, sub, scale_x, scale_y, dx, dy);
cairo_region_destroy (sub);
}
break;
case GSK_TRANSFORM_CATEGORY_UNKNOWN:
case GSK_TRANSFORM_CATEGORY_ANY:
case GSK_TRANSFORM_CATEGORY_3D:
case GSK_TRANSFORM_CATEGORY_2D:
case GSK_TRANSFORM_CATEGORY_2D_AFFINE:
default:
gsk_render_node_diff_impossible (node1, node2, region);
break;
@@ -6034,7 +6065,7 @@ gsk_gl_shader_node_new (GskGLShader *shader,
for (guint i = 0; i < n_children; i++)
{
self->children[i] = gsk_render_node_ref (children[i]);
node->prefers_high_depth |= gsk_render_node_prefers_high_depth (children[i]);
node->prefers_high_depth = node->prefers_high_depth || gsk_render_node_prefers_high_depth (children[i]);
}
}
+24
View File
@@ -293,6 +293,30 @@
...
fun:g_intern_string
}
{
xdg-mime init
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
...
fun:xdg_mime_init*
}
{
xdg-mime init
Memcheck:Leak
match-leak-kinds: definite
fun:calloc
...
fun:xdg_mime_init*
}
{
glib init
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
...
fun:glib_init_ctor
}
# Threads
{
+9
View File
@@ -46,6 +46,12 @@ G_DEFINE_TYPE (GtkApplicationImplDBus, gtk_application_impl_dbus, GTK_TYPE_APPLI
#define GNOME_SCREENSAVER_DBUS_OBJECT_PATH "/org/gnome/ScreenSaver"
#define GNOME_SCREENSAVER_DBUS_INTERFACE "org.gnome.ScreenSaver"
static void client_proxy_signal (GDBusProxy *proxy,
const gchar *sender_name,
const gchar *signal_name,
GVariant *parameters,
gpointer user_data);
static void
unregister_client (GtkApplicationImplDBus *dbus)
{
@@ -67,6 +73,7 @@ unregister_client (GtkApplicationImplDBus *dbus)
g_error_free (error);
}
g_signal_handlers_disconnect_by_func (dbus->client_proxy, client_proxy_signal, dbus);
g_clear_object (&dbus->client_proxy);
g_free (dbus->client_path);
@@ -888,6 +895,8 @@ gtk_application_impl_dbus_finalize (GObject *object)
g_free (dbus->app_menu_path);
g_free (dbus->menubar_path);
g_clear_object (&dbus->sm_proxy);
if (dbus->ss_proxy)
g_signal_handlers_disconnect_by_func (dbus->ss_proxy, screensaver_signal_session, dbus->impl.application);
g_clear_object (&dbus->ss_proxy);
G_OBJECT_CLASS (gtk_application_impl_dbus_parent_class)->finalize (object);
+70
View File
@@ -74,6 +74,7 @@ enum {
PROP_0,
PROP_SPACING,
PROP_HOMOGENEOUS,
PROP_BASELINE_CHILD,
PROP_BASELINE_POSITION,
/* orientable */
@@ -125,6 +126,9 @@ gtk_box_set_property (GObject *object,
case PROP_SPACING:
gtk_box_set_spacing (box, g_value_get_int (value));
break;
case PROP_BASELINE_CHILD:
gtk_box_set_baseline_child (box, g_value_get_int (value));
break;
case PROP_BASELINE_POSITION:
gtk_box_set_baseline_position (box, g_value_get_enum (value));
break;
@@ -154,6 +158,9 @@ gtk_box_get_property (GObject *object,
case PROP_SPACING:
g_value_set_int (value, gtk_box_layout_get_spacing (box_layout));
break;
case PROP_BASELINE_CHILD:
g_value_set_int (value, gtk_box_layout_get_baseline_child (box_layout));
break;
case PROP_BASELINE_POSITION:
g_value_set_enum (value, gtk_box_layout_get_baseline_position (box_layout));
break;
@@ -270,6 +277,18 @@ gtk_box_class_init (GtkBoxClass *class)
FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkBox:baseline-child: (attributes org.gtk.Property.get=gtk_box_get_baseline_child org.gtk.Property.set=gtk_box_set_baseline_child)
*
* The child that determines the baseline, in vertical orientation.
*
* Since: 4.12
*/
props[PROP_BASELINE_CHILD] =
g_param_spec_int ("baseline-child", NULL, NULL,
-1, G_MAXINT, -1,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkBox:baseline-position: (attributes org.gtk.Property.get=gtk_box_get_baseline_position org.gtk.Property.set=gtk_box_set_baseline_position)
*
@@ -425,6 +444,57 @@ gtk_box_get_spacing (GtkBox *box)
return gtk_box_layout_get_spacing (GTK_BOX_LAYOUT (box_layout));
}
/**
* gtk_box_set_baseline_child: (attributes org.gtk.Method.set_property=baseline-child)
* @box: a `GtkBox`
* @child: a child, or -1
*
* Sets the baseline child of a box.
*
* This affects only vertical boxes.
*
* Since: 4.12
*/
void
gtk_box_set_baseline_child (GtkBox *box,
int child)
{
GtkBoxLayout *box_layout;
g_return_if_fail (GTK_IS_BOX (box));
g_return_if_fail (child >= -1);
box_layout = GTK_BOX_LAYOUT (gtk_widget_get_layout_manager (GTK_WIDGET (box)));
if (child == gtk_box_layout_get_baseline_child (box_layout))
return;
gtk_box_layout_set_baseline_child (box_layout, child);
g_object_notify_by_pspec (G_OBJECT (box), props[PROP_BASELINE_CHILD]);
gtk_widget_queue_resize (GTK_WIDGET (box));
}
/**
* gtk_box_get_baseline_child: (attributes org.gtk.Method.get_property=baseline-child)
* @box: a `GtkBox`
*
* Gets the value set by gtk_box_set_baseline_child().
*
* Returns: the baseline child
*
* Since: 4.12
*/
int
gtk_box_get_baseline_child (GtkBox *box)
{
GtkLayoutManager *box_layout;
g_return_val_if_fail (GTK_IS_BOX (box), -1);
box_layout = gtk_widget_get_layout_manager (GTK_WIDGET (box));
return gtk_box_layout_get_baseline_child (GTK_BOX_LAYOUT (box_layout));
}
/**
* gtk_box_set_baseline_position: (attributes org.gtk.Method.set_property=baseline-position)
* @box: a `GtkBox`
+6
View File
@@ -86,6 +86,12 @@ void gtk_box_set_baseline_position (GtkBox *box,
GDK_AVAILABLE_IN_ALL
GtkBaselinePosition gtk_box_get_baseline_position (GtkBox *box);
GDK_AVAILABLE_IN_4_12
void gtk_box_set_baseline_child (GtkBox *box,
int child);
GDK_AVAILABLE_IN_4_12
int gtk_box_get_baseline_child (GtkBox *box);
GDK_AVAILABLE_IN_ALL
void gtk_box_append (GtkBox *box,
GtkWidget *child);
+212 -36
View File
@@ -55,6 +55,7 @@ struct _GtkBoxLayout
guint spacing;
GtkOrientation orientation;
GtkBaselinePosition baseline_position;
int baseline_child;
};
G_DEFINE_TYPE_WITH_CODE (GtkBoxLayout, gtk_box_layout, GTK_TYPE_LAYOUT_MANAGER,
@@ -63,6 +64,7 @@ G_DEFINE_TYPE_WITH_CODE (GtkBoxLayout, gtk_box_layout, GTK_TYPE_LAYOUT_MANAGER,
enum {
PROP_HOMOGENEOUS = 1,
PROP_SPACING,
PROP_BASELINE_CHILD,
PROP_BASELINE_POSITION,
/* From GtkOrientable */
@@ -112,6 +114,10 @@ gtk_box_layout_set_property (GObject *gobject,
gtk_box_layout_set_spacing (self, g_value_get_int (value));
break;
case PROP_BASELINE_CHILD:
gtk_box_layout_set_baseline_child (self, g_value_get_int (value));
break;
case PROP_BASELINE_POSITION:
gtk_box_layout_set_baseline_position (self, g_value_get_enum (value));
break;
@@ -144,6 +150,10 @@ gtk_box_layout_get_property (GObject *gobject,
g_value_set_int (value, box_layout->spacing);
break;
case PROP_BASELINE_CHILD:
g_value_set_int (value, box_layout->baseline_child);
break;
case PROP_BASELINE_POSITION:
g_value_set_enum (value, box_layout->baseline_position);
break;
@@ -204,20 +214,28 @@ gtk_box_layout_compute_size (GtkBoxLayout *self,
GtkWidget *widget,
int for_size,
int *minimum,
int *natural)
int *natural,
int *minimum_baseline,
int *natural_baseline)
{
GtkWidget *child;
int n_visible_children = 0;
int required_min = 0, required_nat = 0;
int largest_min = 0, largest_nat = 0;
int spacing = get_spacing (self, gtk_widget_get_css_node (widget));
int child_above_min = 0, child_above_nat = 0;
int above_min = 0, above_nat = 0;
gboolean have_baseline = FALSE;
int pos;
for (child = gtk_widget_get_first_child (widget);
for (child = gtk_widget_get_first_child (widget), pos = 0;
child != NULL;
child = gtk_widget_get_next_sibling (child))
child = gtk_widget_get_next_sibling (child), pos++)
{
int child_min = 0;
int child_nat = 0;
int child_min_baseline = -1;
int child_nat_baseline = -1;
if (!gtk_widget_should_layout (child))
continue;
@@ -225,7 +243,7 @@ gtk_box_layout_compute_size (GtkBoxLayout *self,
gtk_widget_measure (child, self->orientation,
for_size,
&child_min, &child_nat,
NULL, NULL);
&child_min_baseline, &child_nat_baseline);
largest_min = MAX (largest_min, child_min);
largest_nat = MAX (largest_nat, child_nat);
@@ -233,6 +251,29 @@ gtk_box_layout_compute_size (GtkBoxLayout *self,
required_min += child_min;
required_nat += child_nat;
if (self->orientation == GTK_ORIENTATION_VERTICAL)
{
if (pos < self->baseline_child)
{
above_min += child_min;
above_nat += child_nat;
}
else if (pos == self->baseline_child)
{
have_baseline = TRUE;
if (child_min_baseline > -1)
{
child_above_min = child_min_baseline;
child_above_nat = child_nat_baseline;
}
else
{
child_above_min = child_min;
child_above_nat = child_nat;
}
}
}
n_visible_children += 1;
}
@@ -242,14 +283,31 @@ gtk_box_layout_compute_size (GtkBoxLayout *self,
{
required_min = largest_min * n_visible_children;
required_nat = largest_nat * n_visible_children;
above_min = largest_min * MAX (self->baseline_child, 0);
above_nat = largest_nat * MAX (self->baseline_child, 0);
}
required_min += (n_visible_children - 1) * spacing;
required_nat += (n_visible_children - 1) * spacing;
above_min += MAX (self->baseline_child, 0) * spacing;
above_nat += MAX (self->baseline_child, 0) * spacing;
}
*minimum = required_min;
*natural = required_nat;
if (have_baseline)
{
*minimum_baseline = above_min + child_above_min;
*natural_baseline = above_nat + child_above_nat;
}
else
{
*minimum_baseline = -1;
*natural_baseline = -1;
}
}
static void
@@ -262,6 +320,9 @@ gtk_box_layout_compute_opposite_size (GtkBoxLayout *self,
{
GtkWidget *child;
int largest_min = 0, largest_nat = 0;
int largest_min_above = -1, largest_min_below = -1;
int largest_nat_above = -1, largest_nat_below = -1;
gboolean have_baseline = FALSE;
for (child = gtk_widget_get_first_child (widget);
child != NULL;
@@ -269,6 +330,8 @@ gtk_box_layout_compute_opposite_size (GtkBoxLayout *self,
{
int child_min = 0;
int child_nat = 0;
int child_min_baseline = -1;
int child_nat_baseline = -1;
if (!gtk_widget_should_layout (child))
continue;
@@ -277,14 +340,43 @@ gtk_box_layout_compute_opposite_size (GtkBoxLayout *self,
OPPOSITE_ORIENTATION (self->orientation),
-1,
&child_min, &child_nat,
NULL, NULL);
&child_min_baseline, &child_nat_baseline);
largest_min = MAX (largest_min, child_min);
largest_nat = MAX (largest_nat, child_nat);
if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
{
if (child_min_baseline > -1)
{
have_baseline = TRUE;
largest_min_above = MAX (largest_min_above, child_min_baseline);
largest_min_below = MAX (largest_min_below, child_min - child_min_baseline);
largest_nat_above = MAX (largest_nat_above, child_nat_baseline);
largest_nat_below = MAX (largest_nat_below, child_nat - child_nat_baseline);
}
}
}
if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
{
largest_min = MAX (largest_min, largest_min_above + largest_min_below);
largest_nat = MAX (largest_nat, largest_nat_above + largest_nat_below);
}
*minimum = largest_min;
*natural = largest_nat;
if (have_baseline)
{
*min_baseline = largest_min_above;
*nat_baseline = largest_nat_above;
}
else
{
*min_baseline = -1;
*nat_baseline = -1;
}
}
/* if widgets haven't reached their min opposite size at this
@@ -445,13 +537,21 @@ gtk_box_layout_compute_opposite_size_for_size (GtkBoxLayout *self,
&child_minimum, &child_natural,
&child_minimum_baseline, &child_natural_baseline);
if (child_minimum_baseline >= 0)
if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
{
have_baseline = TRUE;
computed_minimum_below = MAX (computed_minimum_below, child_minimum - child_minimum_baseline);
computed_natural_below = MAX (computed_natural_below, child_natural - child_natural_baseline);
computed_minimum_above = MAX (computed_minimum_above, child_minimum_baseline);
computed_natural_above = MAX (computed_natural_above, child_natural_baseline);
if (child_minimum_baseline > -1)
{
have_baseline = TRUE;
computed_minimum_below = MAX (computed_minimum_below, child_minimum - child_minimum_baseline);
computed_natural_below = MAX (computed_natural_below, child_natural - child_natural_baseline);
computed_minimum_above = MAX (computed_minimum_above, child_minimum_baseline);
computed_natural_above = MAX (computed_natural_above, child_natural_baseline);
}
else
{
computed_minimum = MAX (computed_minimum, child_minimum);
computed_natural = MAX (computed_natural, child_natural);
}
}
else
{
@@ -561,13 +661,21 @@ gtk_box_layout_compute_opposite_size_for_size (GtkBoxLayout *self,
&child_minimum, &child_natural,
&child_minimum_baseline, &child_natural_baseline);
if (child_minimum_baseline >= 0)
if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
{
have_baseline = TRUE;
computed_minimum_below = MAX (computed_minimum_below, child_minimum - child_minimum_baseline);
computed_natural_below = MAX (computed_natural_below, child_natural - child_natural_baseline);
computed_minimum_above = MAX (computed_minimum_above, child_minimum_baseline);
computed_natural_above = MAX (computed_natural_above, child_natural_baseline);
if (child_minimum_baseline > -1)
{
have_baseline = TRUE;
computed_minimum_below = MAX (computed_minimum_below, child_minimum - child_minimum_baseline);
computed_natural_below = MAX (computed_natural_below, child_natural - child_natural_baseline);
computed_minimum_above = MAX (computed_minimum_above, child_minimum_baseline);
computed_natural_above = MAX (computed_natural_above, child_natural_baseline);
}
else
{
computed_minimum = MAX (computed_minimum, child_minimum);
computed_natural = MAX (computed_natural, child_natural);
}
}
else
{
@@ -579,24 +687,27 @@ gtk_box_layout_compute_opposite_size_for_size (GtkBoxLayout *self,
if (have_baseline)
{
computed_minimum = MAX (computed_minimum, computed_minimum_below + computed_minimum_above);
computed_natural = MAX (computed_natural, computed_natural_below + computed_natural_above);
switch (self->baseline_position)
if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
{
case GTK_BASELINE_POSITION_TOP:
computed_minimum_baseline = computed_minimum_above;
computed_natural_baseline = computed_natural_above;
break;
case GTK_BASELINE_POSITION_CENTER:
computed_minimum_baseline = computed_minimum_above + MAX((computed_minimum - (computed_minimum_above + computed_minimum_below)) / 2, 0);
computed_natural_baseline = computed_natural_above + MAX((computed_natural - (computed_natural_above + computed_natural_below)) / 2, 0);
break;
case GTK_BASELINE_POSITION_BOTTOM:
computed_minimum_baseline = computed_minimum - computed_minimum_below;
computed_natural_baseline = computed_natural - computed_natural_below;
break;
default:
break;
computed_minimum = MAX (computed_minimum, computed_minimum_below + computed_minimum_above);
computed_natural = MAX (computed_natural, computed_natural_below + computed_natural_above);
switch (self->baseline_position)
{
case GTK_BASELINE_POSITION_TOP:
computed_minimum_baseline = computed_minimum_above;
computed_natural_baseline = computed_natural_above;
break;
case GTK_BASELINE_POSITION_CENTER:
computed_minimum_baseline = computed_minimum_above + MAX((computed_minimum - (computed_minimum_above + computed_minimum_below)) / 2, 0);
computed_natural_baseline = computed_natural_above + MAX((computed_natural - (computed_natural_above + computed_natural_below)) / 2, 0);
break;
case GTK_BASELINE_POSITION_BOTTOM:
computed_minimum_baseline = computed_minimum - computed_minimum_below;
computed_natural_baseline = computed_natural - computed_natural_below;
break;
default:
break;
}
}
}
@@ -636,7 +747,8 @@ gtk_box_layout_measure (GtkLayoutManager *layout_manager,
else
{
gtk_box_layout_compute_size (self, widget, for_size,
minimum, natural);
minimum, natural,
min_baseline, nat_baseline);
}
}
@@ -711,7 +823,6 @@ gtk_box_layout_allocate (GtkLayoutManager *layout_manager,
/* We still need to run the above loop to populate the minimum sizes for
* children that aren't going to fill.
*/
size_given_to_child = extra_space / nvis_children;
n_extra_widgets = extra_space % nvis_children;
}
@@ -911,6 +1022,24 @@ gtk_box_layout_class_init (GtkBoxLayoutClass *klass)
GTK_PARAM_READWRITE |
G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkBoxLayout:baseline-child: (attributes org.gtk.Property.get=gtk_box_layout_get_baseline_child org.gtk.Property.set=gtk_box_layout_set_baseline_child)
*
* The child that determines the baseline of the box
* in vertical layout.
*
* If the child does baseline positioning, then its baseline
* is lined up with the baseline of the box. If it doesn't, then
* the bottom edge of the child is used.
*
* Since: 4.12
*/
box_layout_props[PROP_BASELINE_CHILD] =
g_param_spec_int ("baseline-child", NULL, NULL,
-1, G_MAXINT, -1,
GTK_PARAM_READWRITE |
G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkBoxLayout:baseline-position: (attributes org.gtk.Property.get=gtk_box_layout_get_baseline_position org.gtk.Property.set=gtk_box_layout_set_baseline_position)
*
@@ -938,6 +1067,7 @@ gtk_box_layout_init (GtkBoxLayout *self)
self->spacing = 0;
self->orientation = GTK_ORIENTATION_HORIZONTAL;
self->baseline_position = GTK_BASELINE_POSITION_CENTER;
self->baseline_child = -1;
}
/**
@@ -1078,3 +1208,49 @@ gtk_box_layout_get_baseline_position (GtkBoxLayout *box_layout)
return box_layout->baseline_position;
}
/**
* gtk_box_layout_set_baseline_child: (attributes org.gtk.Method.set_property=baseline-child)
* @box_layout: a `GtkBoxLayout`
* @child: the child position, or -1
*
* Sets the index of the child that determines the baseline
* in vertical layout.
*
* Since: 4.12
*/
void
gtk_box_layout_set_baseline_child (GtkBoxLayout *box_layout,
int child)
{
g_return_if_fail (GTK_IS_BOX_LAYOUT (box_layout));
g_return_if_fail (child >= -1);
if (box_layout->baseline_child == child)
return;
box_layout->baseline_child = child;
g_object_notify_by_pspec (G_OBJECT (box_layout), box_layout_props[PROP_BASELINE_CHILD]);
gtk_layout_manager_layout_changed (GTK_LAYOUT_MANAGER (box_layout));
}
/**
* gtk_box_layout_get_baseline_child:
* @box_layout: a `GtkBoxLayout`
*
* Gets the value set by gtk_box_layout_set_baseline_child().
*
* Returns: the index of the child that determines the baseline
* in vertical layout, or -1
*
* Since: 4.12
*/
int
gtk_box_layout_get_baseline_child (GtkBoxLayout *box_layout)
{
g_return_val_if_fail (GTK_IS_BOX_LAYOUT (box_layout), -1);
return box_layout->baseline_child;
}
+6
View File
@@ -51,4 +51,10 @@ void gtk_box_layout_set_baseline_position (GtkBoxLayout
GDK_AVAILABLE_IN_ALL
GtkBaselinePosition gtk_box_layout_get_baseline_position (GtkBoxLayout *box_layout);
GDK_AVAILABLE_IN_4_12
void gtk_box_layout_set_baseline_child (GtkBoxLayout *box_layout,
int child);
GDK_AVAILABLE_IN_4_12
int gtk_box_layout_get_baseline_child (GtkBoxLayout *box_layout);
G_END_DECLS
+4 -3
View File
@@ -153,9 +153,10 @@
* specifies the function to connect to the signal.
* The remaining attributes, after, swapped and object, have the
* same meaning as the corresponding parameters of the
* g_signal_connect_object() or g_signal_connect_data() functions. A
* last_modification_time attribute is also allowed, but it does not
* have a meaning to the builder.
* g_signal_connect_object() or g_signal_connect_data() functions. By
* default "swapped" will be set to "yes" if not specified otherwise, in the
* case where "object" is set, for convenience. A last_modification_time
* attribute is also allowed, but it does not have a meaning to the builder.
*
* If you rely on `GModule` support to lookup callbacks in the symbol table,
* the following details should be noted:
+3 -3
View File
@@ -69,9 +69,9 @@ typedef struct {
GParamSpec *pspec;
gpointer value;
GString *text;
gboolean translatable : 1;
gboolean bound : 1;
gboolean applied : 1;
unsigned int translatable : 1;
unsigned int bound : 1;
unsigned int applied : 1;
char *context;
int line;
int col;
+100
View File
@@ -94,6 +94,7 @@ struct _GtkButtonPrivate
guint button_down : 1;
guint use_underline : 1;
guint child_type : 2;
guint can_shrink : 1;
};
enum {
@@ -109,6 +110,7 @@ enum {
PROP_USE_UNDERLINE,
PROP_ICON_NAME,
PROP_CHILD,
PROP_CAN_SHRINK,
/* actionable properties */
PROP_ACTION_NAME,
@@ -260,6 +262,24 @@ gtk_button_class_init (GtkButtonClass *klass)
GTK_TYPE_WIDGET,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkButton:can-shrink:
*
* Whether the size of the button can be made smaller than the natural
* size of its contents.
*
* For text buttons, setting this property will allow ellipsizing the label.
*
* If the contents of a button are an icon or a custom widget, setting this
* property has no effect.
*
* Since: 4.12
*/
props[PROP_CAN_SHRINK] =
g_param_spec_boolean ("can-shrink", NULL, NULL,
FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
g_object_class_install_properties (gobject_class, LAST_PROP, props);
g_object_class_override_property (gobject_class, PROP_ACTION_NAME, "action-name");
@@ -510,6 +530,9 @@ gtk_button_set_property (GObject *object,
case PROP_CHILD:
gtk_button_set_child (button, g_value_get_object (value));
break;
case PROP_CAN_SHRINK:
gtk_button_set_can_shrink (button, g_value_get_boolean (value));
break;
case PROP_ACTION_NAME:
gtk_button_set_action_name (GTK_ACTIONABLE (button), g_value_get_string (value));
break;
@@ -548,6 +571,9 @@ gtk_button_get_property (GObject *object,
case PROP_CHILD:
g_value_set_object (value, priv->child);
break;
case PROP_CAN_SHRINK:
g_value_set_boolean (value, priv->can_shrink);
break;
case PROP_ACTION_NAME:
g_value_set_string (value, gtk_action_helper_get_action_name (priv->action_helper));
break;
@@ -837,6 +863,10 @@ gtk_button_set_label (GtkButton *button,
}
gtk_label_set_label (GTK_LABEL (priv->child), label);
gtk_label_set_ellipsize (GTK_LABEL (priv->child),
priv->can_shrink ? PANGO_ELLIPSIZE_END
: PANGO_ELLIPSIZE_NONE);
gtk_button_set_child_type (button, LABEL_CHILD);
gtk_accessible_update_property (GTK_ACCESSIBLE (button),
@@ -1067,3 +1097,73 @@ gtk_button_get_child (GtkButton *button)
return priv->child;
}
/**
* gtk_button_set_can_shrink:
* @button: a button
* @can_shrink: whether the button can shrink
*
* Sets whether the button size can be smaller than the natural size of
* its contents.
*
* For text buttons, setting @can_shrink to true will ellipsize the label.
*
* For icons and custom children, this function has no effect.
*
* Since: 4.12
*/
void
gtk_button_set_can_shrink (GtkButton *button,
gboolean can_shrink)
{
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
g_return_if_fail (GTK_IS_BUTTON (button));
can_shrink = !!can_shrink;
if (priv->can_shrink != can_shrink)
{
priv->can_shrink = can_shrink;
switch (priv->child_type)
{
case LABEL_CHILD:
gtk_label_set_ellipsize (GTK_LABEL (priv->child),
priv->can_shrink ? PANGO_ELLIPSIZE_END
: PANGO_ELLIPSIZE_NONE);
break;
case ICON_CHILD:
case WIDGET_CHILD:
break;
default:
g_assert_not_reached ();
break;
}
g_object_notify_by_pspec (G_OBJECT (button), props[PROP_CAN_SHRINK]);
}
}
/**
* gtk_button_get_can_shrink:
* @button: a button
*
* Retrieves whether the button can be smaller than the natural
* size of its contents.
*
* Returns: true if the button can shrink, and false otherwise
*
* Since: 4.12
*/
gboolean
gtk_button_get_can_shrink (GtkButton *button)
{
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
g_return_val_if_fail (GTK_IS_BUTTON (button), FALSE);
return priv->can_shrink;
}
+7 -1
View File
@@ -93,7 +93,7 @@ GDK_AVAILABLE_IN_ALL
void gtk_button_set_label (GtkButton *button,
const char *label);
GDK_AVAILABLE_IN_ALL
const char * gtk_button_get_label (GtkButton *button);
const char * gtk_button_get_label (GtkButton *button);
GDK_AVAILABLE_IN_ALL
void gtk_button_set_use_underline (GtkButton *button,
gboolean use_underline);
@@ -112,6 +112,12 @@ void gtk_button_set_child (GtkButton *button,
GDK_AVAILABLE_IN_ALL
GtkWidget * gtk_button_get_child (GtkButton *button);
GDK_AVAILABLE_IN_4_12
void gtk_button_set_can_shrink (GtkButton *button,
gboolean can_shrink);
GDK_AVAILABLE_IN_4_12
gboolean gtk_button_get_can_shrink (GtkButton *button);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkButton, g_object_unref)
G_END_DECLS
+2 -1
View File
@@ -320,6 +320,7 @@ gtk_column_view_update_cell_factories (GtkColumnView *self,
GtkColumnViewColumn *column = g_list_model_get_item (G_LIST_MODEL (self->columns), i);
gtk_column_view_column_update_factory (column, inert);
g_object_unref (column);
}
}
@@ -1245,7 +1246,7 @@ update_column_reorder (GtkColumnView *self,
int size;
column = g_list_model_get_item (G_LIST_MODEL (self->columns), self->drag_pos);
width = gtk_widget_get_allocated_width (GTK_WIDGET (self->header));
width = gtk_widget_get_width (GTK_WIDGET (self->header));
gtk_column_view_column_get_allocation (column, NULL, &size);
self->drag_x = CLAMP (x - self->drag_offset, 0, width - size);
+3
View File
@@ -1706,6 +1706,9 @@ gtk_entry_size_allocate (GtkWidget *widget,
text_alloc.width = width;
text_alloc.height = height;
if (gtk_widget_get_valign (widget) != GTK_ALIGN_BASELINE)
baseline = -1;
for (i = 0; i < MAX_ICONS; i++)
{
EntryIconInfo *icon_info = priv->icons[i];
+4 -2
View File
@@ -56,8 +56,10 @@ G_BEGIN_DECLS
* are interpreted relative to text direction.
*
* %GTK_ALIGN_BASELINE support is optional for containers and widgets, and
* it is only supported for vertical alignment. When it's not supported by
* a child or a container it is treated as %GTK_ALIGN_FILL.
* it is only supported for vertical alignment. Where it is supported, it is
* treated similar to %GTK_ALIGN_CENTER, except that it positions the widget
* to line up the baselines. When it's not supported by a child or a container,
* it is treated as %GTK_ALIGN_FILL.
*/
typedef enum
{
+1 -1
View File
@@ -32,7 +32,7 @@
*
* See the chapter on [input handling](input-handling.html) for
* an overview of the basic concepts, such as the capture and bubble
* phases of even propagation.
* phases of event propagation.
*/
#include "config.h"
+5
View File
@@ -164,6 +164,8 @@ response_cb (GDBusConnection *connection,
g_object_unref (filters);
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (self), filter_to_select);
g_object_unref (filter_to_select);
g_variant_unref (current_filter);
}
g_slist_free_full (self->custom_files, g_object_unref);
@@ -171,6 +173,9 @@ response_cb (GDBusConnection *connection,
for (i = 0; uris[i]; i++)
self->custom_files = g_slist_prepend (self->custom_files, g_file_new_for_uri (uris[i]));
g_free (uris);
g_variant_unref (response_data);
switch (portal_response)
{
case 0:
+8
View File
@@ -587,6 +587,12 @@ gtk_file_chooser_widget_finalize (GObject *object)
g_clear_object (&impl->sort_model);
g_clear_object (&impl->filter_model);
g_clear_object (&impl->column_view_name_column);
g_clear_object (&impl->column_view_location_column);
g_clear_object (&impl->column_view_size_column);
g_clear_object (&impl->column_view_time_column);
g_clear_object (&impl->column_view_type_column);
/* stopping the load above should have cleared this */
g_assert (impl->load_timeout_id == 0);
@@ -1647,6 +1653,8 @@ check_file_list_popover_sensitivity (GtkFileChooserWidget *impl)
g_simple_action_set_enabled (trash_action, FALSE);
g_simple_action_set_enabled (delete_action, FALSE);
}
g_clear_object (&info);
}
static void
+7 -20
View File
@@ -784,6 +784,8 @@ G_GNUC_END_IGNORE_DEPRECATIONS
else
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_FAILED, "Unknown failure (%d)", response);
gtk_native_dialog_destroy (GTK_NATIVE_DIALOG (g_task_get_task_data (task)));
g_object_unref (task);
}
@@ -943,7 +945,7 @@ gtk_file_dialog_open (GtkFileDialog *self,
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_check_cancellable (task, FALSE);
g_task_set_source_tag (task, gtk_file_dialog_open);
g_task_set_task_data (task, chooser, (GDestroyNotify) gtk_native_dialog_destroy);
g_task_set_task_data (task, chooser, g_object_unref);
if (cancellable)
g_signal_connect (cancellable, "cancelled", G_CALLBACK (cancelled_cb), task);
@@ -976,9 +978,6 @@ gtk_file_dialog_open_finish (GtkFileDialog *self,
g_return_val_if_fail (g_task_is_valid (result, self), NULL);
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gtk_file_dialog_open, NULL);
/* Destroy the dialog window not to be bound to GTask lifecycle */
g_task_set_task_data (G_TASK (result), NULL, NULL);
return finish_file_op (self, G_TASK (result), error);
}
@@ -1020,7 +1019,7 @@ gtk_file_dialog_select_folder (GtkFileDialog *self,
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_check_cancellable (task, FALSE);
g_task_set_source_tag (task, gtk_file_dialog_select_folder);
g_task_set_task_data (task, chooser, (GDestroyNotify) gtk_native_dialog_destroy);
g_task_set_task_data (task, chooser, g_object_unref);
if (cancellable)
g_signal_connect (cancellable, "cancelled", G_CALLBACK (cancelled_cb), task);
@@ -1053,9 +1052,6 @@ gtk_file_dialog_select_folder_finish (GtkFileDialog *self,
g_return_val_if_fail (g_task_is_valid (result, self), NULL);
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gtk_file_dialog_select_folder, NULL);
/* Destroy the dialog window not to be bound to GTask lifecycle */
g_task_set_task_data (G_TASK (result), NULL, NULL);
return finish_file_op (self, G_TASK (result), error);
}
@@ -1093,7 +1089,7 @@ gtk_file_dialog_save (GtkFileDialog *self,
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_check_cancellable (task, FALSE);
g_task_set_source_tag (task, gtk_file_dialog_save);
g_task_set_task_data (task, chooser, (GDestroyNotify) gtk_native_dialog_destroy);
g_task_set_task_data (task, chooser, g_object_unref);
if (cancellable)
g_signal_connect (cancellable, "cancelled", G_CALLBACK (cancelled_cb), task);
@@ -1126,9 +1122,6 @@ gtk_file_dialog_save_finish (GtkFileDialog *self,
g_return_val_if_fail (g_task_is_valid (result, self), NULL);
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gtk_file_dialog_save, NULL);
/* Destroy the dialog window not to be bound to GTask lifecycle */
g_task_set_task_data (G_TASK (result), NULL, NULL);
return finish_file_op (self, G_TASK (result), error);
}
@@ -1169,7 +1162,7 @@ gtk_file_dialog_open_multiple (GtkFileDialog *self,
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_check_cancellable (task, FALSE);
g_task_set_source_tag (task, gtk_file_dialog_open_multiple);
g_task_set_task_data (task, chooser, (GDestroyNotify) gtk_native_dialog_destroy);
g_task_set_task_data (task, chooser, g_object_unref);
if (cancellable)
g_signal_connect (cancellable, "cancelled", G_CALLBACK (cancelled_cb), task);
@@ -1203,9 +1196,6 @@ gtk_file_dialog_open_multiple_finish (GtkFileDialog *self,
g_return_val_if_fail (g_task_is_valid (result, self), NULL);
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gtk_file_dialog_open_multiple, NULL);
/* Destroy the dialog window not to be bound to GTask lifecycle */
g_task_set_task_data (G_TASK (result), NULL, NULL);
return finish_multiple_files_op (self, G_TASK (result), error);
}
@@ -1246,7 +1236,7 @@ gtk_file_dialog_select_multiple_folders (GtkFileDialog *self,
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_check_cancellable (task, FALSE);
g_task_set_source_tag (task, gtk_file_dialog_select_multiple_folders);
g_task_set_task_data (task, chooser, (GDestroyNotify) gtk_native_dialog_destroy);
g_task_set_task_data (task, chooser, g_object_unref);
if (cancellable)
g_signal_connect (cancellable, "cancelled", G_CALLBACK (cancelled_cb), task);
@@ -1280,9 +1270,6 @@ gtk_file_dialog_select_multiple_folders_finish (GtkFileDialog *self,
g_return_val_if_fail (g_task_is_valid (result, self), NULL);
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gtk_file_dialog_select_multiple_folders, NULL);
/* Destroy the dialog window not to be bound to GTask lifecycle */
g_task_set_task_data (G_TASK (result), NULL, NULL);
return finish_multiple_files_op (self, G_TASK (result), error);
}
+9 -10
View File
@@ -66,22 +66,21 @@ struct _GtkFileSystemModel
GArray * files; /* array of FileModelNode containing all our files */
guint n_nodes_valid; /* count of valid nodes (i.e. those whose node->row is accurate) */
GHashTable * file_lookup; /* mapping of GFile => array index in model->files
* This hash table doesn't always have the same number of entries as the files array;
* The hash table gets re-populated in node_get_for_file() if this mismatch is
* detected.
* This hash table doesn't always have the same number of entries
* as the files array; it gets re-populated in node_get_for_file()
* if this mismatch is detected.
*/
GtkFileFilter * filter; /* filter to use for deciding which nodes are visible */
guint frozen; /* number of times we're frozen */
gboolean filter_on_thaw :1;/* set when filtering needs to happen upon thawing */
guint show_hidden :1; /* whether to show hidden files */
guint show_folders :1;/* whether to show folders */
guint show_files :1; /* whether to show files */
guint filter_folders :1;/* whether filter applies to folders */
guint can_select_files : 1;
unsigned int filter_on_thaw : 1; /* set when filtering needs to happen upon thawing */
unsigned int show_hidden : 1; /* whether to show hidden files */
unsigned int show_folders : 1; /* whether to show folders */
unsigned int show_files : 1; /* whether to show files */
unsigned int filter_folders : 1; /* whether filter applies to folders */
unsigned int can_select_files : 1;
};
static void freeze_updates (GtkFileSystemModel *model);
+10
View File
@@ -2548,7 +2548,9 @@ gtk_flow_box_snapshot (GtkWidget *widget,
GtkWidget *child;
child = g_sequence_get (iter);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_widget_get_allocation (GTK_WIDGET (child), &rect);
G_GNUC_END_IGNORE_DEPRECATIONS
if (line_rect.width == 0)
line_rect = rect;
else
@@ -3350,7 +3352,9 @@ gtk_flow_box_move_cursor (GtkFlowBox *box,
{
child = priv->cursor_child;
iter = CHILD_PRIV (child)->iter;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_widget_get_allocation (GTK_WIDGET (child), &allocation);
G_GNUC_END_IGNORE_DEPRECATIONS
start = vertical ? allocation.x : allocation.y;
if (count < 0)
@@ -3369,7 +3373,9 @@ gtk_flow_box_move_cursor (GtkFlowBox *box,
/* go up an even number of rows */
if (i % priv->cur_children_per_line == 0)
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_widget_get_allocation (GTK_WIDGET (prev), &allocation);
G_GNUC_END_IGNORE_DEPRECATIONS
if ((vertical ? allocation.x : allocation.y) < start - page_size)
break;
}
@@ -3393,7 +3399,9 @@ gtk_flow_box_move_cursor (GtkFlowBox *box,
if (i % priv->cur_children_per_line == 0)
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_widget_get_allocation (GTK_WIDGET (next), &allocation);
G_GNUC_END_IGNORE_DEPRECATIONS
if ((vertical ? allocation.x : allocation.y) > start + page_size)
break;
}
@@ -3402,7 +3410,9 @@ gtk_flow_box_move_cursor (GtkFlowBox *box,
i++;
}
}
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_widget_get_allocation (GTK_WIDGET (child), &allocation);
G_GNUC_END_IGNORE_DEPRECATIONS
}
break;
+10 -6
View File
@@ -404,7 +404,6 @@ delete_one_texture (gpointer data)
{
Texture *texture = data;
guint id;
gpointer sync;
if (texture->holder)
gdk_gl_texture_release (GDK_GL_TEXTURE (texture->holder));
@@ -413,10 +412,6 @@ delete_one_texture (gpointer data)
if (id != 0)
glDeleteTextures (1, &id);
sync = gdk_gl_texture_builder_get_sync (texture->builder);
if (sync)
glDeleteSync (sync);
g_object_unref (texture->builder);
g_free (texture);
@@ -704,6 +699,15 @@ static void
release_texture (gpointer data)
{
Texture *texture = data;
gpointer sync;
sync = gdk_gl_texture_builder_get_sync (texture->builder);
if (sync)
{
glDeleteSync (sync);
gdk_gl_texture_builder_set_sync (texture->builder, NULL);
}
texture->holder = NULL;
}
@@ -768,7 +772,7 @@ gtk_gl_area_snapshot (GtkWidget *widget,
priv->texture = NULL;
priv->textures = g_list_prepend (priv->textures, texture);
if (gdk_gl_context_has_fence_sync (priv->context))
if (gdk_gl_context_has_sync (priv->context))
sync = glFenceSync (GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
gdk_gl_texture_builder_set_sync (texture->builder, sync);
+2 -2
View File
@@ -1162,7 +1162,7 @@ grid_request_allocate (GridRequest *request,
lines = &request->lines[orientation];
spacing = get_spacing (request->layout, request->widget, orientation);
baseline = gtk_widget_get_allocated_baseline (request->widget);
baseline = gtk_widget_get_baseline (request->widget);
if (orientation == GTK_ORIENTATION_VERTICAL && baseline != -1 &&
self->baseline_row >= lines->min && self->baseline_row < lines->max &&
@@ -1298,7 +1298,7 @@ grid_request_position (GridRequest *request,
lines = &request->lines[orientation];
spacing = get_spacing (request->layout, request->widget, orientation);
allocated_baseline = gtk_widget_get_allocated_baseline (request->widget);
allocated_baseline = gtk_widget_get_baseline (request->widget);
position = 0;
for (i = 0; i < lines->max - lines->min; i++)
+4 -2
View File
@@ -2592,7 +2592,8 @@ gtk_icon_theme_has_icon (GtkIconTheme *self,
ensure_valid_themes (self, FALSE);
if (gtk_string_set_lookup (&self->icons, icon_name) != NULL)
if (gtk_string_set_lookup (&self->icons, icon_name) != NULL ||
g_hash_table_contains (self->unthemed_icons, icon_name))
{
res = TRUE;
goto out;
@@ -2634,7 +2635,8 @@ gtk_icon_theme_has_gicon (GtkIconTheme *self,
for (int i = 0; names[i]; i++)
{
if (gtk_string_set_lookup (&self->icons, names[i]) != NULL)
if (gtk_string_set_lookup (&self->icons, names[i]) != NULL ||
g_hash_table_contains (self->unthemed_icons, names[i]))
{
res = TRUE;
goto out;
+3 -5
View File
@@ -1014,7 +1014,7 @@ gtk_image_snapshot (GtkWidget *widget,
x = (width - ceil (w)) / 2;
baseline = gtk_widget_get_allocated_baseline (widget);
baseline = gtk_widget_get_baseline (widget);
if (baseline == -1)
y = floor(height - ceil (h)) / 2;
else
@@ -1168,10 +1168,8 @@ gtk_image_measure (GtkWidget *widget,
if (orientation == GTK_ORIENTATION_VERTICAL)
{
baseline_align = gtk_image_get_baseline_align (GTK_IMAGE (widget));
if (minimum_baseline)
*minimum_baseline = *minimum * baseline_align;
if (natural_baseline)
*natural_baseline = *natural * baseline_align;
*minimum_baseline = *minimum * baseline_align;
*natural_baseline = *natural * baseline_align;
}
}
+4 -2
View File
@@ -38,7 +38,7 @@
#include "gdk/win32/gdkwin32.h"
#include "gtk/gtkimmodule.h"
#include "gtk/deprecated/gtkstylecontextprivate.h"
#include "gtk/gtkcssstyleprivate.h"
#include "gtkwidgetprivate.h"
/* avoid warning */
#ifdef STRICT
@@ -728,6 +728,7 @@ gtk_im_context_ime_set_preedit_font (GtkIMContext *context)
PangoFont *font;
LOGFONT *logfont;
PangoFontDescription *font_desc;
GtkCssStyle *style;
g_return_if_fail (GTK_IS_IM_CONTEXT_IME (context));
@@ -777,7 +778,8 @@ gtk_im_context_ime_set_preedit_font (GtkIMContext *context)
lang = ""; break;
}
font_desc = gtk_css_style_get_pango_font (gtk_style_context_lookup_style (gtk_widget_get_style_context (context_ime->client_widget)));
style = gtk_css_node_get_style (gtk_widget_get_css_node (context_ime->client_widget));
font_desc = gtk_css_style_get_pango_font (style);
if (lang[0])
{
+1 -1
View File
@@ -432,7 +432,7 @@ gtk_inscription_get_layout_location (GtkInscription *self,
else
x = floor ((xalign * (widget_width - logical.width)) - logical.x);
baseline = gtk_widget_get_allocated_baseline (widget);
baseline = gtk_widget_get_baseline (widget);
if (baseline != -1)
{
int layout_baseline = pango_layout_get_baseline (self->layout) / PANGO_SCALE;
+4 -4
View File
@@ -1335,7 +1335,7 @@ get_layout_location (GtkLabel *self,
pango_layout_get_pixel_extents (self->layout, NULL, &logical);
x = floor ((xalign * (widget_width - logical.width)) - logical.x);
baseline = gtk_widget_get_allocated_baseline (widget);
baseline = gtk_widget_get_baseline (widget);
if (baseline != -1)
{
int layout_baseline = pango_layout_get_baseline (self->layout) / PANGO_SCALE;
@@ -5773,10 +5773,10 @@ gtk_label_get_current_uri (GtkLabel *self)
if (!self->select_info)
return NULL;
if (self->select_info->link_clicked)
link = self->select_info->active_link;
else
if (!self->select_info->link_clicked && self->select_info->selectable)
link = gtk_label_get_focus_link (self, NULL);
else
link = self->select_info->active_link;
if (link)
return link->uri;
+80
View File
@@ -128,6 +128,7 @@ struct _GtkMenuButton
gboolean always_show_arrow;
gboolean primary;
gboolean can_shrink;
};
struct _GtkMenuButtonClass
@@ -151,6 +152,7 @@ enum
PROP_PRIMARY,
PROP_CHILD,
PROP_ACTIVE,
PROP_CAN_SHRINK,
LAST_PROP
};
@@ -212,6 +214,9 @@ gtk_menu_button_set_property (GObject *object,
case PROP_ACTIVE:
gtk_menu_button_set_active (self, g_value_get_boolean (value));
break;
case PROP_CAN_SHRINK:
gtk_menu_button_set_can_shrink (self, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -260,6 +265,9 @@ gtk_menu_button_get_property (GObject *object,
case PROP_ACTIVE:
g_value_set_boolean (value, gtk_menu_button_get_active (self));
break;
case PROP_CAN_SHRINK:
g_value_set_boolean (value, gtk_menu_button_get_can_shrink (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -534,6 +542,19 @@ gtk_menu_button_class_init (GtkMenuButtonClass *klass)
FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkMenuButton:can-shrink: (attributes org.gtk.Property.get=gtk_menu_button_get_can_shrink org.gtk.Property.set=gtk_menu_button_set_can_shrink)
*
* Whether the size of the button can be made smaller than the natural
* size of its contents.
*
* Since: 4.12
*/
menu_button_props[PROP_CAN_SHRINK] =
g_param_spec_boolean ("can-shrink", NULL, NULL,
FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
g_object_class_install_properties (gobject_class, LAST_PROP, menu_button_props);
/**
@@ -1150,6 +1171,9 @@ gtk_menu_button_set_label (GtkMenuButton *menu_button,
gtk_label_set_xalign (GTK_LABEL (label_widget), 0);
gtk_label_set_use_underline (GTK_LABEL (label_widget),
gtk_button_get_use_underline (GTK_BUTTON (menu_button->button)));
gtk_label_set_ellipsize (GTK_LABEL (label_widget),
menu_button->can_shrink ? PANGO_ELLIPSIZE_END
: PANGO_ELLIPSIZE_NONE);
gtk_widget_set_hexpand (label_widget, TRUE);
gtk_widget_set_halign (label_widget, GTK_ALIGN_CENTER);
arrow = gtk_builtin_icon_new ("arrow");
@@ -1566,3 +1590,59 @@ gtk_menu_button_get_active (GtkMenuButton *menu_button)
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (menu_button->button));
}
/**
* gtk_menu_button_set_can_shrink:
* @menu_button: a menu button
* @can_shrink: whether the button can shrink
*
* Sets whether the button size can be smaller than the natural size of
* its contents.
*
* For text buttons, setting @can_shrink to true will ellipsize the label.
*
* For icon buttons, this function has no effect.
*
* Since: 4.12
*/
void
gtk_menu_button_set_can_shrink (GtkMenuButton *menu_button,
gboolean can_shrink)
{
g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
can_shrink = !!can_shrink;
if (menu_button->can_shrink == can_shrink)
return;
menu_button->can_shrink = can_shrink;
if (menu_button->label_widget != NULL)
{
gtk_label_set_ellipsize (GTK_LABEL (menu_button->label_widget),
can_shrink ? PANGO_ELLIPSIZE_END
: PANGO_ELLIPSIZE_NONE);
}
g_object_notify_by_pspec (G_OBJECT (menu_button), menu_button_props[PROP_CAN_SHRINK]);
}
/**
* gtk_menu_button_get_can_shrink:
* @menu_button: a button
*
* Retrieves whether the button can be smaller than the natural
* size of its contents.
*
* Returns: true if the button can shrink, and false otherwise
*
* Since: 4.12
*/
gboolean
gtk_menu_button_get_can_shrink (GtkMenuButton *menu_button)
{
g_return_val_if_fail (GTK_IS_MENU_BUTTON (menu_button), FALSE);
return menu_button->can_shrink;
}
+9 -2
View File
@@ -127,10 +127,17 @@ GDK_AVAILABLE_IN_4_6
GtkWidget * gtk_menu_button_get_child (GtkMenuButton *menu_button);
GDK_AVAILABLE_IN_4_10
void gtk_menu_button_set_active (GtkMenuButton *menu_button,
void gtk_menu_button_set_active (GtkMenuButton *menu_button,
gboolean active);
GDK_AVAILABLE_IN_4_10
gboolean gtk_menu_button_get_active (GtkMenuButton *menu_button);
gboolean gtk_menu_button_get_active (GtkMenuButton *menu_button);
GDK_AVAILABLE_IN_4_12
void gtk_menu_button_set_can_shrink (GtkMenuButton *menu_button,
gboolean can_shrink);
GDK_AVAILABLE_IN_4_12
gboolean gtk_menu_button_get_can_shrink (GtkMenuButton *menu_button);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkMenuButton, g_object_unref)

Some files were not shown because too many files have changed in this diff Show More