Compare commits

...

298 Commits

Author SHA1 Message Date
Jasper St. Pierre d3b614836f gdkwindow-x11: Implement support for the X Present extension
This allows us better synchronization than simply using XCopyArea, which
is what cairo does by default.
2014-11-20 18:20:58 -08:00
Josef Andersson 5a0d1a79c5 Updated Swedish translation 2014-11-20 20:55:11 +00:00
Piotr Drąg 6fa4aef811 Updated POTFILES.in 2014-11-20 16:46:38 +01:00
Alexander Larsson 442adf6359 GL: Fix typo in gdk_gl_texture_from_surface
Got a sign wrong in commit 800c712738
2014-11-20 15:37:40 +01:00
Chun-wei Fan 4744058832 Visual Studio Builds: Fix gdkconfig.h Generation
...for Broadway builds, as it was producing a wrongly-named check file for
that configuration, so that a clean would not be correctly performed and
subsequently affected rebuilds.
2014-11-20 22:35:05 +08:00
Alexander Larsson cf94da2ca1 GdkGLContext: Remove unused update vfunc
The update virtual function for GdkGLContext is unused and is a
leftover from a previous GL approach. Just remove it.

https://bugzilla.gnome.org/show_bug.cgi?id=739750
2014-11-20 12:38:04 +01:00
Alexander Larsson 800c712738 GL: Fix GL Y coordinate flipping to use unscaled window height
This is needed in the edge case where the X11 backend rounded the actual
size, and the GL flipping really needs the correct window height to
do proper Y coordinate flipping.

https://bugzilla.gnome.org/show_bug.cgi?id=739750
2014-11-20 12:38:04 +01:00
Alexander Larsson 1eb3b34bce Add gdk_window_get_unscaled_size
This is required for the X backend GL integration. If the
window has a height that is not a multiple of the window scale
we can't properly do the y coordinate flipping that GL needs.
Other backends can ignore this and use the default implementation.

https://bugzilla.gnome.org/show_bug.cgi?id=739750
2014-11-20 12:38:04 +01:00
Alexander Larsson 788478dff9 x11: Return the exact pixel coverage in get_frame_extents
Rather than just rounding down the position *and* the size separately
we correctly calculate a rectangle in scaled window coords that fully
covers the real window size. This really only makes a difference
when the window size/position isn't a multiple of the window scale.

https://bugzilla.gnome.org/show_bug.cgi?id=739750
2014-11-20 12:38:04 +01:00
Owen W. Taylor bd643e0e1a x11: Keep track of the exact size in X pixels of windows
Keep track of the exact size of X windows in underlying pixels; we
generally use the scaled size instead, but to properly handle the GL
viewport for windows that aren't a multiple of window_scale,
we need to know the real size.

https://bugzilla.gnome.org/show_bug.cgi?id=739750
2014-11-20 12:38:04 +01:00
Owen W. Taylor 608c25453b x11: round the scaled size *up* when we get a ConfigureNotify
Although we specify a resize increment to try and get a size that is
a multiple of the window scale, maximization typically wins
over the resize increment, so the window might be odd sized.

Round *up* in this case, rather than down, since it's better to
truncate a line or two at the bottom and right of the window rather
than have a line or two that we don't know what to do with.

https://bugzilla.gnome.org/show_bug.cgi?id=739750
2014-11-20 10:19:27 +01:00
Marco Trevisan (Treviño) f5d96f7110 mir: use proper naming for mir window type checking macro 2014-11-20 05:51:12 +01:00
Marco Trevisan (Treviño) 99d849412b mir: add public getter for the internal MirSurface 2014-11-20 04:41:45 +01:00
Marco Trevisan (Treviño) 60e185e496 mir: don't use struct MirConnection*, just the latter 2014-11-20 04:41:06 +01:00
Marco Trevisan (Treviño) 6e9db05601 mir: add OpenGL support
Implement GdkGLContext using EGL and use hardware mir surfaces
when a GdkWindow uses gl rendering.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=740346
2014-11-20 04:33:38 +01:00
Matthias Clasen 45cfb405c0 GtkModelButton: Don't show both text and icon
The intention was that ::iconic indicates which representation is
preferred (text or icon). We fall back to the other representation
if one is missing.
2014-11-19 21:14:30 -05:00
Matthias Clasen d51c9e0337 GtkPopoverMenu: be more careful about change notification
Only emit notify for ::visible-submenu when the visible page
in the stack actually changed.
2014-11-19 21:14:30 -05:00
Kjartan Maraas 46b6c2f024 Updated Norwegian bokmål translation. 2014-11-19 19:42:51 +01:00
Kjartan Maraas 048bbb0e6d Updated Norwegian bokmål translation. 2014-11-19 19:31:09 +01:00
Daniel Mustieles 17fce05123 Updated Spanish translation 2014-11-19 13:48:15 +01:00
Lapo Calamandrei 7197758600 Adwaita: typo fix 2014-11-18 15:17:06 +01:00
Matthias Clasen 955c798ab1 GtkPopoverMenu: expose more properties
Expose the position as a child property and the visible page
as a property. These are useful in glade.
2014-11-18 13:39:15 +01:00
Matthias Clasen cd8576ec19 GtkStack: Fix an oversight in child renaming
We currently emit a warning if you rename a child to the name
it already has. We shouldn't do that.
2014-11-18 13:37:51 +01:00
Tom Tryfonidis d31896bdba Updated Greek translation 2014-11-18 08:36:28 +00:00
Timm Bäder 0fac139057 Revert "GtkMenuSectionBox: Add tooltip to iconic buttons"
This reverts commit 7543e7b279.
2014-11-17 18:39:15 +01:00
Timm Bäder 9b83858d9a Revert "popover: Add show/hide transition"
This reverts commit 17f48e3a9e.
2014-11-17 18:39:00 +01:00
Timm Bäder 56133a1feb GtkDialog: Connect to activate signals only once
If the widget is an action widget, it's been previously added with
gtk_dialog_add_action_widget, which calls add_response_data on it, which
in turn connects to the clicked/activate signal of that widget, so we
don't need to connect to that signal a second time in
gtk_buildable_custom_finished.
2014-11-17 18:37:47 +01:00
Timm Bäder 17f48e3a9e popover: Add show/hide transition 2014-11-17 18:37:47 +01:00
Timm Bäder 7543e7b279 GtkMenuSectionBox: Add tooltip to iconic buttons 2014-11-17 18:37:47 +01:00
Marco Trevisan (Treviño) e0e46a4f6b mir: update surface type based on events 2014-11-17 17:23:36 +01:00
Carlos Garnacho 7651061920 scrolledwindow: Avoid too frequent redraws of scrollbars
When overshooting through touchpad kinetic scrolling, the scrollbar remains
mostly static as it already hit a boundary. However, the fade in/out checks
are constantly run during scroll events, causing needless redraws in this
specific case.
2014-11-17 16:55:08 +01:00
Carlos Garnacho 6d5f2ff87e scrolledwindow: Only render background/frame on the widget window
Otherwise it is rendered too on each indicator window, possibly bringing
in an unintended opaque background there. Better seen with git show -b.
2014-11-17 14:55:05 +01:00
Marco Trevisan (Treviño) da8fdab87b mir: fix typo in GDK_IS_WINDOW_MIR definition 2014-11-17 14:02:22 +01:00
Marco Trevisan (Treviño) acfc4f8910 mir: invert scrolling delta 2014-11-17 14:02:22 +01:00
Robert Ancell 5ff39b207b mir: Require mirclient >= 0.9.0
Recent changes to the Mir backend require an unreleased version.
2014-11-17 10:49:13 +13:00
Matthias Clasen ecfcb3e2cc Make gtk_container_remove work on popover menus
Extend the hack we have in place for composite containers to
GtkPopoverMenu.
2014-11-16 02:30:19 -05:00
Matthias Clasen 1e39790c49 GtkPopoverMenu: Implement forall
This is required to make glade work.
2014-11-16 02:30:19 -05:00
Lapo Calamandrei 4f7abe3762 Adwaita: no border radius for GtkTreeView:selected 2014-11-15 19:08:13 +01:00
Lapo Calamandrei 268efd1475 textview: remove osd style class from touch selection popover
The touch-selection class is sufficient since that needs special
casing whatever.
2014-11-15 16:09:39 +01:00
Lapo Calamandrei df7b275de8 entry: remove osd style class from touch selection popover
The touch-selection class is sufficient since that needs special
casing whatever.
2014-11-15 16:08:15 +01:00
Lapo Calamandrei beb28dd3e9 Adwaita: :selected cleanup and rationalization 2014-11-15 15:54:20 +01:00
Marco Trevisan (Treviño) f5c5e9385e mir: handle more surface types 2014-11-14 23:19:15 +01:00
Marco Trevisan (Treviño) 8bc523ef59 mir: fix compilation in mirscreen 2014-11-14 23:19:15 +01:00
Lapo Calamandrei 32aa33e8d1 Adwaita: popover scss cleanup 2014-11-14 19:34:09 +01:00
Lapo Calamandrei ebc379287f Adwaita: more overshoot tweakings and typo fix 2014-11-14 18:58:22 +01:00
Matthias Clasen a7173d097f Make overlay scrollbar fading interruptible
When the pointer starts hovering the scrollbar after it already
started fading out, interrupt the fade and keep the scrollbar
around.
2014-11-14 11:49:33 -05:00
Matthias Clasen 95b075b8eb Drop unused variables
Keeps the compiler happy.
2014-11-14 11:48:50 -05:00
Lapo Calamandrei a30a54a521 Adwaita: overshoot style tweaks
Trying to make it visible on the dark variant.
2014-11-14 15:37:02 +01:00
Matthias Clasen 2d1c7b8937 Trivial formatting fix 2014-11-14 06:16:41 -05:00
Matthias Clasen 49cf85509a GtkPopover: Survive attach_widget == NULL
We can't render a tail, but otherwise things should just work.
This will be useful in glade.
2014-11-14 06:16:41 -05:00
Chun-wei Fan 61286d5927 gdk/gdkgl.c: Fix Typo
The extra ';' actually broke builds on C89 compilers...
2014-11-14 17:26:29 +08:00
Josef Andersson ef6d5ddf27 Updated Swedish translation 2014-11-13 22:01:55 +00:00
Carlos Garnacho 632accd9cc scrolledwindow: Use a fully transparent background for the overlay window
The background will be already given and updated in the GtkScrollbar widget,
plus the background remained static on the window since it is realized.
2014-11-13 21:25:52 +01:00
Kjartan Maraas ed9202bf67 Updated Norwegian bokmål translation. 2014-11-13 21:13:02 +01:00
Carlos Garnacho b591cacc39 scrolledwindow: Don't doubly draw overlay-indicator scrollbars
The scrollbars are still internal children of the GtkScrolledWindow
and handled in ::forall(), no need to propagate draw here again
after chaining up in ::draw().
2014-11-13 20:32:36 +01:00
Carlos Garnacho 733f70ea84 gtkpopover: Fix allocation of child widget wrt margins
During size request, all sides' margins are ensured to be as big
as TAIL_HEIGHT, just to avoid possible relocation loops if the
popover doesn't fit in its original position. This must be
accounted for in size_allocate() as well.
2014-11-13 20:32:36 +01:00
Carlos Garnacho e0353b37a8 scrolledwindow: Only render overshoot on the widget window
Without any check, it was being rendered also on the indicator
GdkWindows, which resulted on an over-exposed effect there.
2014-11-13 20:32:36 +01:00
Lapo Calamandrei 69c30fda5c Adwaita: reset some properties in the overshoot mixin
Otherwise we may inherit them see:
https://bugzilla.gnome.org/show_bug.cgi?id=740011
2014-11-13 18:47:42 +01:00
Lapo Calamandrei 360b516ef4 Adwaita: overshoot styling 2014-11-13 18:31:50 +01:00
Daniel Mustieles 8a5092d1d9 Updated Spanish translation 2014-11-13 13:57:46 +01:00
Daniel Mustieles 7887badaa1 Updated Spanish translation 2014-11-13 13:54:12 +01:00
Lapo Calamandrei c9d0bd8a72 Adwaita: simplify scrollbar styling
By the use of slider margins. In the process darken the overlay
scrollbar trough in fine-tune mode to make it noticiable.
2014-11-13 11:26:40 +01:00
Matthias Clasen 85a539ce6d inspector: Add frame clock info
Add the frame clocks of toplevel widgets to the object tree,
and show their frame count and frame rate in the misc tab.
2014-11-12 22:52:59 -05:00
Marco Trevisan (Treviño) c42146d88c mir: get/set window surface type 2014-11-13 04:42:48 +01:00
Marco Trevisan (Treviño) c7e7e35083 mir: don't request more surface formats than the supported ones 2014-11-13 03:59:29 +01:00
Matthias Clasen 45528440e6 inspector: Show the refcount on the misc tab 2014-11-12 21:58:08 -05:00
Matthias Clasen 72b9d2861c inspector: Update misc-info while the tab is shown
Update the values on the page once per second, while the tab
is shown.
2014-11-12 21:45:16 -05:00
Marco Trevisan (Treviño) 4e4ccb76cd mir: implement screen get_plug_name 2014-11-13 02:26:38 +01:00
Marco Trevisan (Treviño) a77571c42e mir: clear screen objects correctly 2014-11-13 02:19:29 +01:00
Marco Trevisan (Treviño) 0d024c2df8 mir: don't crash when querying infos for an invalid monitor 2014-11-13 02:07:46 +01:00
Marco Trevisan (Treviño) c8826ba8c7 mir: clear screen data 2014-11-13 01:59:21 +01:00
Marco Trevisan (Treviño) 98a8c66970 mir: correctly get screen mm sizes 2014-11-13 01:47:56 +01:00
Marco Trevisan (Treviño) c6de20496c mir: unset config change callback on finalize 2014-11-13 01:34:10 +01:00
Marco Trevisan (Treviño) 92c2e99dda mir: actually pass the GdkMirScreen to display config change cb 2014-11-13 01:30:10 +01:00
Matthias Clasen e2ce0700a6 GtkCssProvider: Load themes from versioned directories
Look for themes in $prefix/themes/$name/gtk-$version/ (for
version = 3.16, 3.14, ...), before using the old location
$prefix/themes/$name/gtk-3.0/. This gives theme authors a
way to support multiple versions of GTK+ 3 with separate
css files.
2014-11-12 19:22:55 -05:00
Matthias Clasen 55fd3a762c GtkCssProvider: Factor out a function
Move finding the gtk.css file into its own function. We will
make this more complicated in the near future.
2014-11-12 18:20:35 -05:00
Matthias Clasen 6a618bf48c widget-factory: Add some margins to text views 2014-11-12 17:23:45 -05:00
Matthias Clasen d50dd1d33c gtk3-demo: Use better text margins
We really want margins around the scrollable content, not around
the viewport. Make it so by using textview-specific properties.
This is unfortunately a little complicated for top/bottom.
2014-11-12 16:05:49 -05:00
Lapo Calamandrei bac7408be4 Adwaita: set scale trough margins where they belong. 2014-11-12 17:30:59 +01:00
Lapo Calamandrei 5108a27e6c gtkrange: consider css margin on the slider
Css margin now works on the slider as they do on the trough.
The margin is not considered in the space allocation as it is for
the trough, so the slider width will be the set slider-width -
margins. Spefifying margins on the main widget in the css will
clearly affect both the trough and the slider, so theme changes are
needed.
2014-11-12 17:20:53 +01:00
Matthias Clasen e14cf55b31 Forgotten files 2014-11-12 07:36:04 -05:00
Daniel Mustieles 00631af967 Updated Spanish translation 2014-11-12 13:31:27 +01:00
Daniel Mustieles 79ac0caa98 Updated Spanish translation 2014-11-12 13:27:56 +01:00
Debarshi Ray 3f4bed4d8f query, searchengine: Drop unused and undefined function declarations
https://bugzilla.gnome.org/show_bug.cgi?id=739977
2014-11-12 13:23:59 +01:00
Matthias Clasen fc855eea7a GtkActionBar: Make ::position writable 2014-11-11 23:02:11 -05:00
Matthias Clasen 047bb15cd7 GtkActionBar: Rename center_box to box 2014-11-11 23:01:16 -05:00
Matthias Clasen 21e3d4f2f7 inspector: Turn off search where we don't have a search bar yet
Avoid the builtin treeview search popup everywhere.
2014-11-11 22:42:51 -05:00
Lapo Calamandrei 4aca13e39e Statusbar: add 'statusbar' style class 2014-11-11 17:23:04 +01:00
Lapo Calamandrei 95aa4769f6 Adwaita: add a missing comma... 2014-11-11 16:12:47 +01:00
Matthias Clasen c8d9e5b564 GtkStack: Remove some clumsy use of GList API
No need for g_list_next(), and don't open-code g_list_index().
2014-11-10 18:45:58 -05:00
Matthias Clasen 8b95515c0c inspector: Only set debug-updates for the default display
Use the new private API to isolate the inspector itself from
this setting.
2014-11-10 15:24:08 -05:00
Matthias Clasen d9b02ea4a3 gdk: Make debug-updates a per-display setting
Add private API to set this per-display, and make the existing
gdk_window_set_debug_update function set a global default.
2014-11-10 15:23:14 -05:00
Matthias Clasen 5c5c8bdd81 inspector: Add a rendering mode control 2014-11-10 15:07:52 -05:00
Matthias Clasen 5536d9bcde gdk: Add private API for rendering mode
This will be used to expose rendering mode in the inspector.
2014-11-10 14:39:57 -05:00
Matthias Clasen 8338b7e4cd Move rendering mode into GdkDisplay
This is in preparation for making it runtime-settable in the
inspector.
2014-11-10 14:28:43 -05:00
Javier Jardón 710f332082 configure.ac: Depend on cairo 1.14.0
This is needed for cairo_set_device_scale()
2014-11-10 15:12:17 +00:00
Emmanuele Bassi 36fedb0c4b window: GtkPlug is conditionally supported on X11 only
We cannot do a type check on it if we don't have the X11 backend
compiled in.

https://bugzilla.gnome.org/show_bug.cgi?id=739885
2014-11-10 15:08:44 +00:00
Alexander Larsson 90555e06be gdk_window_end_paint: Flush destination surface after paint
It seems in cairo 1.14 we need this after having painted an image surface
to a X11 window surface (i.e. with GDK_RENDERING=image).
2014-11-10 15:25:31 +01:00
Baurzhan Muftakhidinov a353e77db4 Updated Kazakh translation 2014-11-10 02:23:15 +00:00
Matthias Clasen 8a8c6c0722 Inspector: hide the selector tab for non-widgets 2014-11-08 21:43:26 -05:00
Matthias Clasen 9a84d8a261 inspector: Hide the size-groups tab when empty 2014-11-08 21:30:12 -05:00
Matthias Clasen 0c20ba7dcb inspector: Hide the inspector tab when empty 2014-11-08 21:29:51 -05:00
Matthias Clasen 7dd466ad74 Set the clip on range widgets
This will allow better scrollbar theming.
2014-11-08 12:55:37 -05:00
Lapo Calamandrei c0c777077a Adwaita: increase scrollbar slider contrast 2014-11-08 17:35:52 +01:00
Matthias Clasen ae4aaf7354 inspector: Set statistics button sensitivity
After moving the button the header, it is now visible when
statistics are not available. Disable it in this case.
2014-11-08 09:57:48 -05:00
Matthias Clasen 592a0d46b4 inspector: Add more GL information
Add version and extension information to the general tab.
2014-11-08 02:16:35 -05:00
Emmanuele Bassi cdcd3ca359 Hide GdkWindow libgtk_only API in the private vtable
These are the last two global GDK symbols that have a libgtk_only
suffix.

https://bugzilla.gnome.org/show_bug.cgi?id=739781
2014-11-08 00:20:15 -05:00
Emmanuele Bassi 585af218a3 Move GDK GL flags accessors to the private vtable
This allows us to use the GDK_PRIVATE_CALL macro inside gtk.

https://bugzilla.gnome.org/show_bug.cgi?id=739781
2014-11-08 00:20:15 -05:00
Emmanuele Bassi eedbec2066 Make global GDK libgtk_only functions more private
The current way of exposing GDK API that should be considered internal
to GTK+ is to append a 'libgtk_only' suffix to the function name; this
is not really safe.

GLib has been using a slightly different approach: a private table of
function pointers, and a macro that allows accessing the desired symbol
inside that vtable.

We can copy the approach, and deprecate the 'libgtk_only' symbols in
lieu of outright removal.

https://bugzilla.gnome.org/show_bug.cgi?id=739781
2014-11-08 00:20:15 -05:00
Matthias Clasen 713d3834f6 inspector: Reserve space for buttons
Make the button area in the top left a stack that is parallel
to the main page stack. This avoids size changes as we switch
between pages.
2014-11-08 00:09:30 -05:00
Matthias Clasen e2949e7bf7 extract-strings: Handle property binding attributes
These attributes are now used in at least one place in the
GtkInspector ui files.
2014-11-08 00:09:30 -05:00
Matthias Clasen d0973fdb78 inspector: Improve search on the statistics page
Use a search bar here as well, instead of the builtin treeview popup.
2014-11-07 23:40:31 -05:00
Matthias Clasen 5f701cf4c9 inspector: Move the record button up
Give all the page space to the content.
2014-11-07 23:19:28 -05:00
Matthias Clasen 1ddace0a5f inspector: Shorten some labels 2014-11-07 22:57:14 -05:00
Matthias Clasen 818d2e238b inspector: Improve search in the resource tree
Make search in the resource tree work the same way as the new
search in the object tree.
2014-11-07 22:44:23 -05:00
Matthias Clasen 48415955f0 inspector: Correct a tooltip 2014-11-07 22:44:23 -05:00
Jasper St. Pierre 433120ae5e gdkwindow-x11: Fix indentation 2014-11-07 17:39:43 -08:00
Jasper St. Pierre a91c88768e inspector: Remove unused variable 2014-11-07 16:33:43 -08:00
Matthias Clasen ee01ee249f inspector: Look for themes in the right places
Match the places that GtkCssProvider looks in, so we show all
the themes that GTK+ would actually find.
2014-11-07 14:19:59 -05:00
Carlos Garnacho af6eab850e wayland: Schedule a clock tick instead of wl_surface_commit()ting directly
Instead of possibly calling wl_surface_commit() out of
GdkFrameClock::after-paint, tick the transient parent clock so ::after-paint
can be eventually run.

This ensures that the subsurface coordinates (considered part of the state
of the parent) aren't committed untimely, and guaranteed to be orderly with
the wl_subsurface-relative state.

This is a gtk-side fix for https://bugzilla.gnome.org/show_bug.cgi?id=738887
2014-11-07 17:24:10 +01:00
Carlos Garnacho 964abf7423 wayland: Don't translate a NULL region into an empty one
cairo_region_copy(NULL) will effectively return an empty region, as this
function is always meant to return valid memory. This however inverts the
meaning of the NULL region and results in entirely non-clickable windows.
2014-11-07 17:23:54 +01:00
Carlos Garnacho 52a90758f9 gtkwindow: claim the press sequence when clicking on the titlebar
This event might not have an action yet, but certainly accounts, and
should be triggering recognition.

This fixes a crash when attempting to drag CSD windows through touch. As
since cfaec2d2f5, gtk_gesture_single_get_current_sequence() would
rightfully return NULL if the gesture didn't enter recognition, making
event lookup fail.
2014-11-07 13:54:10 +01:00
Carlos Garnacho 4df13b7262 treeview: remove single-click activation from GtkGestureMultiPress::pressed
This is already handled in GtkGestureMultiPress::release, and more in
concordance with how it was done pre-gestures.

https://bugzilla.gnome.org/show_bug.cgi?id=737891
2014-11-07 13:49:43 +01:00
Matthias Clasen 1e3e544bfd Revert "Add new API to docs"
This reverts commit 41e9eaf64f.
2014-11-07 07:12:22 -05:00
Matthias Clasen 5442293ce7 inspector: include private gdk headers
...the advantages of living in the same tree.
2014-11-07 07:11:38 -05:00
Matthias Clasen 7e405c286f Don't make the gl flags API
We need to export the symbols so they can be used in the
inspector, but we don't really want to make this supported
public API, so keep them out of installed headers.
2014-11-07 07:10:49 -05:00
Matthias Clasen 41e9eaf64f Add new API to docs 2014-11-06 23:37:00 -05:00
Matthias Clasen 0ecd08ed04 inspector: Add GL flags 2014-11-06 23:35:38 -05:00
Matthias Clasen 5d0d1e524e Export API to set GL flags
This will be used in the inspector.
2014-11-06 23:29:16 -05:00
Lapo Calamandrei d859cf19f6 Adwaita: scrollbar styling overhaul
- finally added the missing border;
  - proper backdrop state styling;
  - tweaked overlay indicator;
  - sidebar special casing gone for now.
2014-11-07 00:03:29 +01:00
Jasper St. Pierre 22ad7b7782 gdkgl: Make some helper functions static 2014-11-06 13:48:20 -08:00
Ryan Lortie ec729d0649 mir: rework cursors a bit
Store the cursor name on the cursor (rather than always using its type).

Use this when setting a cursor on a surface.

The mir server will fallback to using standard cursors from the cursor
theme if the name used is not one of those defined by mir, which is more
or less what we want to happen here in case of creating a cursor by
name.
2014-11-06 16:18:53 -05:00
William Hua 063f79b594 mir: enable csd 2014-11-06 16:18:53 -05:00
William Hua 2fdb266c0d mir: set cursor 2014-11-06 16:18:53 -05:00
Matthias Clasen f60b2a11c5 Drop an unneeded include 2014-11-06 15:17:09 -05:00
Matthias Clasen f229f96d69 GtkModelButton: protect against show_all
We don't want the labels to be shown when there's already
an icon.
2014-11-06 15:03:51 -05:00
Alexander Larsson 41bf293efd GdkWindow: Drop gl matrix setup which is not needed anymore. 2014-11-06 20:37:24 +01:00
Alexander Larsson 61eabc4778 gdk_gl_texture_from_surface: Enable scissor test 2014-11-06 20:37:10 +01:00
Alexander Larsson 56631d02bd gdk_gl_texture_quad: Fix handling of window scales 2014-11-06 19:33:58 +01:00
Lapo Calamandrei c756cef80a Adwaita: remove last child border on backdrop column headers 2014-11-06 17:21:50 +01:00
Lapo Calamandrei d781599b0d Adwaita: initial overlay indicator styling 2014-11-06 12:40:40 +01:00
Alexander Larsson 1f3f933edf GdkX11GLContext: Use bitblit for swap if no buffer age support
If buffer age is undefined and the updated area is not the whole
window then we use bit-blits instead of swap-buffers to end the
frame.

This allows us to not repaint the entire window unnecessarily if
buffer_age is not supported, like e.g. with DRI2.
2014-11-06 12:24:43 +01:00
Alexander Larsson 21189b9f7e Add gdk_gl_context_has_framebuffer_blit()
This checks if the context supports GL_EXT_framebuffer_blit
2014-11-06 12:24:43 +01:00
Alexander Larsson 5f9e6ec2dc GdkGL: Fix up GL_ARB_texture_rectangle support
This broke when gdk_gl_texture_quad moved to shaders. We need
a specialized shader for the rectangle case.
2014-11-06 12:24:43 +01:00
Alexander Larsson 650c9f3b7e Add support for GDK_GL=texture-rectangles
This allows us to test our support for GL_ARB_texture_rectangle
2014-11-06 12:24:43 +01:00
Alexander Larsson 90a5fa80af Add GDK_GL env var and GdkGLFlags
This moves the GDK_ALWAYS_USE_GL env var to GDK_GL=always.
It also changes GDK_DEBUG=nogl to GDK_GL=disable, as GDK_DEBUG
is really only about debug loggin.

It also adds some completely new flags:

 software-draw-gl:
   Always use software fallback for drawing gl content to a cairo_t.
   This disables the fastpaths that exist for drawing directly to
   a window and instead reads back the pixels into a cairo image
   surface.

 software-draw-surface:
   Always use software fallback for drawing cairo surfaces onto a
   gl-using window.  This disables e.g. texture-from-pixmap on X11.

 software-draw:
   Enables both the above.
2014-11-06 12:24:43 +01:00
Alexander Larsson 7fde5213b0 gdk_cairo_draw_from_gl: Remove useless call
The glFramebufferTexture2DEXT call makes no sense here, we're
not using the texture as a framebuffer, just as a normal
texture source.
2014-11-06 12:24:43 +01:00
Alexander Larsson 9372cbdbf8 GdkWindow: Try to use a Core 3.2 GL profile for the paint context
If this is supported we avoid a lot of legacy baggage which we don't
need.
2014-11-06 12:24:43 +01:00
Alexander Larsson e417b18373 gdk_gl_texture_quad: Use shaders to texture things
This is the modern way OpenGL works, and using it will let us
switch to a core context for the paint context, and work on
OpenGL ES 2.0.
2014-11-06 12:24:43 +01:00
Alexander Larsson c78e7e7f17 GdkGL: Rename "context" to "paint_context" to clarify things a bit 2014-11-06 12:24:43 +01:00
Alexander Larsson aaa335b9e8 gdk_cairo_draw_from_gl: Document that this changes the current context 2014-11-06 12:24:43 +01:00
Alexander Larsson 8c6395d8a1 GdkGLContextX11: Use passed in context, not get_current() 2014-11-06 12:24:43 +01:00
Alexander Larsson 10a44e8f7a Add gdk_gl_texture_quad() helper
Right now this just centralizes the glBegin/glEnd code, but
this will be replaced with buffer objects later.
2014-11-06 12:24:43 +01:00
Alexander Larsson 3c34ca3405 gdkgl: Don't constantly re-create the tmp framebuffer 2014-11-06 12:24:43 +01:00
Dimitris Spingos 0ac24904bd Updated Greek translation 2014-11-06 13:49:23 +02:00
Matthias Clasen 5a01208f55 GtkHeaderBar: Queue a resize when pack-type is changed
Otherwise, buttons appear to stick to the wrong side in glade.
2014-11-06 01:05:51 -05:00
Robert Ancell 053b65a21a mir: Handle pointer up/down events without a button mask set (i.e. touch events)
The Mir backend was checking for button mask changes to generate the appropriate
GDK event. When Mir generates a touch event it has no button mask. In this case
we'll just generate a primary button event.
2014-11-06 11:15:52 +13:00
Lapo Calamandrei fdc01f80af Adwaita: dim GtkPlacesSidebar icons color 2014-11-05 16:01:28 +01:00
Benjamin Otte 0e44722fd8 tests: Add deprecation guards
It's the last test still spewing these and I'm too lazy to do a proper
fix.
2014-11-05 13:06:32 +01:00
Matthias Clasen dd7a851f69 widget-factory: Fill up page 2 properly
The collapsed expander leaves and odd empty corner, so expand
it initially.
2014-11-05 06:29:47 -05:00
Matthias Clasen 45c0461f9b widget-factory: Add another osd
This is modeled after the totem osd.
2014-11-05 06:13:39 -05:00
Alexander Larsson dd721acb84 GdkGLContextX11: Only set swap interval when it changed 2014-11-05 12:02:18 +01:00
Alexander Larsson e4bf60224b GdkGL: Fix and clean up gdk_cairo_draw_from_gl()
This was unnecessarily creating a framebuffer in the texture case,
and it was not properly setting up a framebuffer with the texture
as source in the software fallback w/ texture source case.
2014-11-05 09:54:05 +01:00
Robert Ancell c41231cc0f mir: Don't assert on unknown Mir events.
If we get a Mir event we don't understand generate a warning instead of an assert.
2014-11-05 15:50:55 +13:00
Matthias Clasen e2882e4845 GtkHeaderBar: Make the position child property writable
Glade asssumes that it is, and without this, rearranging children
in glade is very cumbersome.
2014-11-04 16:56:25 -05:00
Carlos Garnacho d9a433daf7 gtkwindow: Resort to regular event bubbling by all means on non-toplevels
If the multipress gesture is not created (ie. not a toplevel GtkWindow),
also avoid possibly calling gtk_widget_event() on the events gotten here.
2014-11-04 19:03:27 +01:00
Carlos Garnacho 03a30e462e gtkwindow: Do not create the multipress gesture for plugs
GtkPlugs may "qualify" as toplevels, even though they're not meant to
be WM manipulated, so refuse to create the multipress gesture for these
too.
2014-11-04 19:03:18 +01:00
Yosef Or Boczko 5f26876acb Updated Hebrew properties translation 2014-11-04 19:23:13 +02:00
Yosef Or Boczko 2eb874a8b0 Updated Hebrew translation 2014-11-04 19:22:40 +02:00
Lapo Calamandrei c160340e6c Adwaita: brighter dark variant header-bar bottom shade 2014-11-04 14:59:24 +01:00
Matthias Clasen 113e1d1dc0 Make window scale changes work again
Commit afd9709aff made us keep impl window
cairo surfaces around across changes of window scale. But the
window scale setter forgot to update the size and scale of the
surface. The effect of this was that toggling the window scale
from 1 to 2 in the inspector was not causing the window to draw
at twice the size, although the X window was made twice as big,
and input was scaled too. Fix this by updating the surface when
the window scale changes.
2014-11-03 22:35:11 -05:00
Matthias Clasen 824fa0314d Add some more builder tests 2014-11-03 19:07:18 -05:00
Alexander Larsson ef9ac24e95 GtkGLArea: Correctly position/size input window on realize 2014-11-03 13:35:00 +01:00
Alexander Larsson 6fbc439fd7 GdkGLContext: Add display property
We need to use this in the code path where we make the context
non-current during destroy, because at that point the window
could be destroyed and gdk_window_get_display() would return
NULL.
2014-11-03 13:20:55 +01:00
Alexander Larsson 3656c21030 GtkGLArea: Don't dispose gl context on unrealize
This was done to ensure the context is not current, but this is
pretty broken for shared contexts. We now just make it non-current.
2014-11-03 13:19:40 +01:00
Alexander Larsson 9930e6dcaa GtkGLArea: Add create-context signal
This lets you hook into the GL context creation which is useful
if you want to share one GL context between GtkGLArea widgets.
2014-11-03 10:43:31 +01:00
Matthias Clasen 4aa0d16865 Only warn once if inhibit-related dbus calls fail
No need to spam about it.

https://bugzilla.gnome.org/show_bug.cgi?id=734140
2014-11-03 00:48:42 -05:00
Matthias Clasen 95e8ae6e75 GtkIconTheme: Improve an error message
Mention the name of the theme when an icon lookup fails.
https://bugzilla.gnome.org/show_bug.cgi?id=687963
2014-11-03 00:25:14 -05:00
Matthias Clasen 2aa3eea781 GtkFileChooser: Add a menuitem for 'sort directories first'
This has been requested repeatedly.
2014-11-03 00:02:13 -05:00
Alberts Muktupāvels bdaef1f88d gtkmenu: fix unnecessary scroll buttons
Don't change menu height if menu is out of monitor only by shadow
width.

https://bugzilla.gnome.org/show_bug.cgi?id=738321
2014-11-02 22:11:03 -05:00
Lapo Calamandrei 264cab2b52 Adwaita: add borders to menus in a non composited env
https://bugzilla.gnome.org/show_bug.cgi?id=738800
2014-11-02 22:04:14 -05:00
Matthias Clasen 2873195644 GtkHeaderBar: Fix a corner-case in child properties
The child property setting must be prepared to deal with any
child property for any child, even if it doesn't make sense,
like the pack-type for the custom title. This is happening
in glade when undoing a change in the custom-title property.
2014-11-02 17:49:47 -05:00
Dimitris Spingos cc22325612 Updated Greek translation 2014-11-02 10:52:52 +02:00
Matthias Clasen 120abd9a6e csd: Improve appearance inside glade
glade turns windows into non-toplevels, so we can easily recognize
that situation and avoid adding a humongous shadow area.
2014-11-01 14:49:02 -04:00
Matthias Clasen 1a3bdefb00 Fix an ordering issue in event destruction
gdk_event_get_display accesses event->any.window, so don't
free that window first thing.
2014-11-01 14:44:03 -04:00
Matthias Clasen 18a2a6a90e GtkVolumeButton: Fix annoying double formatting
We meant to specify 0.2, and it came out as 0.2000000001.
2014-11-01 13:21:00 -04:00
Matthias Clasen d8cc9d9a51 glade: Add GtkColorEditor to private widgets 2014-11-01 13:20:59 -04:00
Matthias Clasen ffa49723a2 glade: Drop a no-longer existing private widget
GtkScaleButtonScale fell by the wayside when the scale button
was ported to a popover.
2014-11-01 13:20:59 -04:00
Cosimo Cecchi 276a510b4b radiobutton: don't consider hidden buttons in the group for focus
When a GtkRadioButton has no focus, it will accept it when there is no
other active button in its group.
If the active button in the group is hidden, for example because the UI
desires not to have a default option pre-selected, currently the focus
will not be accepted, which is not desired behavior.

This commit changes the code to only consider visible buttons in the
group when checking whether another button is active.

https://bugzilla.gnome.org/show_bug.cgi?id=739474
2014-11-01 10:08:42 -07:00
Matthias Clasen e6e511eb46 GtkListBox: Fix a bug in unselection
Ensure that gtk_list_box_get_selected_row returns NULL after
gtk_list_box_unselect_all. Add a testcase that detects this
problem.
2014-10-31 22:34:09 -04:00
Matthias Clasen fcdec5ac41 icon-browser: Add search
Most of the code was already in place, just some loose ends
to fix up.
2014-10-31 22:28:17 -04:00
Matthias Clasen 3c997239e9 inspector: Search refinements
Show close buttons on all search bars.
2014-10-31 21:14:09 -04:00
Matthias Clasen 3f3725d97b inspector: Refine object tree search
Behave similar to traditional treeview search, and center
the row when moving between matches.
2014-10-31 21:13:18 -04:00
Matthias Clasen 992c5f0dd6 inspector: Add search to the object tree
This is also an attempt to figure out a better story for search
in treeviews.
2014-10-31 21:02:50 -04:00
Matthias Clasen 69a0b31d2d Trivial: sort file list alphabetically 2014-10-31 14:16:02 -04:00
Lapo Calamandrei 00f618ea1a Adwaita: special case .default-decoration
Titlebars which are just window handles can be smaller.
2014-10-31 16:53:23 +01:00
Lapo Calamandrei 5a5e74bbe2 Adwaita: simpler gtkcalendar style (once again) 2014-10-31 16:44:21 +01:00
Matthias Clasen 89e12495b6 inspector: Improve search in style property list
Use a search bar with a search entry instead of the builtin
treeview search popup.
2014-10-30 20:54:54 -04:00
Matthias Clasen 574c774e4e inspector: Improve search in property list
Use a search bar with a search entry instead of the builtin
treeview search popup.
2014-10-30 20:54:04 -04:00
Matthias Clasen 42e1fad138 inspector: Stop overeager activation
Stop using activate-on-single click for the property list -
it is a little annoying to have the popover come up when you
just click in the list to get the focus there.
2014-10-30 18:47:46 -04:00
Alexander Larsson f66060c422 GdkGLArea: fix has_alpha changes at runtime
We need to completely reallocate the buffers if we switch
has_alpha, because we may switch from render buffers to
texture.
2014-10-30 21:04:29 +01:00
Alexander Larsson 37d0159a84 GtkGLArea: Add resize signal
This is very useful, as almost all GL code wants to recalculate
the cameras each time the window size changes.
2014-10-30 21:04:29 +01:00
Alexander Larsson 969b9c6552 GtkGLArea: Add profile property
This lets you force a core 3.2 context if you want
2014-10-30 21:04:29 +01:00
Alexander Larsson b519b642bd GtkGLArea: Add INPUT_ONLY window so that we can get events 2014-10-30 21:04:29 +01:00
Alexander Larsson 5ea3a1028d GtkGLArea: Major reworking
This restructures the way buffers are allocated and bound in a way
that is more flexible.

Buffer operation happens in three phases:
create_buffer() - Creates the gl objects
allocate_buffers() - Allocates space for the buffers at a given size
attach_buffers() - Attaches the buffers to the framebuffer and makes
                   the framebuffer the default drawing target
And destroy via
delete_buffers()

We call all these the first draw, and after that we allocate buffers
each time the widget changes size until the buffers are deleted.
We delete the buffers at unrealize.

However, anyone that wants to manually control buffer allocation strategies
can manually call allocate/delete_buffers().

There are also some other changes:
* Support for stencil buffers.
* A manual render mode where ::draw doesn't render unless you manually
  invalidated the previous rendering.
2014-10-30 21:04:29 +01:00
Alexander Larsson 869f300f0a gdk_x11_display_make_gl_context_current: move some code
This moves the code related to the frame sync code into
the is_attached check, which means we don't have to ever
run this when making non-window-paint contexts current.

This is a minior speed thing, but the main advantage
is that it makes making a non-paint context current
threadsafe.
2014-10-30 21:04:29 +01:00
Lapo Calamandrei 7a73ec1bb2 Adwaita: darken a bit OSD background color
To not make it vanish on dark variant background color.
2014-10-30 18:42:31 +01:00
Matthias Clasen bb41cfe9d9 Improve warning
Mention the file that we're failing to load. That makes it obvious
what is wrong.
2014-10-30 13:41:13 -04:00
Matthias Clasen cacda8086e inspector: Add HighContrast to built-in themes list 2014-10-30 12:52:25 -04:00
Matthias Clasen d8ba193e9a HighContrast: integrate in build machinery 2014-10-30 12:52:25 -04:00
Matthias Clasen fce2565673 Drop gtk.gresource.xml
Theme resources are controlled from the (generated) .gresource.xml
file two stories up.
2014-10-30 12:52:25 -04:00
Matthias Clasen 76b3fee093 HighContrast: Add sass parsing script
Just a copy of what we have next door in Adwaita.
2014-10-30 12:52:25 -04:00
Matthias Clasen 16d79e8883 HighContrast: Drop settings.ini
The only setting in there is already the default behavior,
and the setting is deprecated and ignored anyway.
2014-10-30 12:52:25 -04:00
Lapo Calamandrei efaabdad0a Adwaita: slightly contrasting popover background 2014-10-30 17:51:22 +01:00
Lapo Calamandrei fdbb93d78c Adwaita: border radiusses rationalization 2014-10-30 17:51:22 +01:00
Piotr Drąg 75d37acb25 Updated POTFILES.in 2014-10-30 17:21:40 +01:00
Jakub Steiner 495f764b3d theme: move HC theme from gnome-themes-standard
- HC is part of the toolkit the same way as Adwaita is
- No automake foo included
2014-10-30 16:14:37 +01:00
Alexander Larsson 0eb2fb01fd Add GdkGLContext::profile 2014-10-30 12:43:03 +01:00
Alexander Larsson 398697eb2f Clarify docs for gdk_cairo_draw_from_gl 2014-10-30 12:43:03 +01:00
Alexander Larsson f0ae8da993 Remove GdkGLContext::visual
This is not really needed. The gl context is totally tied to the
window it is created from by virtue of sharing the context with the
paint context of that window and that context always has the visual
of the window (which we already can get).

Also, all user visible contexts are essentially offscreen contexts, so
a visual doesn't make sense for them. They only use FBOs which have
whatever format that the users sets up.
2014-10-30 12:43:03 +01:00
Alexander Larsson ad30262fef GtkGLArea: Always destroy context on unrealize
We had some code that tried to reuse the context over realize, but
that doesn't work as we need to share with the possibly new
paint context of the re-realized window.
2014-10-30 12:43:03 +01:00
Alexander Larsson 5f14630b76 GdkWindow: destroy paint gl context on destroy 2014-10-30 12:43:03 +01:00
Alexander Larsson dbbab0791d GdkGLContext: Track shared context
This allows us to read it back, but primarily it ensures
the shared context wrapper stays alive as long as the context.
2014-10-30 12:43:03 +01:00
Alexander Larsson fb50015519 GdkGLContext: Change the way we track the current context
To properly support multithreaded use we use a global GPrivate
to track the current context. Since we also don't need to track
the current context on the display we move gdk_display_destroy_gl_context
to GdkGLContext::discard.
2014-10-30 12:43:03 +01:00
Lapo Calamandrei eb8f60f141 Adwaita: osd rationalization and tweakings
Removed bright translucent outer border for "top level" osd widgets,
insensitive osd entry styled, more meaningfull color variables and
some code rationalization.
2014-10-30 11:50:27 +01:00
Alexander Larsson afd9709aff GdkWindowX11: Keep the impl window cairo surface around until destroy
We used to have a weak ref to the cairo surface and it was keep
alive by the references in the normal windows, but that reference
was removed by d48adf9cee, causing
us to constantly create and destroy the surface.

https://bugzilla.gnome.org/show_bug.cgi?id=738648
2014-10-30 10:32:47 +01:00
Matthias Clasen 47191ce173 Make the inspector window translucent instead of lowering
Make the inspector window click-through and see-through
when we can, instead of lowering it. This is useful, since
Wayland has no lowering.
2014-10-29 23:29:20 -04:00
Lapo Calamandrei 7a1eabaf62 Adwaita: fix for the previous colorswatch fix...
Make the selected colorswatch inhert on backdrop.
2014-10-29 19:55:32 +01:00
Lapo Calamandrei 43a2676c3f Adwaita: fix selected colorswatch white border 2014-10-29 19:50:58 +01:00
Lapo Calamandrei bfd4933aa3 Adwaita: first round of OSD style converage
Some code refactoring, entry and spinbuttons and flat buttons
styled, more to come...
2014-10-29 18:40:28 +01:00
Carlos Garnacho b0313c7bcf wayland: Emit GDK_OWNER_CHANGE events around wl_data_offer changes
This way the upper GtkClipboard code emits correctly ::owner-change when
receiving these events.
2014-10-29 18:33:48 +01:00
Alexander Larsson c7451bbf3b GdkX11GLContext: Fix leak 2014-10-29 13:52:04 +01:00
Alexander Larsson 8c7623de84 Cache default gdk visuals in the GDK_VISUALS property on the root window
This means we don't have to try to initialize opengl in every gtk
instance that is stated. It will only happen for the first one.

https://bugzilla.gnome.org/show_bug.cgi?id=738670
2014-10-29 13:35:17 +01:00
Alexander Larsson dae447728d X11: Pick better system and rgba visuals for GL
We want to create windows with the default visuals such that we then
have the right visual for GLX when we want to create the paint GL
context for the window.

For instance, (in bug 738670) the default rgba visual we picked for the
NVidia driver had an alpha size of 0 which gave us a BadMatch when later
trying to initialize a gl context on it with a alpha FBConfig.

Instead of just picking what the Xserver likes for the default, and just
picking the first rgba visual we now actually call into GLX to pick
an appropriate visual.
2014-10-29 13:35:17 +01:00
Matthias Clasen 8765970ba1 Remove a redundant call
No need to set shapes twice in a row.
2014-10-29 06:49:59 -04:00
Matthias Clasen 0b4c37624a GtkPopoverMenu: Add API to open a submenu
This allows alternative menu switching to be implemented, besides
the builtin GtkModelButton support.
2014-10-29 06:49:59 -04:00
Matthias Clasen f83c903ed8 Add a scale to the popover menu example
Demonsttrate that this is flexible enough for the intended uses.
2014-10-29 06:49:59 -04:00
Matthias Clasen 6e001acbf9 Add documentation
Document GtkModelButton and GtkPopoverMenu.
2014-10-29 06:49:59 -04:00
Matthias Clasen 228e51b319 Adapt the testpopover example
Add the required boxes for each submenu. We now need to specify the
submenu name only once per submenu.
2014-10-29 06:49:59 -04:00
Matthias Clasen 55b7838b4f GtkPopoverMenu: Simplify
Change things so each submenu is a single child, and users are
required to create the box themselves.
2014-10-29 06:49:59 -04:00
Matthias Clasen 2b5a49c285 Adapt the testpopover example
Drop all all explicit role setting from the testpopover example.
2014-10-29 06:49:59 -04:00
Matthias Clasen 689363a782 GtkModelButton: Don't require an explicit role
When we have an action-name, we can deduce the role from the
action that is looked up by the action helper.
2014-10-29 06:49:59 -04:00
Matthias Clasen 2401a6cb8e Adapt the testpopover example 2014-10-29 06:49:59 -04:00
Matthias Clasen 14e394d3d7 GtkModelButton: Rename action-role to role
Rename action-role to role, and make all properties readable.
2014-10-29 06:49:59 -04:00
Matthias Clasen e776c665b0 GtkModelButton: Drop unused :accel property 2014-10-29 06:49:59 -04:00
Matthias Clasen 1fee63d097 Adapt the testpopover example
Drop all uses of has-submenu.
2014-10-29 06:49:59 -04:00
Matthias Clasen ef22be9bb7 Drop GtkModelButton:has-submenu
Replace the has-submenu property with checking menu-name != NULL.
2014-10-29 06:49:59 -04:00
Matthias Clasen 4da281d20b Adapt the testpopover example
We now use GtkPopoverMenu, and just add the model buttons
directly to it.
2014-10-29 06:49:58 -04:00
Matthias Clasen e095918128 GtkModelButton: Add a menu-name property
Add a menu-name property and use it in a default implementation
of ::clicked to switch menus if we are inside a stack. This means
GtkModelButton is no longer entirely generic, but rather expects
to be used inside a GtkPopoverMenu. It still works in other contexts
too, of course.
2014-10-29 06:49:58 -04:00
Matthias Clasen 1f81c83fd8 Add GtkPopoverMenu
GtkPopoverMenu is a GtkPopover subclass that has a menu-like stack
built-in.
2014-10-29 06:49:58 -04:00
Matthias Clasen a8cc4787d2 Add a manual popover menu example
Reproduce the testpopover popover manually, by packing model
buttons into a stack in a popover.
2014-10-29 06:49:58 -04:00
Matthias Clasen 83976c47f8 Make GtkModelButton a better GtkActionable
Rename the "toggled" property to "active", since that is what
GtkActionHelper expects to update for check and radio actions.
Also make the property readable, since GtkActionHelper wants
to read it.
2014-10-29 06:49:58 -04:00
Matthias Clasen fd945be50b Make GtkModelButton public 2014-10-29 06:49:58 -04:00
Matthias Clasen c9ad936011 Drop an unused variable 2014-10-29 06:49:58 -04:00
Alexander Larsson d5cd05a0f4 GdkGLContextX11: Don't free NULL visual info 2014-10-29 11:26:00 +01:00
Matthias Clasen 778865f316 Fix toplevel input shape for csd windows
We need to maintain the application-set and the the csd
input shape separately, and intersect them to pass them
down.
2014-10-28 20:23:47 -04:00
Matthias Clasen 3f1dc87188 Plug another memory leak
Also found by valgrind.
2014-10-28 16:07:57 -04:00
Matthias Clasen c8d4eefa71 Plug some memory leaks in GL support
valgrind pointed these out.
2014-10-28 16:07:57 -04:00
Alexander Larsson 0814cd9f8b GdkGlContextWayland: Don't require specific bit depths
This just means we may fail to get a gl context, we just require
*some* color depth.
2014-10-28 18:30:09 +01:00
Alexander Larsson 3406bbd128 Pick the first rgba visual, not the last
The visuals are typically sorted by some sort of "most useful first"
order. And picking the last one is likely to give us the weirdest
matching glx visual.
2014-10-28 18:30:09 +01:00
Alexander Larsson 8d6d6dcca3 GdkGLContextX11: Ensure we get the fbconfig with the exact same visual
We really want a gl context with exactly the same visual, or we will
get a badmatch later, which hits us on nvidia as per:

https://bugzilla.gnome.org/show_bug.cgi?id=738670
2014-10-28 18:30:09 +01:00
Matthias Clasen b673490a1b Document Wayland opacity handling 2014-10-28 10:48:49 -04:00
Matthias Clasen 4cf6edda55 wayland: Make window opacity work
Under wayland, the compositor doesn't have a 'overall window alpha'
knob, we just need to add the alpha to the buffers we send.
Client-side alpha, if you want to call it that.

Implement this by reusing the existing alpha support for non-toplevel
widgets. As a side-effect of the implementation, windows with RGBA
visual under X will now also use per-pixel alpha, instead of
overall alpha.
2014-10-28 10:28:23 -04:00
Matthias Clasen d58c750db5 Bump atk dep
Needed for ATK_STATE_HAS_TOOLTIP.
2014-10-28 08:08:49 -04:00
Matthias Clasen 850143b7a0 Inspector: Make picking work without a grab
Turns out Weston takes an X grab while delivering button events.
Thus, trying to take a grab in response to a button press is
futile.
2014-10-28 07:05:45 -04:00
Jasper St. Pierre c40ba85ace wayland: Don't use the default display
Pass a display in so that multi-display technology works.
2014-10-27 22:29:41 -07:00
Jasper St. Pierre bbe9ef20da gdkevents: Use the correct display to copy event data 2014-10-27 22:29:41 -07:00
Jasper St. Pierre 887b7356c3 gdkdisplay: Provide a default event_data_copy / event_data_free
Every single implementation but Quartz is a no-op for this, so just
provide it once rather than in every backend.
2014-10-27 22:13:23 -07:00
Matthias Clasen e36b57e7f9 gtk-demo: Drop uses of gdk_cursor_new()
Use gdk_cursor_new_for_display() instead.
2014-10-28 00:56:46 -04:00
Matthias Clasen abe7187cfb Add another multi-device invariant
The device and window passed to gdk_device_grab() must be
on the same display, or things are unlikely to work.
Document and assert this.
2014-10-28 00:54:39 -04:00
Matthias Clasen 86f66d26fe Drop an unused variable 2014-10-28 00:53:59 -04:00
Matthias Clasen 4c69dabb6e Don't return GDK_GRAB_SUCCESS on failure
That seems ... counterproductive.
2014-10-28 00:51:32 -04:00
Matthias Clasen d1dcac85f3 Mention the 'same display' requirement in the docs too 2014-10-28 00:44:33 -04:00
Matthias Clasen eedff39413 Deprecate gdk_cursor_new()
Too easy to introduce an unintended assumption about the display
being the default this way.
2014-10-28 00:38:59 -04:00
Matthias Clasen 8aecf2c06a GtkAboutDialog: Don't use gdk_cursor_new
gdk_cursor_new returns cursors for the default display, and
thus is not safe to use in code that may run on non-default
displays.
2014-10-28 00:36:17 -04:00
Jasper St. Pierre 5f980cd8de gtkwindow: Use gdk_cursor_new_for_display
Otherwise, this crashes the inspector, since it now uses multi-display
technology, and on Wayland, resources like the cursor are client-private.
2014-10-27 21:22:44 -07:00
Jasper St. Pierre 52e3b88382 gdkwindow: Specify some invariants for cursors
Cursors should not be on a different display than their window /
device, as that would break Wayland.
2014-10-27 21:22:31 -07:00
Matthias Clasen 168a49426e Update for 3.15.1 2014-10-27 20:03:51 -04:00
Matthias Clasen 60a11333af Update expected results of a11y tests
The new has-tooltip state is showing up in a number of places,
as expected.
2014-10-27 20:03:51 -04:00
Jasper St. Pierre 0f79cb3d11 x11: Scale the frame extents as well 2014-10-27 16:54:33 -07:00
Matthias Clasen a680631345 gtk3-demo: Add a frame to the sidebar
With overlay scrollbars, there's no visible separation between
the sidebar and the content otherwise.
2014-10-27 17:15:31 -04:00
Alexander Larsson f7b1ba0943 opengl: Use GL_TEXTURE_2D rather than GL_TEXTURE_RECTANGLE_ARB when possible
This is more standard, and most driver support non-power-of-2 TEXTURE_2D
these days. We fall back for ancient drivers.
2014-10-27 21:17:08 +01:00
Alexander Larsson 08d44648ea opengl: Use proper blend function for premultiplied alpha 2014-10-27 21:17:08 +01:00
Alexander Larsson 72a6459d73 gdkglcontext: Track whether to use GL_TEXTURE_2D or GL_TEXTURE_RECTANGL_ARB 2014-10-27 21:17:08 +01:00
Jasper St. Pierre 5f40f58c36 cairoblur: Fix the blur again once more
The differences between the mutter and GTK+ code are subtle, but it
turns out that _gtk_cairo_blur_compute_pixels actually returns the
shadow *spread*. Since we use a triple box blur, the constant was
multiplied by 1.5 to approximate three chained box blurs. Split this
out and use the correct value for the lobe width.
2014-10-27 10:20:43 -07:00
Jasper St. Pierre ac9ac55555 cairoblur: Fix the blur code
We weren't passing in the right "d" value, which was causing the blur to
behave incorrectly, especially in the case of 1px blurs, which would
cause no blurs at all.

The blur should now match the web.
2014-10-27 10:10:32 -07:00
Alexander Larsson 3013997e23 Rename gdk_gl_context_flush_buffer to gdk_gl_context_end_frame
This makes a lot more sense.
2014-10-27 16:33:37 +01:00
Matthias Clasen f1fe70e4ad Indentation fix 2014-10-27 07:19:50 -04:00
Sebastien Lafargue 17f9eed14e popover menus: Take iconic into account
We don't want separators in both side of an iconic section
and use a 10px margin to separate two iconic sections.

Separators are also updated in case of dynamic insertion
( often used with menu items for plugins )

https://bugzilla.gnome.org/show_bug.cgi?id=738650
2014-10-27 07:08:37 -04:00
Matthias Clasen fc6f22c3ce Ignore gdk-pixbuf deprecations 2014-10-27 07:05:22 -04:00
Cosimo Cecchi 96a3b23736 testlevelbar: fix CSS to be aligned with documentation
https://bugzilla.gnome.org/show_bug.cgi?id=707695
2014-10-27 06:56:19 -04:00
Cosimo Cecchi 631e2f4c9b levelbar: don't use the current value style class for empty blocks
We want to be able to style the empty blocks independently of all the
offset styles, so remove the current style class when painting an empty
block.

https://bugzilla.gnome.org/show_bug.cgi?id=707695
2014-10-27 06:56:19 -04:00
Cosimo Cecchi 0555ef20a4 testlevelbar: don't segfault when quitting testlevelbar
Quit the mainloop when the window is closed.

https://bugzilla.gnome.org/show_bug.cgi?id=707695
2014-10-27 06:56:19 -04:00
Matthias Clasen 3a2bf9d878 quartz: Move the FullscreenSavedGeometry definition earlier
Move the FullscreenSavedGeometry before the first (conditional)
use, to fix the build on OS X 10.6.

https://bugzilla.gnome.org/show_bug.cgi?id=737561
2014-10-27 06:49:46 -04:00
Marcus Karlsson a703437796 quartz: fix build on 10.6 and below
It is not possible to successfully build GTK+ on OS X 10.6 and below
since NSFullScreenWindowMask is only available starting with 10.7. Add
ifdef guards around setStyleMask: in order to allow it to build on
earlier OS X releases.

https://bugzilla.gnome.org/show_bug.cgi?id=737561
2014-10-27 06:46:12 -04:00
Christophe Fergeau 506d59f526 Return correct font from gtk_font_chooser_widget_find_font
Commit 30a1c4ab fixed several memleaks including one in
gtk_font_chooser_widget_find_font.

However, the fix causes one extra call to gtk_tree_model_iter_next()
after finding the font we look for (ie pango_font_description_equal
returns TRUE): the 'increment' part of the for loop
(gtk_tree_model_iter_next) is run before the 'exit condition' of the for
loop is evaluated.

This commit reverts this part of commit 30a1c4ab and adds an extra
call to pango_font_description_free in order to fix the leak.

https://bugzilla.gnome.org/show_bug.cgi?id=739111
2014-10-26 21:53:33 -04:00
Christophe Fergeau 77487fef2f fontchooserwidget: Don't invalidate priv->font_iter in load_fonts
When using GtkFontChooserButton, the same GtkFontChooserWidget can be
hidden and shown multiple times. When doing that, the font that was
chosen the previous time should be the selected one in the
GtkFontChooserWidget, however this does not work as expected and a
somehow 'random' font gets selected (or none) instead.

Every time the font chooser widget is shown, its style will be updated,
causing gtk_font_chooser_widget_style_updated and then
gtk_font_chooser_widget_load_fonts to be called.

gtk_font_chooser_widget_load_fonts starts by clearing the GtkListStore
listing the available fonts, repopulates it, and then makes sure the
current font is selected.

However, this does not work as expected, as during the call to
gtk_list_store_clear, the cursor_changed_cb will be invoked multiple
times when the GtkTreeView cursor gets moved when the line where the
cursor currently is gets removed. This will cause the 'current font'
state (priv->font_desc) to be unexpectedly modified, and when
gtk_font_chooser_widget_load_fonts tries to reposition the cursor to the
'current font', we won't get the expect result.

This commit avoids that by making sure cursor_changed_cb does not get
called when we call gtk_list_store_clear in
gtk_font_chooser_widget_load_fonts.

https://bugzilla.gnome.org/show_bug.cgi?id=739111
2014-10-26 21:53:33 -04:00
Matthias Clasen e75310a445 Fix an out-of-bounds access in MyEnhancedXkbTranslateKeyCode
Commits 314b6abbe8 and eb9223c008 were ignoring
the fact that the code where found is set to 1 was modifying
col - which was an ok thing to do when that part of the code
was still breaking out of the loop, but it is no longer doing
that (since 2003 !). Fix things up by storing the final col
value in a separate variable and using that after the loop.

https://bugzilla.gnome.org/show_bug.cgi?id=738886
2014-10-26 21:48:59 -04:00
205 changed files with 27358 additions and 12332 deletions
+32
View File
@@ -1,3 +1,35 @@
Overview of Changes in GTK+ 3.15.1
==================================
* An experimental mir backend has been added.
Use --enable-mir-backend to build it.
* Inspector:
- Show more information
- Use a separate display connection
* Deprecations:
- GtkStyleProperties
* Bugs fixed:
707695 GtkLevelBar Colour CSS
737561 quartz: gtk+ 3.14.0 fails to build on 10.6.8, 'NSFullScreen...
738650 fix separator with iconic section and more
738886 Out of bounds access in MyEnhancedXkbTranslateKeyCode
738955 Client-side decoration window menus appear at wrong positio...
738982 Add support for ATK_STATE_HAS_TOOLTIP
739001 Fix Build of broadwayd on Visual Studio
739005 gtkstatusicon.c won't build with both X11 and Quartz backen...
739111 GtkFontChooserDialog fixes
739150 Dragging bookmark crashes nautilus
Translation updates:
Czech
Hungarian
Serbian
Spanish
Overview of Changes in GTK+ 3.15.0
==================================
+2 -2
View File
@@ -33,7 +33,7 @@ echo $(Configuration) > ..\..\..\MSVC_$(Configuration)
:DONE_GDKCONFIG_H
</GenGdkConfigHWin32>
<GenGdkConfigHBroadway>
if exist ..\..\..\MSVC_$(Configuration) goto DONE_GDKCONFIG_H
if exist ..\..\..\MSVC_$(Configuration)_Broadway goto DONE_GDKCONFIG_H
if exist ..\..\..\gdk\gdkconfig.h del ..\..\..\gdk\gdkconfig.h
@@ -53,7 +53,7 @@ copy ..\..\..\gdk\gdkconfig.h.win32_broadway ..\..\..\gdk\gdkconfig.h
copy ..\..\..\gdk\gdkconfig.h.win32_broadway ..\..\..\GDK_BROADWAY_BUILD
echo $(Configuration) &gt; ..\..\..\MSVC_$(Configuration)
echo $(Configuration) &gt; ..\..\..\MSVC_$(Configuration)_Broadway
:DONE_GDKCONFIG_H
</GenGdkConfigHBroadway>
+2 -2
View File
@@ -36,7 +36,7 @@ echo $(ConfigurationName) &gt; ..\..\..\MSVC_$(ConfigurationName)&#x0D;&#x0A;
<UserMacro
Name="GenGdkConfigHBroadway"
Value="
if exist ..\..\..\MSVC_$(ConfigurationName) goto DONE_GDKCONFIG_H&#x0D;&#x0A;
if exist ..\..\..\MSVC_$(ConfigurationName)_Broadway goto DONE_GDKCONFIG_H&#x0D;&#x0A;
if exist ..\..\..\gdk\gdkconfig.h del ..\..\..\gdk\gdkconfig.h&#x0D;&#x0A;
if exist ..\..\..\GDK_WIN32ONLY_BUILD del ..\..\..\GDK_WIN32ONLY_BUILD&#x0D;&#x0A;
@@ -50,7 +50,7 @@ if &quot;$(ConfigurationName)&quot; == &quot;Debug_Broadway&quot; del ..\..\..\M
copy ..\..\..\gdk\gdkconfig.h.win32_broadway ..\..\..\gdk\gdkconfig.h&#x0D;&#x0A;
copy ..\..\..\gdk\gdkconfig.h.win32_broadway ..\..\..\GDK_BROADWAY_BUILD&#x0D;&#x0A;
echo $(ConfigurationName) &gt; ..\..\..\MSVC_$(ConfigurationName)&#x0D;&#x0A;
echo $(ConfigurationName) &gt; ..\..\..\MSVC_$(ConfigurationName)_Broadway&#x0D;&#x0A;
:DONE_GDKCONFIG_H&#x0D;&#x0A;
"
/>
-3
View File
@@ -23,9 +23,6 @@
/* Define to 1 if you have the `bind_textdomain_codeset' function. */
#define HAVE_BIND_TEXTDOMAIN_CODESET 1
/* Define to 1 if you have the `cairo_surface_set_device_scale' function. */
/* #undef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE */
/* define if we have colord */
/* #undef HAVE_COLORD */
+21 -15
View File
@@ -10,7 +10,7 @@
m4_define([gtk_major_version], [3])
m4_define([gtk_minor_version], [15])
m4_define([gtk_micro_version], [0])
m4_define([gtk_micro_version], [1])
m4_define([gtk_interface_age], [0])
m4_define([gtk_binary_age],
[m4_eval(100 * gtk_minor_version + gtk_micro_version)])
@@ -43,11 +43,12 @@ m4_define([gtk_binary_version], [3.0.0])
# required versions of other packages
m4_define([glib_required_version], [2.43.0])
m4_define([pango_required_version], [1.36.7])
m4_define([atk_required_version], [2.12.0])
m4_define([cairo_required_version], [1.12.0])
m4_define([atk_required_version], [2.15.1])
m4_define([cairo_required_version], [1.14.0])
m4_define([gdk_pixbuf_required_version], [2.30.0])
m4_define([introspection_required_version], [1.39.0])
m4_define([wayland_required_version], [1.5.91])
m4_define([mirclient_required_version], [0.9.0])
m4_define([epoxy_required_version], [1.0])
GLIB_REQUIRED_VERSION=glib_required_version
PANGO_REQUIRED_VERSION=pango_required_version
@@ -309,6 +310,10 @@ AC_ARG_ENABLE(xdamage,
[AS_HELP_STRING([--enable-xdamage],
[support X Damage extension [default=maybe]])],,
[enable_xdamage="maybe"])
AC_ARG_ENABLE(xpresent,
[AS_HELP_STRING([--enable-xpresent],
[support X Present extension [default=maybe]])],,
[enable_xpresent="maybe"])
AC_ARG_ENABLE(x11-backend,
[AS_HELP_STRING([--enable-x11-backend],
@@ -464,7 +469,7 @@ else
AM_CONDITIONAL(USE_WAYLAND, false)
fi
MIR_DEPENDENCIES="mirclient"
MIR_DEPENDENCIES="mirclient >= mirclient_required_version"
if test "$enable_mir_backend" = "maybe" ; then
PKG_CHECK_EXISTS($MIR_DEPENDENCIES, [have_mir_deps=yes], [have_mir_deps=no])
AC_MSG_CHECKING([for MIR_DEPENDENCIES])
@@ -1285,6 +1290,18 @@ if test "x$enable_x11_backend" = xyes; then
fi
fi
if test x"$enable_xpresent" != xno; then
if $PKG_CONFIG --exists xcb-present ; then
AC_DEFINE(HAVE_PRESENT, 1, [Have the Present X extension])
X_PACKAGES="$X_PACKAGES xcb-present"
X_EXTENSIONS="$X_EXTENSIONS Present"
GTK_PACKAGES_FOR_X="$GTK_PACKAGES_FOR_X xcb-present"
elif test x"$enable_xpresent" = xyes; then
AC_MSG_ERROR([Present support requested but xcb-present not found])
fi
fi
if $have_base_x_pc ; then
GDK_EXTRA_LIBS="$x_extra_libs"
else
@@ -1342,17 +1359,6 @@ else
LIBS="$gtk_save_LIBS"
fi
# Check for cairo_set_device_scale, as we don't want to depend hard on
# this until there is a stable release with it
CAIRO_CFLAGS=`$PKG_CONFIG --cflags cairo`
CAIRO_LIBS=`$PKG_CONFIG --libs cairo`
CFLAGS="$CFLAGS $CAIRO_CFLAGS"
gtk_save_LIBS="$LIBS"
LIBS="$CAIRO_LIBS $LIBS"
AC_CHECK_FUNCS(cairo_surface_set_device_scale)
LIBS="$gtk_save_LIBS"
CFLAGS="$saved_cflags"
LDFLAGS="$saved_ldflags"
+2 -2
View File
@@ -239,8 +239,8 @@ do_hypertext (GtkWidget *do_widget)
GtkWidget *sw;
GtkTextBuffer *buffer;
hand_cursor = gdk_cursor_new (GDK_HAND2);
regular_cursor = gdk_cursor_new (GDK_XTERM);
hand_cursor = gdk_cursor_new_for_display (gtk_widget_get_display (do_widget), GDK_HAND2);
regular_cursor = gdk_cursor_new_for_display (gtk_widget_get_display (do_widget), GDK_XTERM);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_screen (GTK_WINDOW (window),
+42 -5
View File
@@ -772,19 +772,53 @@ load_file (const gchar *demoname,
case 3:
/* Reading program body */
gtk_text_buffer_insert (source_buffer, &start, p, -1);
gtk_text_buffer_insert (source_buffer, &start, "\n", 1);
if (lines[i+1] != NULL)
gtk_text_buffer_insert (source_buffer, &start, "\n", 1);
break;
}
}
g_strfreev (lines);
fontify (source_buffer);
g_strfreev (lines);
gtk_text_buffer_create_tag (source_buffer, "top-margin",
"pixels-above-lines", 20,
NULL);
gtk_text_buffer_get_start_iter (source_buffer, &start);
end = start;
gtk_text_iter_forward_word_end (&end);
gtk_text_buffer_apply_tag_by_name (source_buffer, "top-margin", &start, &end);
gtk_text_buffer_create_tag (source_buffer, "bottom-margin",
"pixels-below-lines", 20,
NULL);
gtk_text_buffer_get_end_iter (source_buffer, &end);
start = end;
gtk_text_iter_backward_word_start (&start);
gtk_text_buffer_apply_tag_by_name (source_buffer, "bottom-margin", &start, &end);
gtk_text_view_set_buffer (GTK_TEXT_VIEW (source_view), source_buffer);
g_object_unref (source_buffer);
gtk_text_buffer_create_tag (info_buffer, "top-margin",
"pixels-above-lines", 20,
NULL);
gtk_text_buffer_get_start_iter (info_buffer, &start);
end = start;
gtk_text_iter_forward_word_end (&end);
gtk_text_buffer_apply_tag_by_name (info_buffer, "top-margin", &start, &end);
gtk_text_buffer_create_tag (info_buffer, "bottom-margin",
"pixels-below-lines", 20,
NULL);
gtk_text_buffer_get_end_iter (info_buffer, &end);
start = end;
gtk_text_iter_backward_word_start (&start);
gtk_text_buffer_apply_tag_by_name (info_buffer, "bottom-margin", &start, &end);
gtk_text_view_set_buffer (GTK_TEXT_VIEW (info_view), info_buffer);
g_object_unref (info_buffer);
gtk_text_view_set_buffer (GTK_TEXT_VIEW (source_view), source_buffer);
g_object_unref (source_buffer);
}
static void
@@ -830,7 +864,10 @@ create_text (GtkWidget **view,
GTK_SHADOW_NONE);
*view = text_view = gtk_text_view_new ();
g_object_set (text_view, "margin", 20, NULL);
g_object_set (text_view,
"left-margin", 20,
"right-margin", 20,
NULL);
gtk_text_view_set_editable (GTK_TEXT_VIEW (text_view), FALSE);
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (text_view), FALSE);
+33 -32
View File
@@ -70,36 +70,41 @@
<property name="can_focus">False</property>
<property name="border_width">0</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow">
<property name="width_request">120</property>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">none</property>
<property name="min_content_width">150</property>
<style>
<class name="sidebar"/>
</style>
<child>
<object class="GtkTreeView" id="treeview">
<object class="GtkScrolledWindow" id="scrolledwindow">
<property name="width_request">120</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">treestore</property>
<property name="headers_visible">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection">
<property name="mode">browse</property>
</object>
</child>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">none</property>
<property name="min_content_width">150</property>
<style>
<class name="sidebar"/>
</style>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<property name="title" translatable="yes">column</property>
<object class="GtkTreeView" id="treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">treestore</property>
<property name="headers_visible">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection">
<property name="mode">browse</property>
</object>
</child>
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<attributes>
<attribute name="style">4</attribute>
<attribute name="text">1</attribute>
</attributes>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<property name="title" translatable="yes">column</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<attributes>
<attribute name="style">4</attribute>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
@@ -128,10 +133,8 @@
<object class="GtkTextView" id="info-textview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_start">20</property>
<property name="margin_end">20</property>
<property name="margin_top">20</property>
<property name="margin_bottom">20</property>
<property name="left-margin">20</property>
<property name="right-margin">20</property>
<property name="pixels_above_lines">2</property>
<property name="pixels_below_lines">2</property>
<property name="editable">False</property>
@@ -165,10 +168,8 @@
<object class="GtkTextView" id="source-textview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_start">20</property>
<property name="margin_end">20</property>
<property name="margin_top">20</property>
<property name="margin_bottom">20</property>
<property name="left-margin">20</property>
<property name="right-margin">20</property>
<property name="editable">False</property>
<property name="cursor_visible">False</property>
</object>
+35 -14
View File
@@ -1,3 +1,4 @@
#include <string.h>
#include "iconbrowserapp.h"
#include "iconbrowserwin.h"
#include <gtk/gtk.h>
@@ -51,7 +52,7 @@ enum {
G_DEFINE_TYPE(IconBrowserWindow, icon_browser_window, GTK_TYPE_APPLICATION_WINDOW);
static void
search_text_changed (GtkEntry *entry)
search_text_changed (GtkEntry *entry, IconBrowserWindow *win)
{
const gchar *text;
@@ -59,6 +60,8 @@ search_text_changed (GtkEntry *entry)
if (text[0] == '\0')
return;
gtk_tree_model_filter_refilter (win->filter_model);
}
static void
@@ -191,6 +194,8 @@ selected_context_changed (GtkListBox *list, IconBrowserWindow *win)
if (row == NULL)
return;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (win->search), FALSE);
label = gtk_bin_get_child (GTK_BIN (row));
win->current_context = g_object_get_data (G_OBJECT (label), "context");
gtk_tree_model_filter_refilter (win->filter_model);
@@ -671,11 +676,13 @@ populate (IconBrowserWindow *win)
}
static gboolean
key_press_event_cb (GtkWidget *widget,
GdkEvent *event,
GtkSearchBar *bar)
key_press_event_cb (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
return gtk_search_bar_handle_event (bar, event);
IconBrowserWindow *win = data;
return gtk_search_bar_handle_event (GTK_SEARCH_BAR (win->searchbar), event);
}
static gboolean
@@ -687,8 +694,13 @@ icon_visible_func (GtkTreeModel *model,
gchar *context;
gchar *name;
gint column;
gboolean search;
const gchar *search_text;
gboolean visible;
search = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (win->search));
search_text = gtk_entry_get_text (GTK_ENTRY (win->searchentry));
if (win->symbolic)
column = SYMBOLIC_NAME_COLUMN;
else
@@ -698,8 +710,12 @@ icon_visible_func (GtkTreeModel *model,
column, &name,
CONTEXT_COLUMN, &context,
-1);
visible = name != NULL && win->current_context != NULL && g_strcmp0 (context, win->current_context->id) == 0;
if (!name)
visible = FALSE;
else if (search)
visible = strstr (name, search_text) != NULL;
else
visible = win->current_context != NULL && g_strcmp0 (context, win->current_context->id) == 0;
g_free (name);
g_free (context);
@@ -726,6 +742,13 @@ symbolic_toggled (GtkToggleButton *toggle, IconBrowserWindow *win)
gtk_widget_queue_draw (win->list);
}
static void
search_mode_toggled (GObject *searchbar, GParamSpec *pspec, IconBrowserWindow *win)
{
if (gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (searchbar)))
gtk_list_box_unselect_all (GTK_LIST_BOX (win->context_list));
}
static void
icon_browser_window_init (IconBrowserWindow *win)
{
@@ -733,16 +756,13 @@ icon_browser_window_init (IconBrowserWindow *win)
win->contexts = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
g_object_bind_property (win->search, "active",
win->searchbar, "search-mode-enabled",
G_BINDING_BIDIRECTIONAL);
// gtk_tree_view_set_search_entry (GTK_TREE_VIEW (win->list), GTK_ENTRY (win->searchentry));
g_signal_connect (win, "key-press-event", G_CALLBACK (key_press_event_cb), win->searchbar);
gtk_tree_model_filter_set_visible_func (win->filter_model, icon_visible_func, win, NULL);
gtk_window_set_transient_for (GTK_WINDOW (win->details), GTK_WINDOW (win));
g_signal_connect (win->searchbar, "notify::search-mode-enabled",
G_CALLBACK (search_mode_toggled), win);
symbolic_toggled (GTK_TOGGLE_BUTTON (win->symbolic_radio), win);
populate (win);
@@ -778,6 +798,7 @@ icon_browser_window_class_init (IconBrowserWindowClass *class)
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), item_activated);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), selected_context_changed);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), symbolic_toggled);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), key_press_event_cb);
}
IconBrowserWindow *
+4 -2
View File
@@ -16,6 +16,7 @@
<property name="title" translatable="yes">Icon Browser</property>
<property name="default-width">600</property>
<property name="default-height">800</property>
<signal name="key-press-event" handler="key_press_event_cb"/>
<child type="titlebar">
<object class="GtkHeaderBar" id="header">
<property name="visible">True</property>
@@ -47,7 +48,7 @@
</child>
<child>
<object class="GtkToggleButton" id="search">
<property name="visible">False</property>
<property name="visible">True</property>
<style>
<class name="image-button"/>
</style>
@@ -83,10 +84,11 @@
<child>
<object class="GtkSearchBar" id="searchbar">
<property name="visible">True</property>
<property name="search-mode-enabled" bind-source="search" bind-property="active" bind-flags="bidirectional"/>
<child>
<object class="GtkSearchEntry" id="searchentry">
<signal name="search-changed" handler="search_text_changed"/>
<property name="visible">True</property>
<signal name="search-changed" handler="search_text_changed"/>
</object>
</child>
</object>
+19 -1
View File
@@ -761,7 +761,7 @@ background_loaded_cb (GObject *source,
pixbuf = gdk_pixbuf_new_from_stream_finish (res, &error);
if (error)
{
g_warning ("%s", error->message);
g_warning ("Error loading '%s': %s", bd->filename, error->message);
g_error_free (error);
return;
}
@@ -1073,6 +1073,19 @@ textbuffer_notify_selection (GObject *object, GParamSpec *pspec, GtkWidget *butt
gtk_widget_set_sensitive (button, has_selection);
}
static gboolean
osd_frame_button_press (GtkWidget *frame, GdkEventButton *event, gpointer data)
{
GtkWidget *osd;
gboolean visible;
osd = g_object_get_data (G_OBJECT (frame), "osd");
visible = gtk_widget_get_visible (osd);
gtk_widget_set_visible (osd, !visible);
return GDK_EVENT_STOP;
}
static void
activate (GApplication *app)
{
@@ -1119,6 +1132,7 @@ activate (GApplication *app)
gtk_builder_add_callback_symbol (builder, "on_page_combo_changed", (GCallback)on_page_combo_changed);
gtk_builder_add_callback_symbol (builder, "on_range_from_changed", (GCallback)on_range_from_changed);
gtk_builder_add_callback_symbol (builder, "on_range_to_changed", (GCallback)on_range_to_changed);
gtk_builder_add_callback_symbol (builder, "osd_frame_button_press", (GCallback)osd_frame_button_press);
gtk_builder_connect_signals (builder, NULL);
@@ -1266,6 +1280,10 @@ activate (GApplication *app)
g_signal_connect (gtk_widget_get_clipboard (widget2, GDK_SELECTION_CLIPBOARD), "owner-change",
G_CALLBACK (clipboard_owner_change), widget);
widget = (GtkWidget *)gtk_builder_get_object (builder, "osd_frame");
widget2 = (GtkWidget *)gtk_builder_get_object (builder, "totem_like_osd");
g_object_set_data (G_OBJECT (widget), "osd", widget2);
gtk_widget_show_all (GTK_WIDGET (window));
g_object_unref (builder);
+139 -37
View File
@@ -82,6 +82,7 @@
</menu>
<object class="GtkAdjustment" id="adjustment1">
<property name="upper">100</property>
<property name="lower">1</property>
<property name="value">50</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
@@ -168,7 +169,7 @@ Morbi massa libero, congue vitae scelerisque vel, ultricies vel nisl.
Vestibulum in tortor diam, quis aliquet quam. Praesent ut justo neque, tempus rutrum est.
Duis eu lectus quam. Vivamus eget metus a mauris molestie venenatis pulvinar eleifend nisi.
Nulla facilisi. Pellentesque at dolor sit amet purus dapibus pulvinar molestie quis neque.
Suspendisse feugiat quam quis dolor accumsan cursus. </property>
Suspendisse feugiat quam quis dolor accumsan cursus.</property>
</object>
<object class="GtkTextBuffer" id="textbuffer2">
<property name="text">* Translation updates:
@@ -1601,6 +1602,8 @@ Suspendisse feugiat quam quis dolor accumsan cursus. </property>
<property name="can_focus">True</property>
<property name="buffer">textbuffer1</property>
<property name="wrap_mode">2</property>
<property name="left_margin">10</property>
<property name="right_margin">10</property>
</object>
</child>
</object>
@@ -2136,6 +2139,8 @@ microphone-sensitivity-medium-symbolic</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="buffer">textbuffer2</property>
<property name="left_margin">10</property>
<property name="right_margin">10</property>
</object>
</child>
</object>
@@ -2898,6 +2903,8 @@ microphone-sensitivity-medium-symbolic</property>
<property name="can_focus">True</property>
<property name="buffer">textbuffer1</property>
<property name="wrap_mode">2</property>
<property name="left_margin">10</property>
<property name="right_margin">10</property>
</object>
</child>
</object>
@@ -3019,6 +3026,7 @@ microphone-sensitivity-medium-symbolic</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="expand">False</property>
<property name="expanded">True</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow3">
<property name="visible">True</property>
@@ -3711,60 +3719,154 @@ microphone-sensitivity-medium-symbolic</property>
</object>
</child>
<child>
<object class="GtkFrame">
<object class="GtkOverlay">
<property name="visible">True</property>
<child>
<object class="GtkPaned">
<property name="visible">True</property>
<property name="orientation">horizontal</property>
<property name="wide-handle">True</property>
<child type="overlay">
<object class="GtkToolbar" id="totem_like_osd">
<property name="no-show-all">True</property>
<property name="opacity">0.9</property>
<property name="margin">20</property>
<property name="halign">fill</property>
<property name="valign">end</property>
<style>
<class name="osd"/>
</style>
<child>
<object class="GtkNotebook">
<object class="GtkToolItem">
<property name="visible">True</property>
<property name="show-border">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="height-request">120</property>
<property name="orientation">horizontal</property>
<style>
<class name="linked"/>
</style>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<style>
<class name="image-button"/>
</style>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="icon-name">pan-start-symbolic</property>
<property name="icon-size">1</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<style>
<class name="image-button"/>
</style>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="icon-name">pan-end-symbolic</property>
<property name="icon-size">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Page 1</property>
</object>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="height-request">120</property>
</object>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Page 2</property>
</object>
</child>
</object>
</object>
</child>
<child>
<object class="GtkNotebook">
<object class="GtkToolItem">
<property name="visible">True</property>
<property name="show-border">False</property>
<child>
<object class="GtkBox">
<object class="GtkScale">
<property name="visible">True</property>
<property name="height-request">120</property>
<property name="draw-value">False</property>
<property name="orientation">horizontal</property>
<property name="adjustment">adjustment1</property>
</object>
</child>
<child type="tab">
<object class="GtkLabel">
</object>
<packing>
<property name="expand">True</property>
</packing>
</child>
<child>
<object class="GtkToolItem">
<property name="visible">True</property>
<child>
<object class="GtkVolumeButton">
<property name="visible">True</property>
<property name="label" translatable="yes">Page 3</property>
<property name="orientation">vertical</property>
<property name="use-symbolic">True</property>
<property name="value">.5</property>
<style>
<class name="image-button"/>
</style>
</object>
</child>
</object>
</object>
</child>
</object>
</child>
<child>
<object class="GtkFrame" id="osd_frame">
<property name="visible">True</property>
<signal name="button-press-event" handler="osd_frame_button_press"/>
<child>
<object class="GtkPaned">
<property name="visible">True</property>
<property name="orientation">horizontal</property>
<property name="wide-handle">True</property>
<child>
<object class="GtkNotebook">
<property name="visible">True</property>
<property name="show-border">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="height-request">120</property>
</object>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Page 1</property>
</object>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="vexpand">True</property>
</object>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Page 2</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkNotebook">
<property name="visible">True</property>
<property name="show-border">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="vexpand">True</property>
</object>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Page 3</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
-1
View File
@@ -1286,7 +1286,6 @@ gdk_frame_get_type
<SECTION>
<FILE>gdkglcontext</FILE>
GdkGLContext
gdk_gl_context_get_visual
gdk_gl_context_get_window
gdk_gl_context_make_current
gdk_gl_context_clear_current
+2
View File
@@ -114,6 +114,7 @@
<xi:include href="xml/gtkscalebutton.xml" />
<xi:include href="xml/gtkvolumebutton.xml" />
<xi:include href="xml/gtklockbutton.xml" />
<xi:include href="xml/gtkmodelbutton.xml" />
</chapter>
<chapter id="NumericEntry">
@@ -191,6 +192,7 @@
<xi:include href="xml/gtktoggletoolbutton.xml" />
<xi:include href="xml/gtkradiotoolbutton.xml" />
<xi:include href="xml/gtkpopover.xml" />
<xi:include href="xml/gtkpopovermenu.xml" />
</chapter>
<chapter id="SelectorWidgets">
+17
View File
@@ -6046,6 +6046,7 @@ GTK_STYLE_CLASS_SIDEBAR
GTK_STYLE_CLASS_SLIDER
GTK_STYLE_CLASS_SPINBUTTON
GTK_STYLE_CLASS_SPINNER
GTK_STYLE_CLASS_STATUSBAR
GTK_STYLE_CLASS_SUBTITLE
GTK_STYLE_CLASS_SUGGESTED_ACTION
GTK_STYLE_CLASS_TITLE
@@ -7955,6 +7956,22 @@ gtk_popover_set_modal
gtk_popover_get_modal
</SECTION>
<SECTION>
<FILE>gtkpopovermenu</FILE>
<TITLE>GtkPopoverMenu</TITLE>
GtkPopoverMenu
gtk_popover_menu_new
gtk_popover_menu_open_submenu
</SECTION>
<SECTION>
<FILE>gtkmodelbutton</FILE>
<TITLE>GtkModelButton</TITLE>
GtkModelButton
GtkButtonRole
gtk_model_button_new
</SECTION>
<SECTION>
<FILE>gtkeventcontroller</FILE>
<TITLE>GtkEventController</TITLE>
+2
View File
@@ -126,6 +126,7 @@ gtk_menu_shell_get_type
gtk_menu_tool_button_get_type
gtk_message_dialog_get_type
gtk_misc_get_type
gtk_model_button_get_type
gtk_mount_operation_get_type
gtk_notebook_get_type
gtk_numerable_icon_get_type
@@ -139,6 +140,7 @@ gtk_paper_size_get_type
gtk_places_sidebar_get_type
@ENABLE_ON_X11@gtk_plug_get_type
gtk_popover_get_type
gtk_popover_menu_get_type
@DISABLE_ON_W32@gtk_printer_get_type
gtk_print_context_get_type
@DISABLE_ON_W32@gtk_print_job_get_type
+2
View File
@@ -99,6 +99,7 @@ gdk_h_sources = \
$(deprecated_h_sources)
gdk_private_headers = \
gdk-private.h \
gdkapplaunchcontextprivate.h \
gdkcursorprivate.h \
gdkdevicemanagerprivate.h \
@@ -121,6 +122,7 @@ deprecated_c_sources = \
gdk_c_sources = \
$(deprecated_c_sources) \
gdk-private.c \
gdk.c \
gdkapplaunchcontext.c \
gdkcairo.c \
-15
View File
@@ -330,19 +330,6 @@ gdk_broadway_display_get_next_serial (GdkDisplay *display)
return _gdk_broadway_server_get_next_serial (broadway_display->server);
}
static void
gdk_broadway_display_event_data_copy (GdkDisplay *display,
const GdkEvent *src,
GdkEvent *dst)
{
}
static void
gdk_broadway_display_event_data_free (GdkDisplay *display,
GdkEvent *event)
{
}
void
gdk_broadway_display_show_keyboard (GdkBroadwayDisplay *display)
{
@@ -398,8 +385,6 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
display_class->after_process_all_updates = _gdk_broadway_display_after_process_all_updates;
display_class->get_next_serial = gdk_broadway_display_get_next_serial;
display_class->notify_startup_complete = gdk_broadway_display_notify_startup_complete;
display_class->event_data_copy = gdk_broadway_display_event_data_copy;
display_class->event_data_free = gdk_broadway_display_event_data_free;
display_class->create_window_impl = _gdk_broadway_display_create_window_impl;
display_class->get_keymap = _gdk_broadway_display_get_keymap;
display_class->get_selection_owner = _gdk_broadway_display_get_selection_owner;
+23
View File
@@ -0,0 +1,23 @@
#include "config.h"
#include "gdk-private.h"
GdkPrivateVTable *
gdk__private__ (void)
{
static GdkPrivateVTable table = {
gdk_device_grab_info,
gdk_display_open_default,
gdk_add_option_entries,
gdk_pre_parse,
gdk_gl_get_flags,
gdk_gl_set_flags,
gdk_window_freeze_toplevel_updates,
gdk_window_thaw_toplevel_updates,
gdk_display_get_rendering_mode,
gdk_display_set_rendering_mode,
gdk_display_get_debug_updates,
gdk_display_set_debug_updates
};
return &table;
}
+64
View File
@@ -0,0 +1,64 @@
#ifndef __GDK__PRIVATE_H__
#define __GDK__PRIVATE_H__
#include <gdk/gdk.h>
#include "gdk/gdkinternals.h"
#define GDK_PRIVATE_CALL(symbol) (gdk__private__ ()->symbol)
GdkDisplay * gdk_display_open_default (void);
gboolean gdk_device_grab_info (GdkDisplay *display,
GdkDevice *device,
GdkWindow **grab_window,
gboolean *owner_events);
void gdk_add_option_entries (GOptionGroup *group);
void gdk_pre_parse (void);
GdkGLFlags gdk_gl_get_flags (void);
void gdk_gl_set_flags (GdkGLFlags flags);
void gdk_window_freeze_toplevel_updates (GdkWindow *window);
void gdk_window_thaw_toplevel_updates (GdkWindow *window);
GdkRenderingMode gdk_display_get_rendering_mode (GdkDisplay *display);
void gdk_display_set_rendering_mode (GdkDisplay *display,
GdkRenderingMode mode);
gboolean gdk_display_get_debug_updates (GdkDisplay *display);
void gdk_display_set_debug_updates (GdkDisplay *display,
gboolean debug_updates);
typedef struct {
/* add all private functions here, initialize them in gdk-private.c */
gboolean (* gdk_device_grab_info) (GdkDisplay *display,
GdkDevice *device,
GdkWindow **grab_window,
gboolean *owner_events);
GdkDisplay *(* gdk_display_open_default) (void);
void (* gdk_add_option_entries) (GOptionGroup *group);
void (* gdk_pre_parse) (void);
GdkGLFlags (* gdk_gl_get_flags) (void);
void (* gdk_gl_set_flags) (GdkGLFlags flags);
void (* gdk_window_freeze_toplevel_updates) (GdkWindow *window);
void (* gdk_window_thaw_toplevel_updates) (GdkWindow *window);
GdkRenderingMode (* gdk_display_get_rendering_mode) (GdkDisplay *display);
void (* gdk_display_set_rendering_mode) (GdkDisplay *display,
GdkRenderingMode mode);
gboolean (* gdk_display_get_debug_updates) (GdkDisplay *display);
void (* gdk_display_set_debug_updates) (GdkDisplay *display,
gboolean debug_updates);
} GdkPrivateVTable;
GDK_AVAILABLE_IN_ALL
GdkPrivateVTable * gdk__private__ (void);
#endif /* __GDK__PRIVATE_H__ */
+70 -9
View File
@@ -30,6 +30,8 @@
#include "gdkinternals.h"
#include "gdkintl.h"
#include "gdk-private.h"
#ifndef HAVE_XCONVERTCASE
#include "gdkkeysyms.h"
#endif
@@ -134,6 +136,15 @@ static GMutex gdk_threads_mutex;
static GCallback gdk_threads_lock = NULL;
static GCallback gdk_threads_unlock = NULL;
static const GDebugKey gdk_gl_keys[] = {
{"disable", GDK_GL_DISABLE},
{"always", GDK_GL_ALWAYS},
{"software-draw", GDK_GL_SOFTWARE_DRAW_GL | GDK_GL_SOFTWARE_DRAW_SURFACE},
{"software-draw-gl", GDK_GL_SOFTWARE_DRAW_GL},
{"software-draw-surface", GDK_GL_SOFTWARE_DRAW_SURFACE},
{"texture-rectangle", GDK_GL_TEXTURE_RECTANGLE},
};
#ifdef G_ENABLE_DEBUG
static const GDebugKey gdk_debug_keys[] = {
{"events", GDK_DEBUG_EVENTS},
@@ -149,7 +160,6 @@ static const GDebugKey gdk_debug_keys[] = {
{"eventloop", GDK_DEBUG_EVENTLOOP},
{"frames", GDK_DEBUG_FRAMES},
{"settings", GDK_DEBUG_SETTINGS},
{"nogl", GDK_DEBUG_NOGL},
{"opengl", GDK_DEBUG_OPENGL},
};
@@ -231,23 +241,33 @@ static const GOptionEntry gdk_args[] = {
{ NULL }
};
void
gdk_add_option_entries (GOptionGroup *group)
{
g_option_group_add_entries (group, gdk_args);
}
/**
* gdk_add_option_entries_libgtk_only:
* @group: An option group.
*
* Appends gdk option entries to the passed in option group. This is
* not public API and must not be used by applications.
*
* Deprecated: 3.16: This symbol was never meant to be used outside
* of GTK+
*/
void
gdk_add_option_entries_libgtk_only (GOptionGroup *group)
{
g_option_group_add_entries (group, gdk_args);
gdk_add_option_entries (group);
}
void
gdk_pre_parse_libgtk_only (void)
gdk_pre_parse (void)
{
const char *rendering_mode;
const gchar *gl_string;
gdk_initialized = TRUE;
@@ -268,6 +288,12 @@ gdk_pre_parse_libgtk_only (void)
}
#endif /* G_ENABLE_DEBUG */
gl_string = getenv("GDK_GL");
if (gl_string != NULL)
_gdk_gl_flags = g_parse_debug_string (gl_string,
(GDebugKey *) gdk_gl_keys,
G_N_ELEMENTS (gdk_gl_keys));
if (getenv ("GDK_NATIVE_WINDOWS"))
{
g_warning ("The GDK_NATIVE_WINDOWS environment variable is not supported in GTK3.\n"
@@ -287,6 +313,20 @@ gdk_pre_parse_libgtk_only (void)
}
}
/**
* gdk_pre_parse_libgtk_only:
*
* Prepare for parsing command line arguments for GDK. This is not
* public API and should not be used in application code.
*
* Deprecated: 3.16: This symbol was never meant to be used outside
* of GTK+
*/
void
gdk_pre_parse_libgtk_only (void)
{
gdk_pre_parse ();
}
/**
* gdk_parse_args:
@@ -315,7 +355,7 @@ gdk_parse_args (int *argc,
if (gdk_initialized)
return;
gdk_pre_parse_libgtk_only ();
gdk_pre_parse ();
option_context = g_option_context_new (NULL);
g_option_context_set_ignore_unknown_options (option_context, TRUE);
@@ -374,8 +414,8 @@ gdk_get_display_arg_name (void)
return _gdk_display_arg_name;
}
/**
* gdk_display_open_default_libgtk_only:
/*< private >
* gdk_display_open_default:
*
* Opens the default display specified by command line arguments or
* environment variables, sets it as the default display, and returns
@@ -385,9 +425,9 @@ gdk_get_display_arg_name (void)
*
* Returns: (nullable) (transfer none): the default display, if it
* could be opened, otherwise %NULL.
**/
*/
GdkDisplay *
gdk_display_open_default_libgtk_only (void)
gdk_display_open_default (void)
{
GdkDisplay *display;
@@ -402,6 +442,27 @@ gdk_display_open_default_libgtk_only (void)
return display;
}
/**
* gdk_display_open_default_libgtk_only:
*
* Opens the default display specified by command line arguments or
* environment variables, sets it as the default display, and returns
* it. gdk_parse_args() must have been called first. If the default
* display has previously been set, simply returns that. An internal
* function that should not be used by applications.
*
* Returns: (nullable) (transfer none): the default display, if it
* could be opened, otherwise %NULL.
*
* Deprecated: 3.16: This symbol was never meant to be used outside
* of GTK+
*/
GdkDisplay *
gdk_display_open_default_libgtk_only (void)
{
return gdk_display_open_default ();
}
/**
* gdk_init_check:
* @argc: (inout): the number of command line arguments.
@@ -424,7 +485,7 @@ gdk_init_check (int *argc,
{
gdk_parse_args (argc, argv);
return gdk_display_open_default_libgtk_only () != NULL;
return gdk_display_open_default () != NULL;
}
+3 -3
View File
@@ -192,11 +192,13 @@ gdk_cursor_unref (GdkCursor *cursor)
* To make the cursor invisible, use %GDK_BLANK_CURSOR.
*
* Returns: a new #GdkCursor
*
* Deprecated: 3.16: Use gdk_cursor_new_for_display() instead.
*/
GdkCursor*
gdk_cursor_new (GdkCursorType cursor_type)
{
return gdk_cursor_new_for_display (gdk_display_get_default(), cursor_type);
return gdk_cursor_new_for_display (gdk_display_get_default (), cursor_type);
}
/**
@@ -448,9 +450,7 @@ gdk_cursor_get_image (GdkCursor *cursor)
h = cairo_image_surface_get_height (surface);
x_scale = y_scale = 1;
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
cairo_surface_get_device_scale (surface, &x_scale, &y_scale);
#endif
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, w, h);
cairo_surface_destroy (surface);
+1 -1
View File
@@ -219,7 +219,7 @@ GType gdk_cursor_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GdkCursor* gdk_cursor_new_for_display (GdkDisplay *display,
GdkCursorType cursor_type);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_3_16
GdkCursor* gdk_cursor_new (GdkCursorType cursor_type);
GDK_AVAILABLE_IN_ALL
GdkCursor* gdk_cursor_new_from_pixbuf (GdkDisplay *display,
+5 -2
View File
@@ -1260,6 +1260,8 @@ get_native_grab_event_mask (GdkEventMask grab_mask)
* or the window becomes unviewable. This overrides any previous grab on the device
* by this client.
*
* Note that @device and @window need to be on the same display.
*
* Device grabs are used for operations which need complete control over the
* given device events (either pointer or keyboard). For example in GTK+ this
* is used for Drag and Drop operations, popup menus and such.
@@ -1291,8 +1293,9 @@ gdk_device_grab (GdkDevice *device,
GdkGrabStatus res;
GdkWindow *native;
g_return_val_if_fail (GDK_IS_DEVICE (device), GDK_GRAB_SUCCESS);
g_return_val_if_fail (GDK_IS_WINDOW (window), GDK_GRAB_SUCCESS);
g_return_val_if_fail (GDK_IS_DEVICE (device), GDK_GRAB_FAILED);
g_return_val_if_fail (GDK_IS_WINDOW (window), GDK_GRAB_FAILED);
g_return_val_if_fail (gdk_window_get_display (window) == gdk_device_get_display (device), GDK_GRAB_FAILED);
native = gdk_window_get_toplevel (window);
+1 -1
View File
@@ -265,7 +265,7 @@ void gdk_device_warp (GdkDevice *device,
gint x,
gint y);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_3_16
gboolean gdk_device_grab_info_libgtk_only (GdkDisplay *display,
GdkDevice *device,
GdkWindow **grab_window,
+82 -54
View File
@@ -24,6 +24,8 @@
#include "gdkdisplay.h"
#include "gdkdisplayprivate.h"
#include "gdk-private.h"
#include "gdkdeviceprivate.h"
#include "gdkdisplaymanagerprivate.h"
#include "gdkevents.h"
@@ -110,6 +112,19 @@ gdk_display_real_opened (GdkDisplay *display)
_gdk_display_manager_add_display (gdk_display_manager_get (), display);
}
static void
gdk_display_real_event_data_copy (GdkDisplay *display,
const GdkEvent *src,
GdkEvent *dst)
{
}
static void
gdk_display_real_event_data_free (GdkDisplay *display,
GdkEvent *dst)
{
}
static void
gdk_display_class_init (GdkDisplayClass *class)
{
@@ -123,6 +138,8 @@ gdk_display_class_init (GdkDisplayClass *class)
class->opened = gdk_display_real_opened;
class->make_default = gdk_display_real_make_default;
class->event_data_copy = gdk_display_real_event_data_copy;
class->event_data_free = gdk_display_real_event_data_free;
/**
* GdkDisplay::opened:
@@ -206,6 +223,8 @@ gdk_display_init (GdkDisplay *display)
display->multiple_click_info = g_hash_table_new_full (NULL, NULL, NULL,
(GDestroyNotify) g_free);
display->rendering_mode = _gdk_rendering_mode;
}
static void
@@ -1278,8 +1297,8 @@ _gdk_display_pointer_info_foreach (GdkDisplay *display,
}
}
/**
* gdk_device_grab_info_libgtk_only:
/*< private >
* gdk_device_grab_info:
* @display: the display for which to get the grab information
* @device: device to get the grab information from
* @grab_window: (out) (transfer none): location to store current grab window
@@ -1292,12 +1311,12 @@ _gdk_display_pointer_info_foreach (GdkDisplay *display,
*
* Returns: %TRUE if this application currently has the
* keyboard grabbed.
**/
*/
gboolean
gdk_device_grab_info_libgtk_only (GdkDisplay *display,
GdkDevice *device,
GdkWindow **grab_window,
gboolean *owner_events)
gdk_device_grab_info (GdkDisplay *display,
GdkDevice *device,
GdkWindow **grab_window,
gboolean *owner_events)
{
GdkDeviceGrabInfo *info;
@@ -1319,6 +1338,33 @@ gdk_device_grab_info_libgtk_only (GdkDisplay *display,
return FALSE;
}
/**
* gdk_device_grab_info_libgtk_only:
* @display: the display for which to get the grab information
* @device: device to get the grab information from
* @grab_window: (out) (transfer none): location to store current grab window
* @owner_events: (out): location to store boolean indicating whether
* the @owner_events flag to gdk_keyboard_grab() or
* gdk_pointer_grab() was %TRUE.
*
* Determines information about the current keyboard grab.
* This is not public API and must not be used by applications.
*
* Returns: %TRUE if this application currently has the
* keyboard grabbed.
*
* Deprecated: 3.16: The symbol was never meant to be used outside
* of GTK+
*/
gboolean
gdk_device_grab_info_libgtk_only (GdkDisplay *display,
GdkDevice *device,
GdkWindow **grab_window,
gboolean *owner_events)
{
return gdk_device_grab_info (display, device, grab_window, owner_events);
}
/**
* gdk_display_pointer_is_grabbed:
* @display: a #GdkDisplay
@@ -2229,28 +2275,6 @@ gdk_error_trap_pop (void)
return gdk_error_trap_pop_internal (TRUE);
}
/*< private >
* gdk_display_destroy_gl_context:
* @display: a #GdkDisplay
* @context: a #GdkGLContext
*
* Destroys the platform-specific parts of the @context.
*
* The @context instance is still valid, though inert, after
* this functionr returns.
*/
void
gdk_display_destroy_gl_context (GdkDisplay *display,
GdkGLContext *context)
{
GdkGLContext *current = gdk_display_get_current_gl_context (display);
if (current == context)
g_object_set_data (G_OBJECT (display), "-gdk-gl-current-context", NULL);
GDK_DISPLAY_GET_CLASS (display)->destroy_gl_context (display, context);
}
/*< private >
* gdk_display_make_gl_context_current:
* @display: a #GdkDisplay
@@ -2259,35 +2283,39 @@ gdk_display_destroy_gl_context (GdkDisplay *display,
* Makes the given @context the current GL context, or unsets
* the current GL context if @context is %NULL.
*/
void
gboolean
gdk_display_make_gl_context_current (GdkDisplay *display,
GdkGLContext *context)
{
GdkGLContext *current = gdk_display_get_current_gl_context (display);
if (current == context)
return;
if (context == NULL)
g_object_set_data (G_OBJECT (display), "-gdk-gl-current-context", NULL);
else
g_object_set_data_full (G_OBJECT (display), "-gdk-gl-current-context",
g_object_ref (context),
(GDestroyNotify) g_object_unref);
GDK_DISPLAY_GET_CLASS (display)->make_gl_context_current (display, context);
return GDK_DISPLAY_GET_CLASS (display)->make_gl_context_current (display, context);
}
/*< private >
* gdk_display_get_current_gl_context:
* @display: a #GdkDisplay
*
* Retrieves the current #GdkGLContext associated with @display.
*
* Returns: (transfer none): the current #GdkGLContext or %NULL
*/
GdkGLContext *
gdk_display_get_current_gl_context (GdkDisplay *display)
GdkRenderingMode
gdk_display_get_rendering_mode (GdkDisplay *display)
{
return g_object_get_data (G_OBJECT (display), "-gdk-gl-current-context");
return display->rendering_mode;
}
void
gdk_display_set_rendering_mode (GdkDisplay *display,
GdkRenderingMode mode)
{
display->rendering_mode = mode;
}
void
gdk_display_set_debug_updates (GdkDisplay *display,
gboolean debug_updates)
{
display->debug_updates = debug_updates;
display->debug_updates_set = TRUE;
}
gboolean
gdk_display_get_debug_updates (GdkDisplay *display)
{
if (display->debug_updates_set)
return display->debug_updates;
else
return _gdk_debug_updates;
}
+1 -1
View File
@@ -123,7 +123,7 @@ void gdk_display_warp_pointer (GdkDisplay *disp
gint y);
#endif /* GDK_MULTIDEVICE_SAFE */
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_3_16
GdkDisplay *gdk_display_open_default_libgtk_only (void);
GDK_AVAILABLE_IN_ALL
+12 -8
View File
@@ -21,6 +21,7 @@
#include "gdkdisplay.h"
#include "gdkwindow.h"
#include "gdkcursor.h"
#include "gdkinternals.h"
G_BEGIN_DECLS
@@ -116,6 +117,14 @@ struct _GdkDisplay
guint double_click_time; /* Maximum time between clicks in msecs */
guint double_click_distance; /* Maximum distance between clicks in pixels */
guint has_gl_extension_texture_non_power_of_two : 1;
guint has_gl_extension_texture_rectangle : 1;
guint debug_updates : 1;
guint debug_updates_set : 1;
GdkRenderingMode rendering_mode;
};
struct _GdkDisplayClass
@@ -225,10 +234,8 @@ struct _GdkDisplayClass
gchar * (*utf8_to_string_target) (GdkDisplay *display,
const gchar *text);
void (*make_gl_context_current) (GdkDisplay *display,
GdkGLContext *context);
void (*destroy_gl_context) (GdkDisplay *display,
GdkGLContext *context);
gboolean (*make_gl_context_current) (GdkDisplay *display,
GdkGLContext *context);
/* Signals */
void (*opened) (GdkDisplay *display);
@@ -308,11 +315,8 @@ void _gdk_display_create_window_impl (GdkDisplay *display
gint attributes_mask);
GdkWindow * _gdk_display_create_window (GdkDisplay *display);
void gdk_display_destroy_gl_context (GdkDisplay *display,
gboolean gdk_display_make_gl_context_current (GdkDisplay *display,
GdkGLContext *context);
void gdk_display_make_gl_context_current (GdkDisplay *display,
GdkGLContext *context);
GdkGLContext * gdk_display_get_current_gl_context (GdkDisplay *display);
G_END_DECLS
+15 -9
View File
@@ -461,6 +461,15 @@ gdk_event_peek (void)
return event;
}
static GdkDisplay *
event_get_display (const GdkEvent *event)
{
if (event->any.window)
return gdk_window_get_display (event->any.window);
else
return gdk_display_get_default ();
}
/**
* gdk_event_put:
* @event: a #GdkEvent.
@@ -476,10 +485,7 @@ gdk_event_put (const GdkEvent *event)
g_return_if_fail (event != NULL);
if (event->any.window)
display = gdk_window_get_display (event->any.window);
else
display = gdk_display_get_default ();
display = event_get_display (event);
gdk_display_put_event (display, event);
}
@@ -713,7 +719,7 @@ gdk_event_copy (const GdkEvent *event)
}
if (gdk_event_is_allocated (event))
_gdk_display_event_data_copy (gdk_display_get_default (), event, new_event);
_gdk_display_event_data_copy (event_get_display (event), event, new_event);
return new_event;
}
@@ -734,9 +740,6 @@ gdk_event_free (GdkEvent *event)
g_return_if_fail (event != NULL);
if (event->any.window)
g_object_unref (event->any.window);
switch (event->any.type)
{
case GDK_KEY_PRESS:
@@ -804,10 +807,13 @@ gdk_event_free (GdkEvent *event)
break;
}
display = gdk_display_get_default ();
display = event_get_display (event);
if (display)
_gdk_display_event_data_free (display, event);
if (event->any.window)
g_object_unref (event->any.window);
g_hash_table_remove (event_hash, event);
g_slice_free (GdkEventPrivate, (GdkEventPrivate*) event);
}
+367 -82
View File
@@ -35,6 +35,254 @@ gdk_cairo_surface_mark_as_direct (cairo_surface_t *surface,
g_object_ref (window), g_object_unref);
}
static const char *
get_vertex_type_name (int type)
{
switch (type)
{
case GL_VERTEX_SHADER:
return "vertex";
case GL_GEOMETRY_SHADER:
return "geometry";
case GL_FRAGMENT_SHADER:
return "fragment";
}
return "unknown";
}
static guint
create_shader (int type, const char const *code)
{
guint shader;
int status;
shader = glCreateShader (type);
glShaderSource (shader, 1, &code, NULL);
glCompileShader (shader);
glGetShaderiv (shader, GL_COMPILE_STATUS, &status);
if (status == GL_FALSE)
{
int log_len;
char *buffer;
glGetShaderiv (shader, GL_INFO_LOG_LENGTH, &log_len);
buffer = g_malloc (log_len + 1);
glGetShaderInfoLog (shader, log_len, NULL, buffer);
g_warning ("Compile failure in %s shader:\n%s\n", get_vertex_type_name (type), buffer);
g_free (buffer);
glDeleteShader (shader);
return 0;
}
return shader;
}
static guint
make_program (const char const *vertex_shader_code, const char const *fragment_shader_code)
{
guint program, vertex_shader, fragment_shader;
int status;
vertex_shader = create_shader (GL_VERTEX_SHADER, vertex_shader_code);
if (vertex_shader == 0)
return 0;
fragment_shader = create_shader (GL_FRAGMENT_SHADER, fragment_shader_code);
if (fragment_shader == 0)
{
glDeleteShader (vertex_shader);
return 0;
}
program = glCreateProgram ();
glAttachShader (program, vertex_shader);
glAttachShader (program, fragment_shader);
glLinkProgram (program);
glDeleteShader (vertex_shader);
glDeleteShader (fragment_shader);
glGetProgramiv (program, GL_LINK_STATUS, &status);
if (status == GL_FALSE)
{
int log_len;
char *buffer;
glGetProgramiv (program, GL_INFO_LOG_LENGTH, &log_len);
buffer = g_malloc (log_len + 1);
glGetProgramInfoLog (program, log_len, NULL, buffer);
g_warning ("Linker failure: %s\n", buffer);
g_free (buffer);
glDeleteProgram (program);
return 0;
}
return program;
}
static void
bind_vao (GdkGLContextPaintData *paint_data)
{
if (paint_data->vertex_array_object == 0)
{
glGenVertexArrays (1, &paint_data->vertex_array_object);
/* ATM we only use one VAO, so always bind it */
glBindVertexArray (paint_data->vertex_array_object);
}
}
static void
use_texture_2d_program (GdkGLContextPaintData *paint_data,
guint *position_location,
guint *uv_location,
guint *map_location)
{
const char *vertex_shader_code =
"#version 120\n"
"uniform sampler2D map;"
"attribute vec2 position;\n"
"attribute vec2 uv;\n"
"varying vec2 vUv;\n"
"void main() {\n"
" gl_Position = vec4(position, 0, 1);\n"
" vUv = uv;\n"
"}\n";
const char *fragment_shader_code =
"#version 120\n"
"varying vec2 vUv;\n"
"uniform sampler2D map;\n"
"void main() {\n"
" gl_FragColor = texture2D (map, vUv);\n"
"}\n";
if (paint_data->texture_quad_program == 0)
{
paint_data->texture_quad_program = make_program (vertex_shader_code, fragment_shader_code);
paint_data->texture_quad_program_position_location = glGetAttribLocation (paint_data->texture_quad_program, "position");
paint_data->texture_quad_program_uv_location = glGetAttribLocation (paint_data->texture_quad_program, "uv");
paint_data->texture_quad_program_map_location = glGetUniformLocation (paint_data->texture_quad_program, "map");
}
if (paint_data->current_program != paint_data->texture_quad_program)
{
glUseProgram (paint_data->texture_quad_program);
paint_data->current_program = paint_data->texture_quad_program;
}
*position_location = paint_data->texture_quad_program_position_location;
*uv_location = paint_data->texture_quad_program_uv_location;
*map_location = paint_data->texture_quad_program_map_location;
}
static void
use_texture_rect_program (GdkGLContextPaintData *paint_data,
guint *position_location,
guint *uv_location,
guint *map_location)
{
const char *vertex_shader_code =
"#version 120\n"
"uniform sampler2DRect map;"
"attribute vec2 position;\n"
"attribute vec2 uv;\n"
"varying vec2 vUv;\n"
"void main() {\n"
" gl_Position = vec4(position, 0, 1);\n"
" vUv = uv;\n"
"}\n";
const char *fragment_shader_code =
"#version 120\n"
"varying vec2 vUv;\n"
"uniform sampler2DRect map;\n"
"void main() {\n"
" gl_FragColor = texture2DRect (map, vUv);\n"
"}\n";
if (paint_data->texture_quad_rect_program == 0)
{
paint_data->texture_quad_rect_program = make_program (vertex_shader_code, fragment_shader_code);
paint_data->texture_quad_rect_program_position_location = glGetAttribLocation (paint_data->texture_quad_rect_program, "position");
paint_data->texture_quad_rect_program_uv_location = glGetAttribLocation (paint_data->texture_quad_rect_program, "uv");
paint_data->texture_quad_rect_program_map_location = glGetUniformLocation (paint_data->texture_quad_rect_program, "map");
}
if (paint_data->current_program != paint_data->texture_quad_rect_program)
{
glUseProgram (paint_data->texture_quad_rect_program);
paint_data->current_program = paint_data->texture_quad_rect_program;
}
*position_location = paint_data->texture_quad_rect_program_position_location;
*uv_location = paint_data->texture_quad_rect_program_uv_location;
*map_location = paint_data->texture_quad_rect_program_map_location;
}
void
gdk_gl_texture_quad (GdkGLContext *paint_context,
guint texture_target,
float x1, float y1,
float x2, float y2,
float u1, float v1,
float u2, float v2)
{
GdkGLContextPaintData *paint_data = gdk_gl_context_get_paint_data (paint_context);
GdkWindow *window = gdk_gl_context_get_window (paint_context);
int window_scale = gdk_window_get_scale_factor (window);
float w = gdk_window_get_width (window) * window_scale;
float h = gdk_window_get_height (window) * window_scale;
float vertex_buffer_data[] = {
(x2 * 2) / w - 1, (y1 * 2) / h - 1,
(x2 * 2) / w - 1, (y2 * 2) / h - 1,
(x1 * 2) / w - 1, (y2 * 2) / h - 1,
(x1 * 2) / w - 1, (y1 * 2) / h - 1,
};
float uv_buffer_data[] = {
u2, v1,
u2, v2,
u1, v2,
u1, v1,
};
guint position_location, uv_location, map_location;
bind_vao (paint_data);
if (paint_data->tmp_vertex_buffer == 0)
glGenBuffers(1, &paint_data->tmp_vertex_buffer);
if (paint_data->tmp_uv_buffer == 0)
glGenBuffers(1, &paint_data->tmp_uv_buffer);
if (texture_target == GL_TEXTURE_RECTANGLE_ARB)
use_texture_rect_program (paint_data, &position_location, &uv_location, &map_location);
else
use_texture_2d_program (paint_data, &position_location, &uv_location, &map_location);
glActiveTexture (GL_TEXTURE0);
glUniform1i(map_location, 0); /* Use texture unit 0 */
glEnableVertexAttribArray (0);
glBindBuffer (GL_ARRAY_BUFFER, paint_data->tmp_vertex_buffer);
glBufferData (GL_ARRAY_BUFFER, sizeof(vertex_buffer_data), vertex_buffer_data, GL_STREAM_DRAW);
glVertexAttribPointer (position_location, 2, GL_FLOAT, GL_FALSE, 0, NULL);
glEnableVertexAttribArray (1);
glBindBuffer (GL_ARRAY_BUFFER, paint_data->tmp_uv_buffer);
glBufferData (GL_ARRAY_BUFFER, sizeof(uv_buffer_data), uv_buffer_data, GL_STREAM_DRAW);
glVertexAttribPointer (uv_location, 2, GL_FLOAT, GL_FALSE, 0, NULL);
glDrawArrays (GL_TRIANGLE_FAN, 0, 4);
glDisableVertexAttribArray (0);
glDisableVertexAttribArray (1);
}
/* x,y,width,height describes a rectangle in the gl render buffer
coordinate space, and its top left corner is drawn at the current
position according to the cairo translation. */
@@ -54,6 +302,8 @@ gdk_cairo_surface_mark_as_direct (cairo_surface_t *surface,
* This is the main way to draw GL content in GTK+. It takes a render buffer ID
* (@source_type == #GL_RENDERBUFFER) or a texture id (@source_type == #GL_TEXTURE)
* and draws it onto @cr with an OVER operation, respecting the current clip.
* The top left corner of the rectangle specified by @x, @y, @width and @height
* will be drawn at the current (0,0) position of the cairo_t.
*
* This will work for *all* cairo_t, as long as @window is realized, but the
* fallback implementation that reads back the pixels from the buffer may be
@@ -64,6 +314,8 @@ gdk_cairo_surface_mark_as_direct (cairo_surface_t *surface,
* For #GL_RENDERBUFFER the code will always fall back to software for buffers
* with alpha components, so make sure you use #GL_TEXTURE if using alpha.
*
* Calling this may change the current GL context.
*
* Since: 3.16
*/
void
@@ -77,23 +329,24 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
int width,
int height)
{
GdkGLContext *context;
GdkGLContext *paint_context;
cairo_surface_t *image;
cairo_matrix_t matrix;
int dx, dy, window_scale;
gboolean trivial_transform;
cairo_surface_t *group_target;
GdkWindow *direct_window, *impl_window;
GLuint framebuffer;
GLint alpha_size = 0;
guint framebuffer;
int alpha_size = 0;
cairo_region_t *clip_region;
GdkGLContextPaintData *paint_data;
impl_window = window->impl_window;
window_scale = gdk_window_get_scale_factor (impl_window);
context = gdk_window_get_paint_gl_context (window, NULL);
if (context == NULL)
paint_context = gdk_window_get_paint_gl_context (window, NULL);
if (paint_context == NULL)
{
g_warning ("gdk_cairo_draw_gl_render_buffer failed - no paint context");
return;
@@ -101,32 +354,22 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
clip_region = gdk_cairo_region_from_clip (cr);
gdk_gl_context_make_current (context);
gdk_gl_context_make_current (paint_context);
paint_data = gdk_gl_context_get_paint_data (paint_context);
glGenFramebuffersEXT (1, &framebuffer);
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, framebuffer);
if (paint_data->tmp_framebuffer == 0)
glGenFramebuffersEXT (1, &paint_data->tmp_framebuffer);
if (source_type == GL_RENDERBUFFER)
{
glGetRenderbufferParameteriv (GL_RENDERBUFFER, GL_RENDERBUFFER_ALPHA_SIZE, &alpha_size);
glBindRenderbufferEXT (GL_RENDERBUFFER_EXT, source);
glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_RENDERBUFFER_EXT, source);
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
glGetRenderbufferParameteriv (GL_RENDERBUFFER, GL_RENDERBUFFER_ALPHA_SIZE, &alpha_size);
}
else if (source_type == GL_TEXTURE)
{
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE, &alpha_size);
glBindTexture (GL_TEXTURE_2D, source);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_TEXTURE_2D, source, 0);
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE, &alpha_size);
}
else
{
@@ -150,25 +393,34 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
/* For direct paint of non-alpha renderbuffer, we can
just do a bitblit */
if (source_type == GL_RENDERBUFFER &&
if ((_gdk_gl_flags & GDK_GL_SOFTWARE_DRAW_GL) == 0 &&
source_type == GL_RENDERBUFFER &&
alpha_size == 0 &&
direct_window != NULL &&
direct_window->current_paint.use_gl &&
trivial_transform &&
clip_region != NULL)
{
int window_height;
int unscaled_window_height;
int i;
/* Create a framebuffer with the source renderbuffer and
make it the current target for reads */
framebuffer = paint_data->tmp_framebuffer;
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, framebuffer);
glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_RENDERBUFFER_EXT, source);
glBindFramebufferEXT (GL_DRAW_FRAMEBUFFER_EXT, 0);
/* Translate to impl coords */
cairo_region_translate (clip_region, dx, dy);
glEnable (GL_SCISSOR_TEST);
window_height = gdk_window_get_height (impl_window);
gdk_window_get_unscaled_size (impl_window, NULL, &unscaled_window_height);
glDrawBuffer (GL_BACK);
#define FLIP_Y(_y) (window_height*window_scale - (_y))
#define FLIP_Y(_y) (unscaled_window_height - (_y))
for (i = 0; i < cairo_region_num_rectangles (clip_region); i++)
{
@@ -216,17 +468,20 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
glDisable (GL_SCISSOR_TEST);
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
#undef FLIP_Y
}
/* For direct paint of alpha or non-alpha textures we can use texturing */
else if (source_type == GL_TEXTURE &&
else if ((_gdk_gl_flags & GDK_GL_SOFTWARE_DRAW_GL) == 0 &&
source_type == GL_TEXTURE &&
direct_window != NULL &&
direct_window->current_paint.use_gl &&
trivial_transform &&
clip_region != NULL)
{
int window_height;
int unscaled_window_height;
GLint texture_width;
GLint texture_height;
int i;
@@ -234,9 +489,6 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
/* Translate to impl coords */
cairo_region_translate (clip_region, dx, dy);
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &texture_width);
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &texture_height);
if (alpha_size != 0)
{
cairo_region_t *opaque_region, *blend_region;
@@ -260,12 +512,23 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
cairo_region_destroy (opaque_region);
cairo_region_destroy (blend_region);
}
glBindTexture (GL_TEXTURE_2D, source);
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &texture_width);
glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &texture_height);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glEnable (GL_SCISSOR_TEST);
glEnable (GL_TEXTURE_2D);
window_height = gdk_window_get_height (impl_window);
gdk_window_get_unscaled_size (impl_window, NULL, &unscaled_window_height);
#define FLIP_Y(_y) (window_height*window_scale - (_y))
#define FLIP_Y(_y) (unscaled_window_height - (_y))
for (i = 0; i < cairo_region_num_rectangles (clip_region); i++)
{
@@ -291,19 +554,12 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
int clipped_src_x = x + (dest.x - dx * window_scale);
int clipped_src_y = y + (height - dest.height - (dest.y - dy * window_scale));
glBegin (GL_QUADS);
glTexCoord2f (clipped_src_x / (float)texture_width, clipped_src_y / (float)texture_height);
glVertex2f (dest.x, FLIP_Y(dest.y + dest.height));
glTexCoord2f ((clipped_src_x + dest.width) / (float)texture_width, clipped_src_y / (float)texture_height);
glVertex2f (dest.x + dest.width, FLIP_Y(dest.y + dest.height));
glTexCoord2f ((clipped_src_x + dest.width) / (float)texture_width, (clipped_src_y + dest.height) / (float)texture_height);
glVertex2f (dest.x + dest.width, FLIP_Y(dest.y));
glTexCoord2f (clipped_src_x / (float)texture_width, (clipped_src_y + dest.height) / (float)texture_height);
glVertex2f (dest.x, FLIP_Y(dest.y));
glEnd();
gdk_gl_texture_quad (paint_context,
GL_TEXTURE_2D,
dest.x, FLIP_Y(dest.y),
dest.x + dest.width, FLIP_Y(dest.y + dest.height),
clipped_src_x / (float)texture_width, (clipped_src_y + dest.height) / (float)texture_height,
(clipped_src_x + dest.width) / (float)texture_width, clipped_src_y / (float)texture_height);
if (impl_window->current_paint.flushed_region)
{
@@ -340,9 +596,23 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
(alpha_size == 0) ? CAIRO_FORMAT_RGB24 : CAIRO_FORMAT_ARGB32,
width, height);
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
cairo_surface_set_device_scale (image, buffer_scale, buffer_scale);
#endif
framebuffer = paint_data->tmp_framebuffer;
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, framebuffer);
if (source_type == GL_RENDERBUFFER)
{
/* Create a framebuffer with the source renderbuffer and
make it the current target for reads */
glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_RENDERBUFFER_EXT, source);
}
else
{
glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_TEXTURE_2D, source, 0);
}
glPixelStorei (GL_PACK_ALIGNMENT, 4);
glPixelStorei (GL_PACK_ROW_LENGTH, cairo_image_surface_get_stride (image) / 4);
@@ -352,6 +622,8 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
glPixelStorei (GL_PACK_ROW_LENGTH, 0);
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
cairo_surface_mark_dirty (image);
/* Invert due to opengl having different origin */
@@ -365,61 +637,70 @@ gdk_cairo_draw_from_gl (cairo_t *cr,
cairo_surface_destroy (image);
}
glDrawBuffer (GL_BACK);
glReadBuffer(GL_BACK);
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
glDeleteFramebuffersEXT (1, &framebuffer);
if (clip_region)
cairo_region_destroy (clip_region);
}
/* This is always called with the paint context current */
void
gdk_gl_texture_from_surface (cairo_surface_t *surface,
cairo_region_t *region)
{
GdkGLContext *current;
GdkGLContext *paint_context;
cairo_surface_t *image;
double device_x_offset, device_y_offset;
cairo_rectangle_int_t rect, e;
int n_rects, i;
GdkWindow *window;
int window_height;
int unscaled_window_height;
unsigned int texture_id;
int window_scale;
double sx, sy;
float umax, vmax;
gboolean use_texture_rectangle;
guint target;
current = gdk_gl_context_get_current ();
if (current &&
GDK_GL_CONTEXT_GET_CLASS (current)->texture_from_surface &&
GDK_GL_CONTEXT_GET_CLASS (current)->texture_from_surface (current, surface, region))
paint_context = gdk_gl_context_get_current ();
if ((_gdk_gl_flags & GDK_GL_SOFTWARE_DRAW_SURFACE) == 0 &&
paint_context &&
GDK_GL_CONTEXT_GET_CLASS (paint_context)->texture_from_surface &&
GDK_GL_CONTEXT_GET_CLASS (paint_context)->texture_from_surface (paint_context, surface, region))
return;
/* Software fallback */
use_texture_rectangle = gdk_gl_context_use_texture_rectangle (paint_context);
window = gdk_gl_context_get_window (gdk_gl_context_get_current ());
window = gdk_gl_context_get_window (paint_context);
window_scale = gdk_window_get_scale_factor (window);
window_height = gdk_window_get_height (window);
gdk_window_get_unscaled_size (window, NULL, &unscaled_window_height);
sx = sy = 1;
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
cairo_surface_get_device_scale (window->current_paint.surface, &sx, &sy);
#endif
cairo_surface_get_device_offset (surface,
&device_x_offset, &device_y_offset);
glGenTextures (1, &texture_id);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture_id);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
if (use_texture_rectangle)
target = GL_TEXTURE_RECTANGLE_ARB;
else
target = GL_TEXTURE_2D;
glBindTexture (target, texture_id);
glEnable (target);
glEnable (GL_SCISSOR_TEST);
glTexParameteri (target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri (target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri (target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
n_rects = cairo_region_num_rectangles (region);
for (i = 0; i < n_rects; i++)
{
cairo_region_get_rectangle (region, i, &rect);
glScissor (rect.x * window_scale, (window_height - rect.y - rect.height) * window_scale,
glScissor (rect.x * window_scale, unscaled_window_height - (rect.y + rect.height) * window_scale,
rect.width * window_scale, rect.height * window_scale);
e = rect;
@@ -433,29 +714,33 @@ gdk_gl_texture_from_surface (cairo_surface_t *surface,
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
glPixelStorei (GL_UNPACK_ROW_LENGTH, cairo_image_surface_get_stride (image)/4);
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 4, e.width, e.height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
glTexImage2D (target, 0, 4, e.width, e.height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
cairo_image_surface_get_data (image));
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
cairo_surface_unmap_image (surface, image);
#define FLIP_Y(_y) (window_height - (_y))
#define FLIP_Y(_y) (unscaled_window_height - (_y))
glBegin (GL_QUADS);
glTexCoord2f (0.0f * sx, rect.height * sy);
glVertex2f (rect.x * window_scale, FLIP_Y(rect.y + rect.height) * window_scale);
if (use_texture_rectangle)
{
umax = rect.width * sx;
vmax = rect.height * sy;
}
else
{
umax = 1.0;
vmax = 1.0;
}
glTexCoord2f (rect.width * sx, rect.height * sy);
glVertex2f ((rect.x + rect.width) * window_scale, FLIP_Y(rect.y + rect.height) * window_scale);
glTexCoord2f (rect.width * sx, 0.0f * sy);
glVertex2f ((rect.x + rect.width) * window_scale, FLIP_Y(rect.y) * window_scale);
glTexCoord2f (0.0f * sx, 0.0f * sy);
glVertex2f (rect.x * window_scale, FLIP_Y(rect.y) * window_scale);
glEnd();
gdk_gl_texture_quad (paint_context, target,
rect.x * window_scale, FLIP_Y(rect.y),
(rect.x + rect.width) * window_scale, FLIP_Y((rect.y + rect.height) * window_scale),
0, 0,
umax, vmax);
}
glDisable (GL_TEXTURE_RECTANGLE_ARB);
glDisable (GL_SCISSOR_TEST);
glDisable (target);
glDeleteTextures (1, &texture_id);
}
+284 -48
View File
@@ -72,21 +72,34 @@
#include "gdkglcontextprivate.h"
#include "gdkdisplayprivate.h"
#include "gdkvisual.h"
#include "gdkinternals.h"
#include "gdkintl.h"
#include "gdk-private.h"
#include <epoxy/gl.h>
typedef struct {
GdkDisplay *display;
GdkWindow *window;
GdkVisual *visual;
GdkGLContext *shared_context;
GdkGLProfile profile;
guint realized : 1;
guint use_texture_rectangle : 1;
guint has_gl_framebuffer_blit : 1;
guint has_frame_terminator : 1;
GdkGLContextPaintData *paint_data;
} GdkGLContextPrivate;
enum {
PROP_0,
PROP_DISPLAY,
PROP_WINDOW,
PROP_VISUAL,
PROP_PROFILE,
PROP_SHARED_CONTEXT,
LAST_PROP
};
@@ -97,20 +110,35 @@ G_DEFINE_QUARK (gdk-gl-error-quark, gdk_gl_error)
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkGLContext, gdk_gl_context, G_TYPE_OBJECT)
static GPrivate thread_current_context = G_PRIVATE_INIT (g_object_unref);
static void
gdk_gl_context_dispose (GObject *gobject)
{
GdkGLContext *context = GDK_GL_CONTEXT (gobject);
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
GdkGLContext *current;
gdk_display_destroy_gl_context (gdk_window_get_display (priv->window), context);
current = g_private_get (&thread_current_context);
if (current == context)
g_private_replace (&thread_current_context, NULL);
g_clear_object (&priv->display);
g_clear_object (&priv->window);
g_clear_object (&priv->visual);
g_clear_object (&priv->shared_context);
G_OBJECT_CLASS (gdk_gl_context_parent_class)->dispose (gobject);
}
static void
gdk_gl_context_finalize (GObject *gobject)
{
GdkGLContext *context = GDK_GL_CONTEXT (gobject);
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
g_clear_pointer (&priv->paint_data, g_free);
}
static void
gdk_gl_context_set_property (GObject *gobject,
guint prop_id,
@@ -121,6 +149,20 @@ gdk_gl_context_set_property (GObject *gobject,
switch (prop_id)
{
case PROP_DISPLAY:
{
GdkDisplay *display = g_value_get_object (value);
if (display)
g_object_ref (display);
if (priv->display)
g_object_unref (priv->display);
priv->display = display;
}
break;
case PROP_WINDOW:
{
GdkWindow *window = g_value_get_object (value);
@@ -135,15 +177,19 @@ gdk_gl_context_set_property (GObject *gobject,
}
break;
case PROP_VISUAL:
case PROP_SHARED_CONTEXT:
{
GdkVisual *visual = g_value_get_object (value);
GdkGLContext *context = g_value_get_object (value);
if (visual != NULL)
priv->visual = g_object_ref (visual);
if (context != NULL)
priv->shared_context = g_object_ref (context);
}
break;
case PROP_PROFILE:
priv->profile = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
}
@@ -159,12 +205,20 @@ gdk_gl_context_get_property (GObject *gobject,
switch (prop_id)
{
case PROP_DISPLAY:
g_value_set_object (value, priv->display);
break;
case PROP_WINDOW:
g_value_set_object (value, priv->window);
break;
case PROP_VISUAL:
g_value_set_object (value, priv->visual);
case PROP_SHARED_CONTEXT:
g_value_set_object (value, priv->shared_context);
break;
case PROP_PROFILE:
g_value_set_enum (value, priv->profile);
break;
default:
@@ -177,6 +231,22 @@ gdk_gl_context_class_init (GdkGLContextClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
/**
* GdkGLContext:display:
*
* The #GdkWindow the gl context is bound to.
*
* Since: 3.16
*/
obj_pspecs[PROP_DISPLAY] =
g_param_spec_object ("display",
P_("Display"),
P_("The GDK display the context is from"),
GDK_TYPE_DISPLAY,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
/**
* GdkGLContext:window:
*
@@ -194,17 +264,34 @@ gdk_gl_context_class_init (GdkGLContextClass *klass)
G_PARAM_STATIC_STRINGS);
/**
* GdkGLContext:visual:
* GdkGLContext:profile:
*
* The #GdkVisual matching the pixel format used by the context.
* The #GdkGLProfile of the context
*
* Since: 3.16
*/
obj_pspecs[PROP_VISUAL] =
g_param_spec_object ("visual",
P_("Visual"),
P_("The GDK visual used by the GL context"),
GDK_TYPE_VISUAL,
obj_pspecs[PROP_PROFILE] =
g_param_spec_enum ("profile",
P_("Profile"),
P_("The GL profile the context was created for"),
GDK_TYPE_GL_PROFILE,
GDK_GL_PROFILE_DEFAULT,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
/**
* GdkGLContext:shared-context:
*
* The #GdkGLContext that this context is sharing data with, or #NULL
*
* Since: 3.16
*/
obj_pspecs[PROP_SHARED_CONTEXT] =
g_param_spec_object ("shared-context",
P_("Shared context"),
P_("The GL context this context share data with"),
GDK_TYPE_GL_CONTEXT,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
@@ -212,6 +299,7 @@ gdk_gl_context_class_init (GdkGLContextClass *klass)
gobject_class->set_property = gdk_gl_context_set_property;
gobject_class->get_property = gdk_gl_context_get_property;
gobject_class->dispose = gdk_gl_context_dispose;
gobject_class->finalize = gdk_gl_context_finalize;
g_object_class_install_properties (gobject_class, LAST_PROP, obj_pspecs);
}
@@ -221,28 +309,8 @@ gdk_gl_context_init (GdkGLContext *self)
{
}
/**
* gdk_gl_context_get_visual:
* @context: a #GdkGLContext
*
* Retrieves the #GdkVisual associated with the @context.
*
* Returns: (transfer none): the #GdkVisual
*
* Since: 3.16
*/
GdkVisual *
gdk_gl_context_get_visual (GdkGLContext *context)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), NULL);
return priv->visual;
}
/*< private >
* gdk_gl_context_flush_buffer:
* gdk_gl_context_end_frame:
* @context: a #GdkGLContext
* @painted: The area that has been redrawn this frame
* @damage: The area that we know is actually different from the last frame
@@ -256,13 +324,73 @@ gdk_gl_context_get_visual (GdkGLContext *context)
* Since: 3.16
*/
void
gdk_gl_context_flush_buffer (GdkGLContext *context,
cairo_region_t *painted,
cairo_region_t *damage)
gdk_gl_context_end_frame (GdkGLContext *context,
cairo_region_t *painted,
cairo_region_t *damage)
{
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
GDK_GL_CONTEXT_GET_CLASS (context)->flush_buffer (context, painted, damage);
GDK_GL_CONTEXT_GET_CLASS (context)->end_frame (context, painted, damage);
}
GdkGLContextPaintData *
gdk_gl_context_get_paint_data (GdkGLContext *context)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
if (priv->paint_data == NULL)
priv->paint_data = g_new0 (GdkGLContextPaintData, 1);
return priv->paint_data;
}
gboolean
gdk_gl_context_use_texture_rectangle (GdkGLContext *context)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
return priv->use_texture_rectangle;
}
gboolean
gdk_gl_context_has_framebuffer_blit (GdkGLContext *context)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
return priv->has_gl_framebuffer_blit;
}
gboolean
gdk_gl_context_has_frame_terminator (GdkGLContext *context)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
return priv->has_frame_terminator;
}
static void
gdk_gl_context_realize (GdkGLContext *context)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
gboolean has_npot, has_texture_rectangle;
has_npot = epoxy_has_gl_extension ("GL_ARB_texture_non_power_of_two");
has_texture_rectangle = epoxy_has_gl_extension ("GL_ARB_texture_rectangle");
priv->has_gl_framebuffer_blit = epoxy_has_gl_extension ("GL_EXT_framebuffer_blit");
priv->has_frame_terminator = epoxy_has_gl_extension ("GL_GREMEDY_frame_terminator");
if (_gdk_gl_flags & GDK_GL_TEXTURE_RECTANGLE)
priv->use_texture_rectangle = TRUE;
else if (has_npot)
priv->use_texture_rectangle = FALSE;
else if (has_texture_rectangle)
priv->use_texture_rectangle = TRUE;
else
g_warning ("GL implementation doesn't support any form of non-power-of-two textures");
priv->realized = TRUE;
}
/**
@@ -277,10 +405,40 @@ void
gdk_gl_context_make_current (GdkGLContext *context)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
GdkGLContext *current;
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
gdk_display_make_gl_context_current (gdk_window_get_display (priv->window), context);
current = g_private_get (&thread_current_context);
if (current == context)
return;
if (gdk_display_make_gl_context_current (priv->display, context))
{
g_private_replace (&thread_current_context, g_object_ref (context));
if (!priv->realized)
gdk_gl_context_realize (context);
}
}
/**
* gdk_gl_context_get_display:
* @context: a #GdkGLContext
*
* Retrieves the #GdkDisplay the @context is created for
*
* Returns: (transfer none): a #GdkDisplay or %NULL
*
* Since: 3.16
*/
GdkDisplay *
gdk_gl_context_get_display (GdkGLContext *context)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), NULL);
return priv->display;
}
/**
@@ -303,6 +461,46 @@ gdk_gl_context_get_window (GdkGLContext *context)
return priv->window;
}
/**
* gdk_gl_context_get_profile:
* @context: a #GdkGLContext
*
* Retrieves the #GdkGLProfile that @context was created for.
*
* Returns: a #GdkGLProfile
*
* Since: 3.16
*/
GdkGLProfile
gdk_gl_context_get_profile (GdkGLContext *context)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), GDK_GL_PROFILE_LEGACY);
return priv->profile;
}
/**
* gdk_gl_context_get_shared_context:
* @context: a #GdkGLContext
*
* Retrieves the #GdkGLContext that this @context share data with.
*
* Returns: (transfer none): a #GdkGLContext or %NULL
*
* Since: 3.16
*/
GdkGLContext *
gdk_gl_context_get_shared_context (GdkGLContext *context)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), NULL);
return priv->shared_context;
}
/**
* gdk_gl_context_clear_current:
*
@@ -316,9 +514,16 @@ gdk_gl_context_get_window (GdkGLContext *context)
void
gdk_gl_context_clear_current (void)
{
GdkDisplay *display = gdk_display_get_default ();
GdkGLContext *current;
gdk_display_make_gl_context_current (display, NULL);
current = g_private_get (&thread_current_context);
if (current != NULL)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (current);
if (gdk_display_make_gl_context_current (priv->display, NULL))
g_private_replace (&thread_current_context, NULL);
}
}
/**
@@ -333,7 +538,38 @@ gdk_gl_context_clear_current (void)
GdkGLContext *
gdk_gl_context_get_current (void)
{
GdkDisplay *display = gdk_display_get_default ();
GdkGLContext *current;
return gdk_display_get_current_gl_context (display);
current = g_private_get (&thread_current_context);
return current;
}
/**
* gdk_gl_get_flags:
*
* Returns the currently active GL flags.
*
* Returns: the GL flags
*
* Since: 3.16
*/
GdkGLFlags
gdk_gl_get_flags (void)
{
return _gdk_gl_flags;
}
/**
* gdk_gl_set_flags:
* @flags: #GdkGLFlags to set
*
* Sets GL flags.
*
* Since: 3.16
*/
void
gdk_gl_set_flags (GdkGLFlags flags)
{
_gdk_gl_flags = flags;
}
+3 -1
View File
@@ -43,9 +43,11 @@ GDK_AVAILABLE_IN_3_16
GType gdk_gl_context_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_3_16
GdkVisual * gdk_gl_context_get_visual (GdkGLContext *context);
GdkDisplay * gdk_gl_context_get_display (GdkGLContext *context);
GDK_AVAILABLE_IN_3_16
GdkWindow * gdk_gl_context_get_window (GdkGLContext *context);
GDK_AVAILABLE_IN_3_16
GdkGLProfile gdk_gl_context_get_profile (GdkGLContext *context);
GDK_AVAILABLE_IN_3_16
void gdk_gl_context_make_current (GdkGLContext *context);
+28 -9
View File
@@ -40,18 +40,37 @@ struct _GdkGLContextClass
{
GObjectClass parent_class;
void (* update) (GdkGLContext *context);
void (* flush_buffer) (GdkGLContext *context,
cairo_region_t *painted,
cairo_region_t *damage);
void (* end_frame) (GdkGLContext *context,
cairo_region_t *painted,
cairo_region_t *damage);
gboolean (* texture_from_surface) (GdkGLContext *context,
cairo_surface_t *surface,
cairo_region_t *region);
cairo_surface_t *surface,
cairo_region_t *region);
};
void gdk_gl_context_flush_buffer (GdkGLContext *context,
cairo_region_t *painted,
cairo_region_t *damage);
typedef struct {
guint vertex_array_object;
guint tmp_framebuffer;
guint tmp_vertex_buffer;
guint tmp_uv_buffer;
guint current_program;
guint texture_quad_program;
guint texture_quad_program_position_location;
guint texture_quad_program_uv_location;
guint texture_quad_program_map_location;
guint texture_quad_rect_program;
guint texture_quad_rect_program_position_location;
guint texture_quad_rect_program_uv_location;
guint texture_quad_rect_program_map_location;
} GdkGLContextPaintData;
GdkGLContextPaintData *gdk_gl_context_get_paint_data (GdkGLContext *context);
gboolean gdk_gl_context_use_texture_rectangle (GdkGLContext *context);
gboolean gdk_gl_context_has_framebuffer_blit (GdkGLContext *context);
gboolean gdk_gl_context_has_frame_terminator (GdkGLContext *context);
void gdk_gl_context_end_frame (GdkGLContext *context,
cairo_region_t *painted,
cairo_region_t *damage);
G_END_DECLS
+1
View File
@@ -34,4 +34,5 @@ GList *_gdk_default_filters = NULL;
gchar *_gdk_display_name = NULL;
gchar *_gdk_display_arg_name = NULL;
gboolean _gdk_disable_multidevice = FALSE;
guint _gdk_gl_flags = 0;
GdkRenderingMode _gdk_rendering_mode = GDK_RENDERING_MODE_SIMILAR;
+20 -3
View File
@@ -85,8 +85,7 @@ typedef enum {
GDK_DEBUG_EVENTLOOP = 1 << 10,
GDK_DEBUG_FRAMES = 1 << 11,
GDK_DEBUG_SETTINGS = 1 << 12,
GDK_DEBUG_NOGL = 1 << 13,
GDK_DEBUG_OPENGL = 1 << 14
GDK_DEBUG_OPENGL = 1 << 13,
} GdkDebugFlag;
typedef enum {
@@ -95,11 +94,21 @@ typedef enum {
GDK_RENDERING_MODE_RECORDING
} GdkRenderingMode;
typedef enum {
GDK_GL_DISABLE = 1 << 0,
GDK_GL_ALWAYS = 1 << 1,
GDK_GL_SOFTWARE_DRAW_GL = 1 << 2,
GDK_GL_SOFTWARE_DRAW_SURFACE = 1 << 3,
GDK_GL_TEXTURE_RECTANGLE = 1 << 4
} GdkGLFlags;
extern GList *_gdk_default_filters;
extern GdkWindow *_gdk_parent_root;
extern guint _gdk_debug_flags;
extern guint _gdk_gl_flags;
extern GdkRenderingMode _gdk_rendering_mode;
extern gboolean _gdk_debug_updates;
#ifdef G_ENABLE_DEBUG
@@ -341,6 +350,12 @@ gboolean _gdk_cairo_surface_extents (cairo_surface_t *surface,
GdkRectangle *extents);
void gdk_gl_texture_from_surface (cairo_surface_t *surface,
cairo_region_t *region);
void gdk_gl_texture_quad (GdkGLContext *paint_context,
guint texture_target,
float x1, float y1,
float x2, float y2,
float u1, float v1,
float u2, float v2);
void gdk_cairo_surface_mark_as_direct (cairo_surface_t *surface,
GdkWindow *window);
cairo_region_t *gdk_cairo_region_from_clip (cairo_t *cr);
@@ -360,7 +375,9 @@ void _gdk_window_update_size (GdkWindow *window);
gboolean _gdk_window_update_viewable (GdkWindow *window);
GdkGLContext * gdk_window_get_paint_gl_context (GdkWindow *window,
GError **error);
void gdk_window_get_unscaled_size (GdkWindow *window,
int *unscaled_width,
int *unscaled_height);
void _gdk_window_process_updates_recurse (GdkWindow *window,
cairo_region_t *expose_region);
+2 -2
View File
@@ -49,9 +49,9 @@ void gdk_init (gint *argc,
GDK_AVAILABLE_IN_ALL
gboolean gdk_init_check (gint *argc,
gchar ***argv);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_3_16
void gdk_add_option_entries_libgtk_only (GOptionGroup *group);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_3_16
void gdk_pre_parse_libgtk_only (void);
GDK_AVAILABLE_IN_ALL
+3 -1
View File
@@ -310,6 +310,7 @@ typedef enum
* @GDK_GRAB_NOT_VIEWABLE: the grab window or the @confine_to window are not
* viewable.
* @GDK_GRAB_FROZEN: the resource is frozen by an active grab of another client.
* @GDK_GRAB_FAILED: the grab failed for some other reason.
*
* Returned by gdk_device_grab(), gdk_pointer_grab() and gdk_keyboard_grab() to
* indicate success or the reason for the failure of the grab attempt.
@@ -320,7 +321,8 @@ typedef enum
GDK_GRAB_ALREADY_GRABBED = 1,
GDK_GRAB_INVALID_TIME = 2,
GDK_GRAB_NOT_VIEWABLE = 3,
GDK_GRAB_FROZEN = 4
GDK_GRAB_FROZEN = 4,
GDK_GRAB_FAILED = 5
} GdkGrabStatus;
/**
+122 -56
View File
@@ -40,6 +40,7 @@
#include "gdkframeclockidle.h"
#include "gdkwindowimpl.h"
#include "gdkglcontextprivate.h"
#include "gdk-private.h"
#include <math.h>
@@ -287,16 +288,11 @@ create_surface_accumulator (GSignalInvocationHint *ihint,
static GQuark quark_pointer_window = 0;
static gboolean always_use_gl = FALSE;
static void
gdk_window_class_init (GdkWindowClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
if (g_getenv ("GDK_ALWAYS_USE_GL"))
always_use_gl = TRUE;
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gdk_window_finalize;
@@ -1424,7 +1420,7 @@ gdk_window_new (GdkWindow *parent,
G_CALLBACK (device_removed_cb), window);
if (always_use_gl)
if ((_gdk_gl_flags & (GDK_GL_ALWAYS | GDK_GL_DISABLE)) == GDK_GL_ALWAYS)
{
GError *error = NULL;
@@ -1993,6 +1989,14 @@ _gdk_window_destroy_hierarchy (GdkWindow *window,
}
}
if (window->gl_paint_context)
{
/* Make sure to destroy if current */
g_object_run_dispose (G_OBJECT (window->gl_paint_context));
g_object_unref (window->gl_paint_context);
window->gl_paint_context = NULL;
}
if (window->frame_clock)
{
g_object_run_dispose (G_OBJECT (window->frame_clock));
@@ -2722,7 +2726,7 @@ gdk_window_ref_impl_surface (GdkWindow *window)
GdkGLContext *
gdk_window_get_paint_gl_context (GdkWindow *window, GError **error)
{
if (_gdk_debug_flags & GDK_DEBUG_NOGL)
if (_gdk_gl_flags & GDK_GL_DISABLE)
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_NOT_AVAILABLE,
@@ -2731,12 +2735,26 @@ gdk_window_get_paint_gl_context (GdkWindow *window, GError **error)
}
if (window->impl_window->gl_paint_context == NULL)
window->impl_window->gl_paint_context =
GDK_WINDOW_IMPL_GET_CLASS (window->impl)->create_gl_context (window,
TRUE,
GDK_GL_PROFILE_DEFAULT,
NULL,
error);
{
window->impl_window->gl_paint_context =
GDK_WINDOW_IMPL_GET_CLASS (window->impl)->create_gl_context (window,
TRUE,
GDK_GL_PROFILE_3_2_CORE,
NULL,
error);
if (window->impl_window->gl_paint_context == NULL &&
g_error_matches (*error, GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_PROFILE))
{
g_clear_error (error);
window->impl_window->gl_paint_context =
GDK_WINDOW_IMPL_GET_CLASS (window->impl)->create_gl_context (window,
TRUE,
GDK_GL_PROFILE_DEFAULT,
NULL,
error);
}
}
return window->impl_window->gl_paint_context;
}
@@ -2913,16 +2931,10 @@ gdk_window_begin_paint_region (GdkWindow *window,
glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
glDisable (GL_DEPTH_TEST);
glDisable(GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glViewport (0, 0, ww, wh);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho (0.0f, ww, 0.0f, wh, -1.0f, 1.0f);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
}
}
@@ -2933,9 +2945,7 @@ gdk_window_begin_paint_region (GdkWindow *window,
MAX (clip_box.width, 1),
MAX (clip_box.height, 1));
sx = sy = 1;
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
cairo_surface_get_device_scale (window->current_paint.surface, &sx, &sy);
#endif
cairo_surface_set_device_offset (window->current_paint.surface, -clip_box.x*sx, -clip_box.y*sy);
gdk_cairo_surface_mark_as_direct (window->current_paint.surface, window);
@@ -3009,6 +3019,7 @@ gdk_window_mark_paint_from_clip (GdkWindow *window,
cairo_region_subtract (impl_window->current_paint.flushed_region, clip_region);
cairo_region_union (impl_window->current_paint.need_blend_region, clip_region);
}
cairo_region_destroy (clip_region);
/* Clear the area on the double buffer surface to transparent so we
can start drawing from scratch the area "above" the flushed
@@ -3058,7 +3069,6 @@ gdk_window_end_paint (GdkWindow *window)
if (impl_class->end_paint)
impl_class->end_paint (window);
if (window->current_paint.surface_needs_composite)
{
cairo_surface_t *surface;
@@ -3086,14 +3096,11 @@ gdk_window_end_paint (GdkWindow *window)
cairo_region_destroy (opaque_region);
gdk_gl_context_flush_buffer (window->gl_paint_context,
window->current_paint.region,
window->active_update_area);
if (epoxy_has_gl_extension ("GL_GREMEDY_frame_terminator"))
glFrameTerminatorGREMEDY();
gdk_gl_context_end_frame (window->gl_paint_context,
window->current_paint.region,
window->active_update_area);
}
else
else if (!impl_class->do_composite (window))
{
surface = gdk_window_ref_impl_surface (window);
cr = cairo_create (surface);
@@ -3107,6 +3114,8 @@ gdk_window_end_paint (GdkWindow *window)
cairo_paint (cr);
cairo_destroy (cr);
cairo_surface_flush (surface);
}
}
@@ -3328,7 +3337,7 @@ gdk_cairo_create (GdkWindow *window)
/* Code for dirty-region queueing
*/
static GSList *update_windows = NULL;
static gboolean debug_updates = FALSE;
gboolean _gdk_debug_updates = FALSE;
static inline gboolean
gdk_window_is_ancestor (GdkWindow *window,
@@ -3603,7 +3612,9 @@ gdk_window_process_updates_internal (GdkWindow *window)
{
GdkWindowImplClass *impl_class;
GdkWindow *toplevel;
GdkDisplay *display;
display = gdk_window_get_display (window);
toplevel = gdk_window_get_toplevel (window);
if (toplevel->geometry_dirty)
{
@@ -3643,7 +3654,7 @@ gdk_window_process_updates_internal (GdkWindow *window)
/* Clip to part visible in impl window */
cairo_region_intersect (expose_region, window->clip_region);
if (debug_updates)
if (gdk_display_get_debug_updates (display))
{
cairo_region_t *swap_region = cairo_region_copy (expose_region);
cairo_region_subtract (swap_region, window->active_update_area);
@@ -4057,6 +4068,7 @@ gdk_window_invalidate_maybe_recurse_full (GdkWindow *window,
{
cairo_region_t *visible_region;
cairo_rectangle_int_t r;
GdkDisplay *display;
g_return_if_fail (GDK_IS_WINDOW (window));
@@ -4076,7 +4088,8 @@ gdk_window_invalidate_maybe_recurse_full (GdkWindow *window,
invalidate_impl_subwindows (window, region, child_func, user_data, 0, 0);
if (debug_updates)
display = gdk_window_get_display (window);
if (gdk_display_get_debug_updates (display))
draw_ugly_color (window, visible_region, 0);
while (window != NULL &&
@@ -4370,9 +4383,17 @@ gdk_window_thaw_updates (GdkWindow *window)
*
* This function is not part of the GDK public API and is only
* for use by GTK+.
**/
*
* Deprecated: 3.16: This symbol was never meant to be used outside of GTK+
*/
void
gdk_window_freeze_toplevel_updates_libgtk_only (GdkWindow *window)
{
gdk_window_freeze_toplevel_updates (window);
}
void
gdk_window_freeze_toplevel_updates (GdkWindow *window)
{
g_return_if_fail (GDK_IS_WINDOW (window));
g_return_if_fail (window->window_type != GDK_WINDOW_CHILD);
@@ -4390,9 +4411,17 @@ gdk_window_freeze_toplevel_updates_libgtk_only (GdkWindow *window)
*
* This function is not part of the GDK public API and is only
* for use by GTK+.
**/
*
* Deprecated: 3.16: This symbol was never meant to be used outside of GTK+
*/
void
gdk_window_thaw_toplevel_updates_libgtk_only (GdkWindow *window)
{
gdk_window_thaw_toplevel_updates (window);
}
void
gdk_window_thaw_toplevel_updates (GdkWindow *window)
{
g_return_if_fail (GDK_IS_WINDOW (window));
g_return_if_fail (window->window_type != GDK_WINDOW_CHILD);
@@ -4432,7 +4461,7 @@ gdk_window_thaw_toplevel_updates_libgtk_only (GdkWindow *window)
void
gdk_window_set_debug_updates (gboolean setting)
{
debug_updates = setting;
_gdk_debug_updates = setting;
}
/**
@@ -6014,6 +6043,9 @@ gdk_window_set_cursor_internal (GdkWindow *window,
if (GDK_WINDOW_DESTROYED (window))
return;
g_assert (gdk_window_get_display (window) == gdk_device_get_display (device));
g_assert (!cursor || gdk_window_get_display (window) == gdk_cursor_get_display (cursor));
if (window->window_type == GDK_WINDOW_ROOT ||
window->window_type == GDK_WINDOW_FOREIGN)
GDK_WINDOW_IMPL_GET_CLASS (window->impl)->set_device_cursor (window, device, cursor);
@@ -6059,11 +6091,15 @@ gdk_window_get_cursor (GdkWindow *window)
* @window: a #GdkWindow
* @cursor: (allow-none): a cursor
*
* Sets the default mouse pointer for a #GdkWindow. Use gdk_cursor_new_for_display()
* or gdk_cursor_new_from_pixbuf() to create the cursor. To make the cursor
* invisible, use %GDK_BLANK_CURSOR. Passing %NULL for the @cursor argument
* to gdk_window_set_cursor() means that @window will use the cursor of its
* parent window. Most windows should use this default.
* Sets the default mouse pointer for a #GdkWindow.
*
* Note that @cursor must be for the same display as @window.
*
* Use gdk_cursor_new_for_display() or gdk_cursor_new_from_pixbuf() to
* create the cursor. To make the cursor invisible, use %GDK_BLANK_CURSOR.
* Passing %NULL for the @cursor argument to gdk_window_set_cursor() means
* that @window will use the cursor of its parent window. Most windows
* should use this default.
*/
void
gdk_window_set_cursor (GdkWindow *window,
@@ -7992,9 +8028,9 @@ gdk_pointer_grab (GdkWindow * window,
gulong serial;
GList *devices, *dev;
g_return_val_if_fail (window != NULL, 0);
g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
g_return_val_if_fail (confine_to == NULL || GDK_IS_WINDOW (confine_to), 0);
g_return_val_if_fail (window != NULL, GDK_GRAB_FAILED);
g_return_val_if_fail (GDK_IS_WINDOW (window), GDK_GRAB_FAILED);
g_return_val_if_fail (confine_to == NULL || GDK_IS_WINDOW (confine_to), GDK_GRAB_FAILED);
/* We need a native window for confine to to work, ensure we have one */
if (confine_to)
@@ -8104,7 +8140,7 @@ gdk_keyboard_grab (GdkWindow *window,
gulong serial;
GList *devices, *dev;
g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
g_return_val_if_fail (GDK_IS_WINDOW (window), GDK_GRAB_FAILED);
/* Non-viewable client side window => fail */
if (!_gdk_window_has_impl (window) &&
@@ -9415,6 +9451,7 @@ gdk_window_create_similar_surface (GdkWindow * window,
int width,
int height)
{
GdkDisplay *display;
cairo_surface_t *window_surface, *surface;
double sx, sy;
@@ -9422,28 +9459,23 @@ gdk_window_create_similar_surface (GdkWindow * window,
window_surface = gdk_window_ref_impl_surface (window);
sx = sy = 1;
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
cairo_surface_get_device_scale (window_surface, &sx, &sy);
#endif
switch (_gdk_rendering_mode)
display = gdk_window_get_display (window);
switch (display->rendering_mode)
{
case GDK_RENDERING_MODE_RECORDING:
{
cairo_rectangle_t rect = { 0, 0, width * sx, height *sy };
surface = cairo_recording_surface_create (content, &rect);
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
cairo_surface_set_device_scale (surface, sx, sy);
#endif
}
break;
case GDK_RENDERING_MODE_IMAGE:
surface = cairo_image_surface_create (content == CAIRO_CONTENT_COLOR ? CAIRO_FORMAT_RGB24 :
content == CAIRO_CONTENT_ALPHA ? CAIRO_FORMAT_A8 : CAIRO_FORMAT_ARGB32,
width * sx, height * sy);
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
cairo_surface_set_device_scale (surface, sx, sy);
#endif
break;
case GDK_RENDERING_MODE_SIMILAR:
default:
@@ -9521,12 +9553,10 @@ gdk_window_create_similar_image_surface (GdkWindow * window,
cairo_surface_destroy (window_surface);
}
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
if (scale == 0)
scale = gdk_window_get_scale_factor (window);
cairo_surface_set_device_scale (surface, scale, scale);
#endif
return surface;
}
@@ -10523,7 +10553,12 @@ gdk_window_configure_finished (GdkWindow *window)
*
* For toplevel windows this depends on support from the windowing system
* that may not always be there. For instance, On X11, this works only on
* X screens with a compositing manager running.
* X screens with a compositing manager running. On Wayland, there is no
* per-window opacity value that the compositor would apply. Instead, use
* `gdk_window_set_opaque_region (window, NULL)` to tell the compositor
* that the entire window is (potentially) non-opaque, and draw your content
* with alpha, or use gtk_widget_set_opacity() to set an overall opacity
* for your widgets.
*
* For child windows this function only works for non-native windows.
*
@@ -11009,6 +11044,37 @@ gdk_window_get_scale_factor (GdkWindow *window)
return 1;
}
/* Returns the *real* unscaled size, which may be a fractional size
in window scale coordinates. We need this to properly handle GL
coordinates which are y-flipped in the real coordinates. */
void
gdk_window_get_unscaled_size (GdkWindow *window,
int *unscaled_width,
int *unscaled_height)
{
GdkWindowImplClass *impl_class;
gint scale;
g_return_if_fail (GDK_IS_WINDOW (window));
if (window->impl_window == window)
{
impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl);
if (impl_class->get_unscaled_size)
return impl_class->get_unscaled_size (window, unscaled_width, unscaled_height);
}
scale = gdk_window_get_scale_factor (window);
if (unscaled_width)
*unscaled_width = window->width * scale;
if (unscaled_height)
*unscaled_height = window->height * scale;
}
/**
* gdk_window_set_opaque_region:
* @window: a top-level or non-native #GdkWindow
+2 -2
View File
@@ -1037,9 +1037,9 @@ void gdk_window_freeze_updates (GdkWindow *window);
GDK_AVAILABLE_IN_ALL
void gdk_window_thaw_updates (GdkWindow *window);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_3_16
void gdk_window_freeze_toplevel_updates_libgtk_only (GdkWindow *window);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_3_16
void gdk_window_thaw_toplevel_updates_libgtk_only (GdkWindow *window);
GDK_AVAILABLE_IN_ALL
+7
View File
@@ -46,11 +46,18 @@ gdk_window_impl_process_updates_recurse (GdkWindow *window,
_gdk_window_process_updates_recurse (window, region);
}
static gboolean
gdk_window_impl_do_composite (GdkWindow *window)
{
return FALSE;
}
static void
gdk_window_impl_class_init (GdkWindowImplClass *impl_class)
{
impl_class->beep = gdk_window_impl_beep;
impl_class->process_updates_recurse = gdk_window_impl_process_updates_recurse;
impl_class->do_composite = gdk_window_impl_do_composite;
}
static void
+4
View File
@@ -279,6 +279,9 @@ struct _GdkWindowImplClass
GdkAtom property);
gint (* get_scale_factor) (GdkWindow *window);
void (* get_unscaled_size) (GdkWindow *window,
int *unscaled_width,
int *unscaled_height);
void (* set_opaque_region) (GdkWindow *window,
cairo_region_t *region);
@@ -296,6 +299,7 @@ struct _GdkWindowImplClass
GError **error);
void (*invalidate_for_new_frame)(GdkWindow *window,
cairo_region_t *update_area);
gboolean (*do_composite) (GdkWindow *window);
};
/* Interface Functions */
+1
View File
@@ -24,6 +24,7 @@ libgdk_mir_la_SOURCES = \
gdkmirdevicemanager.c \
gdkmirdisplay.c \
gdkmireventsource.c \
gdkmirglcontext.c \
gdkmirkeyboard.c \
gdkmirkeymap.c \
gdkmirpointer.c \
+49 -1
View File
@@ -18,10 +18,13 @@
#ifndef __GDK_PRIVATE_MIR_H__
#define __GDK_PRIVATE_MIR_H__
#include <epoxy/egl.h>
#include "gdkmir.h"
#include "gdkdisplay.h"
#include "gdkscreen.h"
#include "gdkdevicemanager.h"
#include "gdkglcontextprivate.h"
#include "gdkkeys.h"
#include "gdkwindowimpl.h"
@@ -35,6 +38,27 @@ typedef struct _GdkMirEventSource GdkMirEventSource;
GType gdk_mir_window_impl_get_type (void);
struct _GdkMirGLContext
{
GdkGLContext parent_instance;
EGLContext egl_context;
EGLConfig egl_config;
gboolean is_attached;
};
struct _GdkMirGLContextClass
{
GdkGLContextClass parent_class;
};
typedef struct _GdkMirGLContext GdkMirGLContext;
typedef struct _GdkMirGLContextClass GdkMirGLContextClass;
#define GDK_MIR_GL_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_MIR_GL_CONTEXT, GdkMirGLContext))
GdkDisplay *_gdk_mir_display_open (const gchar *display_name);
GdkScreen *_gdk_mir_screen_new (GdkDisplay *display);
@@ -51,12 +75,18 @@ GdkDevice *_gdk_mir_pointer_new (GdkDeviceManager *device_manager, const gchar *
void _gdk_mir_pointer_set_location (GdkDevice *pointer, gdouble x, gdouble y, GdkWindow *window, GdkModifierType mask);
GdkCursor *_gdk_mir_cursor_new (GdkDisplay *display, GdkCursorType type);
GdkCursor *_gdk_mir_cursor_new_for_type (GdkDisplay *display, GdkCursorType type);
GdkCursor *_gdk_mir_cursor_new_for_name (GdkDisplay *display, const gchar *name);
const gchar *_gdk_mir_cursor_get_name (GdkCursor *cursor);
GdkWindowImpl *_gdk_mir_window_impl_new (void);
void _gdk_mir_window_impl_set_surface_state (GdkMirWindowImpl *impl, MirSurfaceState state);
void _gdk_mir_window_impl_set_surface_type (GdkMirWindowImpl *impl, MirSurfaceType type);
void _gdk_mir_window_impl_set_cursor_state (GdkMirWindowImpl *impl, gdouble x, gdouble y, gboolean cursor_inside, MirMotionButton button_state);
void _gdk_mir_window_impl_get_cursor_state (GdkMirWindowImpl *impl, gdouble *x, gdouble *y, gboolean *cursor_inside, MirMotionButton *button_state);
@@ -71,6 +101,24 @@ void _gdk_mir_window_reference_unref (GdkMirWindowReference *ref);
void _gdk_mir_event_source_queue (GdkMirWindowReference *window_ref, const MirEvent *event);
MirPixelFormat _gdk_mir_display_get_pixel_format (GdkDisplay *display, MirBufferUsage usage);
gboolean _gdk_mir_display_init_egl_display (GdkDisplay *display);
EGLDisplay _gdk_mir_display_get_egl_display (GdkDisplay *display);
gboolean _gdk_mir_display_have_egl_khr_create_context (GdkDisplay *display);
gboolean _gdk_mir_display_have_egl_buffer_age (GdkDisplay *display);
gboolean _gdk_mir_display_have_egl_swap_buffers_with_damage (GdkDisplay *display);
gboolean _gdk_mir_display_have_egl_surfaceless_context (GdkDisplay *display);
EGLSurface _gdk_mir_window_get_egl_surface (GdkWindow *window, EGLConfig config);
EGLSurface _gdk_mir_window_get_dummy_egl_surface (GdkWindow *window, EGLConfig config);
void _gdk_mir_print_modifiers (unsigned int modifiers);
void _gdk_mir_print_key_event (const MirKeyEvent *event);
+12 -3
View File
@@ -24,16 +24,25 @@
#define GDK_TYPE_MIR_DISPLAY (gdk_mir_display_get_type ())
#define GDK_IS_MIR_DISPLAY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_DISPLAY))
#define GDK_TYPE_MIR_WINDOW (gdk_mir_window_get_type ())
#define GDK_IS_WINDOW_MIR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WINDOW_MIR))
#define GDK_TYPE_MIR_GL_CONTEXT (gdk_mir_gl_context_get_type ())
#define GDK_MIR_IS_GL_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_MIR_GL_CONTEXT))
#define GDK_TYPE_MIR_WINDOW (gdk_mir_window_get_type ())
#define GDK_IS_MIR_WINDOW(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_WINDOW))
GDK_AVAILABLE_IN_3_10
GType gdk_mir_display_get_type (void);
GDK_AVAILABLE_IN_3_10
struct MirConnection *gdk_mir_display_get_mir_connection (GdkDisplay *display);
MirConnection *gdk_mir_display_get_mir_connection (GdkDisplay *display);
GDK_AVAILABLE_IN_3_10
GType gdk_mir_window_get_type (void);
GDK_AVAILABLE_IN_3_16
MirSurface *gdk_mir_window_get_mir_surface (GdkWindow *window);
GDK_AVAILABLE_IN_3_16
GType gdk_mir_gl_context_get_type (void) G_GNUC_CONST;
#endif /* __GDK_MIR_H__ */
+107 -3
View File
@@ -35,6 +35,8 @@ typedef struct GdkMirCursorClass GdkMirCursorClass;
struct GdkMirCursor
{
GdkCursor parent_instance;
gchar *name;
};
struct GdkMirCursorClass
@@ -44,10 +46,100 @@ struct GdkMirCursorClass
G_DEFINE_TYPE (GdkMirCursor, gdk_mir_cursor, GDK_TYPE_CURSOR)
GdkCursor *
_gdk_mir_cursor_new (GdkDisplay *display, GdkCursorType type)
static const gchar *
get_cursor_name_for_cursor_type (GdkCursorType cursor_type)
{
return g_object_new (GDK_TYPE_MIR_CURSOR, "display", display, "cursor-type", type, NULL);
switch (cursor_type)
{
case GDK_BLANK_CURSOR:
return mir_disabled_cursor_name;
case GDK_X_CURSOR:
case GDK_ARROW:
case GDK_CENTER_PTR:
case GDK_DRAFT_LARGE:
case GDK_DRAFT_SMALL:
case GDK_LEFT_PTR:
case GDK_RIGHT_PTR:
case GDK_TOP_LEFT_ARROW:
return mir_arrow_cursor_name;
case GDK_CLOCK:
case GDK_WATCH:
return mir_busy_cursor_name;
case GDK_XTERM:
return mir_caret_cursor_name;
case GDK_HAND1:
case GDK_HAND2:
return mir_pointing_hand_cursor_name;
return mir_open_hand_cursor_name;
case GDK_FLEUR:
return mir_closed_hand_cursor_name;
case GDK_LEFT_SIDE:
case GDK_LEFT_TEE:
case GDK_RIGHT_SIDE:
case GDK_RIGHT_TEE:
case GDK_SB_LEFT_ARROW:
case GDK_SB_RIGHT_ARROW:
return mir_horizontal_resize_cursor_name;
case GDK_BASED_ARROW_DOWN:
case GDK_BASED_ARROW_UP:
case GDK_BOTTOM_SIDE:
case GDK_BOTTOM_TEE:
case GDK_DOUBLE_ARROW:
case GDK_SB_DOWN_ARROW:
case GDK_SB_UP_ARROW:
case GDK_TOP_SIDE:
case GDK_TOP_TEE:
return mir_vertical_resize_cursor_name;
case GDK_BOTTOM_LEFT_CORNER:
case GDK_LL_ANGLE:
case GDK_TOP_RIGHT_CORNER:
case GDK_UR_ANGLE:
return mir_diagonal_resize_bottom_to_top_cursor_name;
case GDK_BOTTOM_RIGHT_CORNER:
case GDK_LR_ANGLE:
case GDK_SIZING:
case GDK_TOP_LEFT_CORNER:
case GDK_UL_ANGLE:
return mir_diagonal_resize_top_to_bottom_cursor_name;
return mir_omnidirectional_resize_cursor_name;
case GDK_SB_V_DOUBLE_ARROW:
return mir_vsplit_resize_cursor_name;
case GDK_SB_H_DOUBLE_ARROW:
return mir_hsplit_resize_cursor_name;
default:
return mir_default_cursor_name;
}
}
GdkCursor *
_gdk_mir_cursor_new_for_name (GdkDisplay *display, const gchar *name)
{
GdkMirCursor *cursor;
cursor = g_object_new (GDK_TYPE_MIR_CURSOR, "display", display, "cursor-type", GDK_CURSOR_IS_PIXMAP, NULL);
cursor->name = g_strdup (name);
return GDK_CURSOR (cursor);
}
GdkCursor *
_gdk_mir_cursor_new_for_type (GdkDisplay *display, GdkCursorType type)
{
GdkMirCursor *cursor;
cursor = g_object_new (GDK_TYPE_MIR_CURSOR, "display", display, "cursor-type", type, NULL);
cursor->name = g_strdup (get_cursor_name_for_cursor_type (type));
return GDK_CURSOR (cursor);
}
const gchar *
_gdk_mir_cursor_get_name (GdkCursor *cursor)
{
GdkMirCursor *mir_cursor = GDK_MIR_CURSOR (cursor);
return mir_cursor->name;
}
cairo_surface_t *
@@ -64,10 +156,22 @@ gdk_mir_cursor_init (GdkMirCursor *cursor)
{
}
static void
gdk_mir_cursor_finalize (GObject *object)
{
GdkMirCursor *mir_cursor = GDK_MIR_CURSOR (object);
g_free (mir_cursor->name);
G_OBJECT_CLASS (gdk_mir_cursor_parent_class)->finalize (object);
}
static void
gdk_mir_cursor_class_init (GdkMirCursorClass *klass)
{
GdkCursorClass *cursor_class = GDK_CURSOR_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
cursor_class->get_surface = gdk_mir_cursor_get_surface;
object_class->finalize = gdk_mir_cursor_finalize;
}
+189 -26
View File
@@ -45,9 +45,16 @@ typedef struct GdkMirDisplay
/* Screen information */
GdkScreen *screen;
GdkCursor *cursor;
GdkKeymap *keymap;
MirPixelFormat sw_pixel_format;
MirPixelFormat hw_pixel_format;
EGLDisplay egl_display;
guint have_egl_khr_create_context : 1;
guint have_egl_buffer_age : 1;
guint have_egl_swap_buffers_with_damage : 1;
guint have_egl_surfaceless_context : 1;
} GdkMirDisplay;
typedef struct GdkMirDisplayClass
@@ -55,6 +62,8 @@ typedef struct GdkMirDisplayClass
GdkDisplayClass parent_class;
} GdkMirDisplayClass;
static void initialize_pixel_formats (GdkMirDisplay *display);
/**
* SECTION:mir_interaction
* @Short_description: Mir backend-specific functions
@@ -114,6 +123,7 @@ _gdk_mir_display_open (const gchar *display_name)
display->connection = connection;
GDK_DISPLAY (display)->device_manager = _gdk_mir_device_manager_new (GDK_DISPLAY (display));
display->screen = _gdk_mir_screen_new (GDK_DISPLAY (display));
initialize_pixel_formats (display);
g_signal_emit_by_name (display, "opened");
@@ -317,18 +327,14 @@ static GdkCursor *
gdk_mir_display_get_cursor_for_type (GdkDisplay *display,
GdkCursorType cursor_type)
{
//g_printerr ("gdk_mir_display_get_cursor_for_type (%u)\n", cursor_type);
/* We don't support configurable cursors */
return g_object_ref (GDK_MIR_DISPLAY (display)->cursor);
return _gdk_mir_cursor_new_for_type (display, cursor_type);
}
static GdkCursor *
gdk_mir_display_get_cursor_for_name (GdkDisplay *display,
const gchar *name)
{
g_printerr ("gdk_mir_display_get_cursor_for_name (\"%s\")\n", name);
/* We don't support configurable cursors */
return g_object_ref (GDK_MIR_DISPLAY (display)->cursor);
return _gdk_mir_cursor_new_for_name (display, name);
}
static GdkCursor *
@@ -382,21 +388,6 @@ gdk_mir_display_notify_startup_complete (GdkDisplay *display,
//g_printerr ("gdk_mir_display_notify_startup_complete\n");
}
static void
gdk_mir_display_event_data_copy (GdkDisplay *display,
const GdkEvent *src,
GdkEvent *dst)
{
//g_printerr ("gdk_mir_display_event_data_copy\n");
}
static void
gdk_mir_display_event_data_free (GdkDisplay *display,
GdkEvent *event)
{
//g_printerr ("gdk_mir_display_event_data_free\n");
}
static void
gdk_mir_display_create_window_impl (GdkDisplay *display,
GdkWindow *window,
@@ -508,11 +499,184 @@ gdk_mir_display_utf8_to_string_target (GdkDisplay *display,
return NULL;
}
static void
initialize_pixel_formats (GdkMirDisplay *display)
{
MirPixelFormat formats[mir_pixel_formats];
unsigned int n_formats, i;
mir_connection_get_available_surface_formats (display->connection, formats,
mir_pixel_formats, &n_formats);
display->sw_pixel_format = mir_pixel_format_invalid;
display->hw_pixel_format = mir_pixel_format_invalid;
for (i = 0; i < n_formats; i++)
{
switch (formats[i])
{
case mir_pixel_format_abgr_8888:
case mir_pixel_format_xbgr_8888:
case mir_pixel_format_argb_8888:
case mir_pixel_format_xrgb_8888:
display->hw_pixel_format = formats[i];
break;
default:
continue;
}
if (display->hw_pixel_format != mir_pixel_format_invalid)
break;
}
for (i = 0; i < n_formats; i++)
{
if (formats[i] == mir_pixel_format_argb_8888)
{
display->sw_pixel_format = formats[i];
break;
}
}
}
MirPixelFormat
_gdk_mir_display_get_pixel_format (GdkDisplay *display,
MirBufferUsage usage)
{
GdkMirDisplay *mir_dpy = GDK_MIR_DISPLAY (display);
if (usage == mir_buffer_usage_hardware)
return mir_dpy->hw_pixel_format;
return mir_dpy->sw_pixel_format;
}
gboolean
_gdk_mir_display_init_egl_display (GdkDisplay *display)
{
GdkMirDisplay *mir_dpy = GDK_MIR_DISPLAY (display);
EGLint major_version, minor_version;
EGLDisplay *dpy;
if (mir_dpy->egl_display)
return TRUE;
dpy = eglGetDisplay (mir_connection_get_egl_native_display (mir_dpy->connection));
if (dpy == NULL)
return FALSE;
if (!eglInitialize (dpy, &major_version, &minor_version))
return FALSE;
if (!eglBindAPI (EGL_OPENGL_API))
return FALSE;
mir_dpy->egl_display = dpy;
mir_dpy->have_egl_khr_create_context =
epoxy_has_egl_extension (dpy, "EGL_KHR_create_context");
mir_dpy->have_egl_buffer_age =
epoxy_has_egl_extension (dpy, "EGL_EXT_buffer_age");
mir_dpy->have_egl_swap_buffers_with_damage =
epoxy_has_egl_extension (dpy, "EGL_EXT_swap_buffers_with_damage");
mir_dpy->have_egl_surfaceless_context =
epoxy_has_egl_extension (dpy, "EGL_KHR_surfaceless_context");
GDK_NOTE (OPENGL,
g_print ("EGL API version %d.%d found\n"
" - Vendor: %s\n"
" - Version: %s\n"
" - Client APIs: %s\n"
" - Extensions:\n"
"\t%s\n",
major_version,
minor_version,
eglQueryString (dpy, EGL_VENDOR),
eglQueryString (dpy, EGL_VERSION),
eglQueryString (dpy, EGL_CLIENT_APIS),
eglQueryString (dpy, EGL_EXTENSIONS)));
return TRUE;
}
static gboolean
gdk_mir_display_make_gl_context_current (GdkDisplay *display,
GdkGLContext *context)
{
EGLDisplay egl_display = _gdk_mir_display_get_egl_display (display);
GdkMirGLContext *mir_context;
GdkWindow *window;
EGLSurface egl_surface;
if (context == NULL)
{
eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
return TRUE;
}
mir_context = GDK_MIR_GL_CONTEXT (context);
window = gdk_gl_context_get_window (context);
if (mir_context->is_attached)
{
egl_surface = _gdk_mir_window_get_egl_surface (window,
mir_context->egl_config);
}
else
{
if (_gdk_mir_display_have_egl_surfaceless_context (display))
egl_surface = EGL_NO_SURFACE;
else
egl_surface = _gdk_mir_window_get_dummy_egl_surface (window,
mir_context->egl_config);
}
if (!eglMakeCurrent (egl_display, egl_surface, egl_surface, mir_context->egl_context))
{
g_warning ("eglMakeCurrent failed");
return FALSE;
}
return TRUE;
}
EGLDisplay _gdk_mir_display_get_egl_display (GdkDisplay *display)
{
return GDK_MIR_DISPLAY (display)->egl_display;
}
gboolean _gdk_mir_display_have_egl_khr_create_context (GdkDisplay *display)
{
return GDK_MIR_DISPLAY (display)->have_egl_khr_create_context;
}
gboolean _gdk_mir_display_have_egl_buffer_age (GdkDisplay *display)
{
/* FIXME: this is not really supported by mir yet (despite is advertised) */
// return GDK_MIR_DISPLAY (display)->have_egl_buffer_age;
return FALSE;
}
gboolean _gdk_mir_display_have_egl_swap_buffers_with_damage (GdkDisplay *display)
{
/* FIXME: this is not really supported by mir yet (despite is advertised) */
// return GDK_MIR_DISPLAY (display)->have_egl_swap_buffers_with_damage;
return FALSE;
}
gboolean _gdk_mir_display_have_egl_surfaceless_context (GdkDisplay *display)
{
return GDK_MIR_DISPLAY (display)->have_egl_surfaceless_context;
}
static void
gdk_mir_display_init (GdkMirDisplay *display)
{
display->event_source = _gdk_mir_event_source_new (GDK_DISPLAY (display));
display->cursor = _gdk_mir_cursor_new (GDK_DISPLAY (display), GDK_ARROW);
display->keymap = _gdk_mir_keymap_new ();
}
@@ -556,8 +720,6 @@ gdk_mir_display_class_init (GdkMirDisplayClass *klass)
display_class->after_process_all_updates = gdk_mir_display_after_process_all_updates;
display_class->get_next_serial = gdk_mir_display_get_next_serial;
display_class->notify_startup_complete = gdk_mir_display_notify_startup_complete;
display_class->event_data_copy = gdk_mir_display_event_data_copy;
display_class->event_data_free = gdk_mir_display_event_data_free;
display_class->create_window_impl = gdk_mir_display_create_window_impl;
display_class->get_keymap = gdk_mir_display_get_keymap;
display_class->push_error_trap = gdk_mir_display_push_error_trap;
@@ -569,4 +731,5 @@ gdk_mir_display_class_init (GdkMirDisplayClass *klass)
display_class->convert_selection = gdk_mir_display_convert_selection;
display_class->text_property_to_utf8_list = gdk_mir_display_text_property_to_utf8_list;
display_class->utf8_to_string_target = gdk_mir_display_utf8_to_string_target;
display_class->make_gl_context_current = gdk_mir_display_make_gl_context_current;
}
+11 -4
View File
@@ -162,8 +162,8 @@ generate_scroll_event (GdkWindow *window, gdouble x, gdouble y, gdouble delta_x,
event->scroll.y = y;
event->scroll.state = state;
event->scroll.direction = GDK_SCROLL_SMOOTH;
event->scroll.delta_x = delta_x;
event->scroll.delta_y = delta_y;
event->scroll.delta_x = -delta_x;
event->scroll.delta_y = -delta_y;
send_event (window, get_pointer (window), event);
}
@@ -311,7 +311,7 @@ handle_motion_event (GdkWindow *window, const MirMotionEvent *event)
case mir_motion_action_up:
event_type = event->action == mir_motion_action_down ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE;
changed_button_state = button_state ^ event->button_state;
if ((changed_button_state & mir_motion_button_primary) != 0)
if (changed_button_state == 0 || (changed_button_state & mir_motion_button_primary) != 0)
generate_button_event (window, event_type, x, y, GDK_BUTTON_PRIMARY, modifier_state);
if ((changed_button_state & mir_motion_button_secondary) != 0)
generate_button_event (window, event_type, x, y, GDK_BUTTON_SECONDARY, modifier_state);
@@ -343,6 +343,7 @@ handle_surface_event (GdkWindow *window, const MirSurfaceEvent *event)
switch (event->attrib)
{
case mir_surface_attrib_type:
_gdk_mir_window_impl_set_surface_type (impl, event->value);
break;
case mir_surface_attrib_state:
_gdk_mir_window_impl_set_surface_state (impl, event->value);
@@ -413,8 +414,14 @@ gdk_mir_event_source_queue_event (GdkDisplay *display,
case mir_event_type_resize:
handle_resize_event (window, &event->resize);
break;
case mir_event_type_prompt_session_state_change:
// FIXME?
break;
case mir_event_type_orientation:
// FIXME?
break;
default:
g_assert_not_reached ();
g_warning ("Ignoring unknown Mir event %d", event->type);
// FIXME?
break;
}
+106
View File
@@ -0,0 +1,106 @@
/* GDK - The GIMP Drawing Kit
*
* gdkmirglcontext.c: Mir specific OpenGL wrappers
*
* Copyright © 2014 Canonical Ltd
*
* 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/>.
*/
#include "config.h"
#include "gdkmir-private.h"
#include "gdkinternals.h"
#include "gdkintl.h"
G_DEFINE_TYPE (GdkMirGLContext, gdk_mir_gl_context, GDK_TYPE_GL_CONTEXT)
static void
gdk_mir_gl_context_end_frame (GdkGLContext *context,
cairo_region_t *painted,
cairo_region_t *damage)
{
GdkWindow *window = gdk_gl_context_get_window (context);
GdkDisplay *display = gdk_window_get_display (window);
GdkMirGLContext *context_mir = GDK_MIR_GL_CONTEXT (context);
EGLDisplay egl_display = _gdk_mir_display_get_egl_display (display);
EGLSurface egl_surface;
gdk_gl_context_make_current (context);
egl_surface = _gdk_mir_window_get_egl_surface (window,
context_mir->egl_config);
if (_gdk_mir_display_have_egl_swap_buffers_with_damage (display))
{
int i, j, n_rects = cairo_region_num_rectangles (damage);
EGLint *rects = g_new (EGLint, n_rects * 4);
cairo_rectangle_int_t rect;
int window_height = gdk_window_get_height (window);
for (i = 0, j = 0; i < n_rects; i++)
{
cairo_region_get_rectangle (damage, i, &rect);
rects[j++] = rect.x;
rects[j++] = window_height - rect.height - rect.y;
rects[j++] = rect.width;
rects[j++] = rect.height;
}
eglSwapBuffersWithDamageEXT (egl_display, egl_surface, rects, n_rects);
g_free (rects);
}
else
{
eglSwapBuffers (egl_display, egl_surface);
}
}
static void
gdk_mir_gl_context_dispose (GObject *gobject)
{
GdkMirGLContext *context_mir = GDK_MIR_GL_CONTEXT (gobject);
if (context_mir->egl_context != NULL)
{
GdkGLContext *context = GDK_GL_CONTEXT (gobject);
GdkWindow *window = gdk_gl_context_get_window (context);
GdkDisplay *display = gdk_window_get_display (window);
EGLDisplay egl_display = _gdk_mir_display_get_egl_display (display);
if (eglGetCurrentContext () == context_mir->egl_context)
eglMakeCurrent (egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
GDK_NOTE (OPENGL, g_print ("Destroying EGL context\n"));
eglDestroyContext (egl_display, context_mir->egl_context);
context_mir->egl_context = NULL;
}
G_OBJECT_CLASS (gdk_mir_gl_context_parent_class)->dispose (gobject);
}
static void
gdk_mir_gl_context_class_init (GdkMirGLContextClass *klass)
{
GdkGLContextClass *context_class = GDK_GL_CONTEXT_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
context_class->end_frame = gdk_mir_gl_context_end_frame;
gobject_class->dispose = gdk_mir_gl_context_dispose;
}
static void
gdk_mir_gl_context_init (GdkMirGLContext *self)
{
}
+98 -14
View File
@@ -94,6 +94,29 @@ get_screen_size (MirDisplayConfiguration *config, gint *width, gint *height)
}
}
static void
get_screen_size_mm (MirDisplayConfiguration *config, gint *width, gint *height)
{
uint32_t i;
*width = 0;
*height = 0;
if (!config)
return;
for (i = 0; i < config->num_outputs; i++)
{
MirDisplayOutput *o = &config->outputs[i];
if (!o->used)
continue;
*width += o->physical_width_mm;
*height += o->physical_height_mm;
}
}
static void
update_display_config (GdkMirScreen *screen)
{
@@ -124,7 +147,7 @@ _gdk_mir_screen_new (GdkDisplay *display)
screen = g_object_new (GDK_TYPE_MIR_SCREEN, NULL);
screen->display = display;
mir_connection_set_display_config_change_callback (get_connection (screen), config_changed_cb, display);
mir_connection_set_display_config_change_callback (get_connection (screen), config_changed_cb, screen);
update_display_config (screen);
return GDK_SCREEN (screen);
@@ -139,6 +162,13 @@ gdk_mir_screen_dispose (GObject *object)
static void
gdk_mir_screen_finalize (GObject *object)
{
GdkMirScreen *screen = GDK_MIR_SCREEN (object);
mir_connection_set_display_config_change_callback (get_connection (screen), NULL, NULL);
mir_display_config_destroy (screen->display_config);
g_clear_object (&screen->visual);
g_clear_object (&screen->root_window);
G_OBJECT_CLASS (gdk_mir_screen_parent_class)->finalize (object);
}
@@ -192,16 +222,18 @@ static gint
gdk_mir_screen_get_width_mm (GdkScreen *screen)
{
g_printerr ("gdk_mir_screen_get_width_mm\n");
// FIXME: A combination of all screens?
return get_output (screen, 0)->physical_width_mm;
gint width, height;
get_screen_size_mm (GDK_MIR_SCREEN (screen)->display_config, &width, &height);
return width;
}
static gint
gdk_mir_screen_get_height_mm (GdkScreen *screen)
{
g_printerr ("gdk_mir_screen_get_height_mm\n");
// FIXME: A combination of all screens?
return get_output (screen, 0)->physical_height_mm;
gint width, height;
get_screen_size_mm (GDK_MIR_SCREEN (screen)->display_config, &width, &height);
return height;
}
static gint
@@ -253,7 +285,7 @@ gdk_mir_screen_get_n_monitors (GdkScreen *screen)
for (i = 0; i < config->num_outputs; i++)
if (config->outputs[i].used)
count++;
++count;
return count;
}
@@ -270,7 +302,8 @@ gdk_mir_screen_get_monitor_width_mm (GdkScreen *screen,
gint monitor_num)
{
g_printerr ("gdk_mir_screen_get_monitor_width_mm (%d)\n", monitor_num);
return get_output (screen, monitor_num)->physical_width_mm;
MirDisplayOutput *output = get_output (screen, monitor_num);
return output ? output->physical_width_mm : 0;
}
static gint
@@ -278,7 +311,8 @@ gdk_mir_screen_get_monitor_height_mm (GdkScreen *screen,
gint monitor_num)
{
g_printerr ("gdk_mir_screen_get_monitor_height_mm (%d)\n", monitor_num);
return get_output (screen, monitor_num)->physical_height_mm;
MirDisplayOutput *output = get_output (screen, monitor_num);
return output ? output->physical_height_mm : 0;
}
static gchar *
@@ -286,7 +320,46 @@ gdk_mir_screen_get_monitor_plug_name (GdkScreen *screen,
gint monitor_num)
{
g_printerr ("gdk_mir_screen_get_monitor_plug_name (%d)\n", monitor_num);
return NULL; //?
MirDisplayOutput *output = get_output (screen, monitor_num);
if (output)
{
switch (output->type)
{
case mir_display_output_type_unknown:
return g_strdup_printf ("UNKNOWN-%u", output->output_id);
case mir_display_output_type_vga:
return g_strdup_printf ("VGA-%u", output->output_id);
case mir_display_output_type_dvii:
return g_strdup_printf ("DVII-%u", output->output_id);
case mir_display_output_type_dvid:
return g_strdup_printf ("DVID-%u", output->output_id);
case mir_display_output_type_dvia:
return g_strdup_printf ("DVIA-%u", output->output_id);
case mir_display_output_type_composite:
return g_strdup_printf ("COMPOSITE-%u", output->output_id);
case mir_display_output_type_svideo:
return g_strdup_printf ("SVIDEO-%u", output->output_id);
case mir_display_output_type_lvds:
return g_strdup_printf ("LVDS-%u", output->output_id);
case mir_display_output_type_component:
return g_strdup_printf ("COMPONENT-%u", output->output_id);
case mir_display_output_type_ninepindin:
return g_strdup_printf ("NINEPINDIN-%u", output->output_id);
case mir_display_output_type_displayport:
return g_strdup_printf ("DISPLAYPORT-%u", output->output_id);
case mir_display_output_type_hdmia:
return g_strdup_printf ("HDMIA-%u", output->output_id);
case mir_display_output_type_hdmib:
return g_strdup_printf ("HDMIB-%u", output->output_id);
case mir_display_output_type_tv:
return g_strdup_printf ("TV-%u", output->output_id);
case mir_display_output_type_edp:
return g_strdup_printf ("EDP-%u", output->output_id);
}
}
return NULL;
}
static void
@@ -299,11 +372,22 @@ gdk_mir_screen_get_monitor_geometry (GdkScreen *screen,
MirDisplayMode *mode;
output = get_output (screen, monitor_num);
mode = &output->modes[output->current_mode];
dest->x = output->position_x;
dest->y = output->position_y;
dest->width = mode->horizontal_resolution;
dest->height = mode->vertical_resolution;
if (output)
{
mode = &output->modes[output->current_mode];
dest->x = output->position_x;
dest->y = output->position_y;
dest->width = mode->horizontal_resolution;
dest->height = mode->vertical_resolution;
}
else
{
dest->x = 0;
dest->y = 0;
dest->width = 0;
dest->height = 0;
}
}
static void
+457 -72
View File
@@ -25,6 +25,7 @@
#include "gdkwindowimpl.h"
#include "gdkinternals.h"
#include "gdkintl.h"
#include "gdkdisplayprivate.h"
#include "gdkdeviceprivate.h"
@@ -32,6 +33,8 @@
#define GDK_IS_WINDOW_IMPL_MIR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WINDOW_IMPL_MIR))
#define GDK_MIR_WINDOW_IMPL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WINDOW_IMPL_MIR, GdkMirWindowImplClass))
#define MAX_EGL_ATTRS 30
typedef struct _GdkMirWindowImplClass GdkMirWindowImplClass;
struct _GdkMirWindowImpl
@@ -47,7 +50,7 @@ struct _GdkMirWindowImpl
GList *transient_children;
/* Desired surface attributes */
MirSurfaceType surface_type; // FIXME
MirSurfaceType surface_type;
MirSurfaceState surface_state;
/* Pattern for background */
@@ -64,6 +67,13 @@ struct _GdkMirWindowImpl
/* Cairo context for current frame */
cairo_surface_t *cairo_surface;
/* Egl surface for the current mir surface */
EGLSurface egl_surface;
/* Dummy MIR and EGL surfaces */
MirSurface *dummy_surface;
EGLSurface dummy_egl_surface;
/* TRUE if the window can be seen */
gboolean visible;
@@ -92,6 +102,12 @@ _gdk_mir_window_impl_set_surface_state (GdkMirWindowImpl *impl, MirSurfaceState
impl->surface_state = state;
}
void
_gdk_mir_window_impl_set_surface_type (GdkMirWindowImpl *impl, MirSurfaceType type)
{
impl->surface_type = type;
}
void
_gdk_mir_window_impl_set_cursor_state (GdkMirWindowImpl *impl,
gdouble x,
@@ -125,23 +141,34 @@ _gdk_mir_window_impl_get_cursor_state (GdkMirWindowImpl *impl,
static void
gdk_mir_window_impl_init (GdkMirWindowImpl *impl)
{
}
static MirConnection *
get_connection (GdkWindow *window)
{
return gdk_mir_display_get_mir_connection (gdk_window_get_display (window));
impl->surface_type = mir_surface_type_normal;
impl->surface_state = mir_surface_state_unknown;
}
static void
set_surface_state (GdkMirWindowImpl *impl,
MirSurfaceState state)
{
if (impl->surface_state == state)
return;
impl->surface_state = state;
if (impl->surface)
mir_surface_set_state (impl->surface, state);
}
static void
set_surface_type (GdkMirWindowImpl *impl,
MirSurfaceType type)
{
if (impl->surface_type == type)
return;
impl->surface_type = type;
if (impl->surface)
mir_surface_set_type (impl->surface, type);
}
static void
event_cb (MirSurface *surface,
const MirEvent *event,
@@ -150,13 +177,32 @@ event_cb (MirSurface *surface,
_gdk_mir_event_source_queue (context, event);
}
static MirSurface *
create_mir_surface (GdkDisplay *display,
gint width,
gint height,
MirBufferUsage buffer_usage)
{
MirSurfaceParameters parameters;
MirConnection *connection;
parameters.name = "GTK+ Mir";
parameters.width = width;
parameters.height = height;
parameters.pixel_format = _gdk_mir_display_get_pixel_format (display, buffer_usage);
parameters.buffer_usage = buffer_usage;
parameters.output_id = mir_display_output_id_invalid;
connection = gdk_mir_display_get_mir_connection (display);
return mir_connection_create_surface_sync (connection, &parameters);
}
static void
ensure_surface (GdkWindow *window)
ensure_surface_full (GdkWindow *window,
MirBufferUsage buffer_usage)
{
GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
MirPixelFormat formats[100], pixel_format = mir_pixel_format_invalid;
unsigned int n_formats, i;
MirSurfaceParameters parameters;
MirEventDelegate event_delegate = { event_cb, NULL };
GdkMirWindowReference *window_ref;
@@ -170,41 +216,33 @@ ensure_surface (GdkWindow *window)
event_delegate.context = window_ref;
// Should probably calculate this once?
// Should prefer certain formats over others
mir_connection_get_available_surface_formats (get_connection (window), formats, 100, &n_formats);
for (i = 0; i < n_formats; i++)
if (formats[i] == mir_pixel_format_argb_8888)
{
pixel_format = formats[i];
break;
}
impl->surface = create_mir_surface (gdk_window_get_display (window),
window->width, window->height,
buffer_usage);
parameters.name = "GTK+ Mir";
parameters.width = window->width;
parameters.height = window->height;
parameters.pixel_format = pixel_format;
parameters.buffer_usage = mir_buffer_usage_software;
parameters.output_id = mir_display_output_id_invalid;
impl->surface = mir_connection_create_surface_sync (get_connection (window), &parameters);
MirGraphicsRegion region;
MirEvent resize_event;
mir_surface_get_graphics_region (impl->surface, &region);
/* Send the initial configure with the size the server gave... */
resize_event.resize.type = mir_event_type_resize;
resize_event.resize.surface_id = 0;
resize_event.resize.width = region.width;
resize_event.resize.height = region.height;
resize_event.resize.width = window->width;
resize_event.resize.height = window->height;
_gdk_mir_event_source_queue (window_ref, &resize_event);
mir_surface_set_event_handler (impl->surface, &event_delegate); // FIXME: Ignore some events until shown
set_surface_type (impl, impl->surface_type);
set_surface_state (impl, impl->surface_state);
}
static void
ensure_surface (GdkWindow *window)
{
ensure_surface_full (window, window->gl_paint_context ?
mir_buffer_usage_hardware :
mir_buffer_usage_software);
}
static void
ensure_no_surface (GdkWindow *window)
{
@@ -213,15 +251,30 @@ ensure_no_surface (GdkWindow *window)
if (impl->cairo_surface)
{
cairo_surface_finish (impl->cairo_surface);
cairo_surface_destroy (impl->cairo_surface);
impl->cairo_surface = NULL;
g_clear_pointer (&impl->cairo_surface, cairo_surface_destroy);
}
if (impl->surface)
if (window->gl_paint_context)
{
mir_surface_release_sync (impl->surface);
impl->surface = NULL;
GdkDisplay *display = gdk_window_get_display (window);
EGLDisplay egl_display = _gdk_mir_display_get_egl_display (display);
if (impl->egl_surface)
{
eglDestroySurface (egl_display, impl->egl_surface);
impl->egl_surface = NULL;
}
if (impl->dummy_egl_surface)
{
eglDestroySurface (egl_display, impl->dummy_egl_surface);
impl->dummy_egl_surface = NULL;
}
g_clear_pointer (&impl->dummy_surface, mir_surface_release_sync);
}
g_clear_pointer(&impl->surface, mir_surface_release_sync);
}
static void
@@ -279,11 +332,7 @@ send_buffer (GdkWindow *window)
mir_surface_swap_buffers_sync (impl->surface);
/* The Cairo context is no longer valid */
if (impl->cairo_surface)
{
cairo_surface_destroy (impl->cairo_surface);
impl->cairo_surface = NULL;
}
g_clear_pointer (&impl->cairo_surface, cairo_surface_destroy);
}
static cairo_surface_t *
@@ -292,7 +341,7 @@ gdk_mir_window_impl_ref_cairo_surface (GdkWindow *window)
//g_printerr ("gdk_mir_window_impl_ref_cairo_surface window=%p\n", window);
GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
MirGraphicsRegion region;
cairo_format_t pixel_format = CAIRO_FORMAT_INVALID;
cairo_format_t pixel_format = CAIRO_FORMAT_ARGB32;
cairo_surface_t *cairo_surface;
cairo_t *c;
@@ -303,31 +352,16 @@ gdk_mir_window_impl_ref_cairo_surface (GdkWindow *window)
}
/* Transient windows get rendered into a buffer and copied onto their parent */
if (impl->transient_for)
if (impl->transient_for || window->gl_paint_context)
{
cairo_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, window->width, window->height);
cairo_surface = cairo_image_surface_create (pixel_format, window->width, window->height);
}
else
{
ensure_surface (window);
mir_surface_get_graphics_region (impl->surface, &region);
// FIXME: Should calculate this once
switch (region.pixel_format)
{
case mir_pixel_format_argb_8888:
pixel_format = CAIRO_FORMAT_ARGB32;
break;
default:
case mir_pixel_format_abgr_8888:
case mir_pixel_format_xbgr_8888:
case mir_pixel_format_xrgb_8888:
case mir_pixel_format_bgr_888:
// uh-oh...
g_printerr ("Unsupported pixel format %d\n", region.pixel_format);
break;
}
g_assert (region.pixel_format == mir_pixel_format_argb_8888);
cairo_surface = cairo_image_surface_create_for_data ((unsigned char *) region.vaddr,
pixel_format,
@@ -397,10 +431,13 @@ gdk_mir_window_impl_show (GdkWindow *window,
/* Make sure there's a surface to see */
ensure_surface (window);
/* Make sure something is rendered and then show first frame */
s = gdk_mir_window_impl_ref_cairo_surface (window);
send_buffer (window);
cairo_surface_destroy (s);
if (!window->gl_paint_context)
{
/* Make sure something is rendered and then show first frame */
s = gdk_mir_window_impl_ref_cairo_surface (window);
send_buffer (window);
cairo_surface_destroy (s);
}
}
static void
@@ -557,8 +594,25 @@ gdk_mir_window_impl_set_device_cursor (GdkWindow *window,
GdkDevice *device,
GdkCursor *cursor)
{
//g_printerr ("gdk_mir_window_impl_set_device_cursor window=%p\n", window);
/* We don't support cursors yet... */
const gchar *cursor_name;
MirCursorConfiguration *configuration;
if (cursor)
cursor_name = _gdk_mir_cursor_get_name (cursor);
else
cursor_name = mir_default_cursor_name;
configuration = mir_cursor_configuration_from_name (cursor_name);
if (configuration)
{
GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
if (impl->surface)
mir_surface_configure_cursor (impl->surface, configuration);
mir_cursor_configuration_destroy (configuration);
}
}
static void
@@ -625,7 +679,7 @@ gdk_mir_window_impl_end_paint (GdkWindow *window)
GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
//g_printerr ("gdk_mir_window_impl_end_paint window=%p\n", window);
if (impl->visible)
if (impl->visible && !window->current_paint.use_gl)
send_buffer (window);
}
@@ -700,14 +754,70 @@ static void
gdk_mir_window_impl_set_type_hint (GdkWindow *window,
GdkWindowTypeHint hint)
{
//g_printerr ("gdk_mir_window_impl_set_type_hint window=%p\n", window);
// FIXME: ?
MirSurfaceType mir_type = mir_surface_type_normal;
switch (hint)
{
case GDK_WINDOW_TYPE_HINT_NORMAL:
case GDK_WINDOW_TYPE_HINT_DOCK:
case GDK_WINDOW_TYPE_HINT_DESKTOP:
mir_type = mir_surface_type_normal;
break;
case GDK_WINDOW_TYPE_HINT_DIALOG:
mir_type = mir_surface_type_dialog;
break;
case GDK_WINDOW_TYPE_HINT_UTILITY:
mir_type = mir_surface_type_utility;
break;
case GDK_WINDOW_TYPE_HINT_MENU:
case GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU:
case GDK_WINDOW_TYPE_HINT_POPUP_MENU:
case GDK_WINDOW_TYPE_HINT_COMBO:
mir_type = mir_surface_type_menu;
break;
case GDK_WINDOW_TYPE_HINT_TOOLTIP:
mir_type = mir_surface_type_tip;
break;
case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
case GDK_WINDOW_TYPE_HINT_DND:
case GDK_WINDOW_TYPE_HINT_NOTIFICATION:
mir_type = mir_surface_type_overlay;
break;
case GDK_WINDOW_TYPE_HINT_TOOLBAR:
mir_type = mir_surface_type_satellite;
break;
}
set_surface_type (GDK_MIR_WINDOW_IMPL (window->impl), mir_type);
}
static GdkWindowTypeHint
gdk_mir_window_impl_get_type_hint (GdkWindow *window)
{
g_printerr ("gdk_mir_window_impl_get_type_hint window=%p\n", window);
GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
switch (impl->surface_type)
{
case mir_surface_type_normal:
case mir_surface_type_freestyle:
case mir_surface_type_inputmethod:
return GDK_WINDOW_TYPE_HINT_NORMAL;
case mir_surface_type_utility:
return GDK_WINDOW_TYPE_HINT_UTILITY;
case mir_surface_type_dialog:
return GDK_WINDOW_TYPE_HINT_DIALOG;
case mir_surface_type_tip:
return GDK_WINDOW_TYPE_HINT_TOOLTIP;
case mir_surface_type_menu:
return GDK_WINDOW_TYPE_HINT_MENU;
case mir_surface_type_overlay:
return GDK_WINDOW_TYPE_HINT_NOTIFICATION;
case mir_surface_type_satellite:
return GDK_WINDOW_TYPE_HINT_TOOLBAR;
case mir_surface_types:
break;
}
return GDK_WINDOW_TYPE_HINT_NORMAL;
}
@@ -1148,6 +1258,279 @@ gdk_mir_window_impl_set_shadow_width (GdkWindow *window,
g_printerr ("gdk_mir_window_impl_set_shadow_width window=%p\n", window);
}
static gboolean
find_eglconfig_for_window (GdkWindow *window,
EGLConfig *egl_config_out,
GError **error)
{
GdkDisplay *display = gdk_window_get_display (window);
EGLDisplay *egl_display = _gdk_mir_display_get_egl_display (display);
GdkVisual *visual = gdk_window_get_visual (window);
EGLint attrs[MAX_EGL_ATTRS];
EGLint count;
EGLConfig *configs;
gboolean use_rgba;
int i = 0;
attrs[i++] = EGL_SURFACE_TYPE;
attrs[i++] = EGL_WINDOW_BIT;
attrs[i++] = EGL_COLOR_BUFFER_TYPE;
attrs[i++] = EGL_RGB_BUFFER;
attrs[i++] = EGL_RED_SIZE;
attrs[i++] = 1;
attrs[i++] = EGL_GREEN_SIZE;
attrs[i++] = 1;
attrs[i++] = EGL_BLUE_SIZE;
attrs[i++] = 1;
use_rgba = (visual == gdk_screen_get_rgba_visual (gdk_display_get_default_screen (display)));
if (use_rgba)
{
attrs[i++] = EGL_ALPHA_SIZE;
attrs[i++] = 1;
}
else
{
attrs[i++] = EGL_ALPHA_SIZE;
attrs[i++] = 0;
}
attrs[i++] = EGL_NONE;
g_assert (i < MAX_EGL_ATTRS);
if (!eglChooseConfig (egl_display, attrs, NULL, 0, &count) || count < 1)
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_FORMAT,
_("No available configurations for the given pixel format"));
return FALSE;
}
configs = g_new (EGLConfig, count);
if (!eglChooseConfig (egl_display, attrs, configs, count, &count) || count < 1)
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_FORMAT,
_("No available configurations for the given pixel format"));
return FALSE;
}
/* Pick first valid configuration i guess? */
if (egl_config_out != NULL)
*egl_config_out = configs[0];
g_free (configs);
return TRUE;
}
static GdkGLContext *
gdk_mir_window_impl_create_gl_context (GdkWindow *window,
gboolean attached,
GdkGLProfile profile,
GdkGLContext *share,
GError **error)
{
GdkDisplay *display = gdk_window_get_display (window);
GdkMirGLContext *context;
EGLContext ctx;
EGLConfig config;
int i;
EGLint context_attribs[3];
if (!_gdk_mir_display_init_egl_display (display))
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_NOT_AVAILABLE,
_("No GL implementation is available"));
return NULL;
}
if (profile == GDK_GL_PROFILE_DEFAULT)
profile = GDK_GL_PROFILE_LEGACY;
if (profile == GDK_GL_PROFILE_3_2_CORE &&
!_gdk_mir_display_have_egl_khr_create_context (display))
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
_("3.2 core GL profile is not available on EGL implementation"));
return NULL;
}
if (!find_eglconfig_for_window (window, &config, error))
return NULL;
i = 0;
if (profile == GDK_GL_PROFILE_3_2_CORE)
{
context_attribs[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
context_attribs[i++] = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
}
context_attribs[i++] = EGL_NONE;
ctx = eglCreateContext (_gdk_mir_display_get_egl_display (display),
config,
share ? GDK_MIR_GL_CONTEXT (share)->egl_context : EGL_NO_CONTEXT,
context_attribs);
if (ctx == NULL)
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_NOT_AVAILABLE,
_("Unable to create a GL context"));
return NULL;
}
GDK_NOTE (OPENGL,
g_print ("Created EGL context[%p]\n", ctx));
context = g_object_new (GDK_TYPE_MIR_GL_CONTEXT,
"display", display,
"window", window,
"profile", profile,
"shared-context", share,
NULL);
context->egl_config = config;
context->egl_context = ctx;
context->is_attached = attached;
return GDK_GL_CONTEXT (context);
}
static void
gdk_mir_window_impl_invalidate_for_new_frame (GdkWindow *window,
cairo_region_t *update_area)
{
cairo_rectangle_int_t window_rect;
GdkDisplay *display = gdk_window_get_display (window);
GdkMirGLContext *context_mir;
int buffer_age;
gboolean invalidate_all;
EGLSurface egl_surface;
/* Minimal update is ok if we're not drawing with gl */
if (window->gl_paint_context == NULL)
return;
context_mir = GDK_MIR_GL_CONTEXT (window->gl_paint_context);
buffer_age = 0;
egl_surface = _gdk_mir_window_get_egl_surface (window, context_mir->egl_config);
if (_gdk_mir_display_have_egl_buffer_age (display))
{
gdk_gl_context_make_current (window->gl_paint_context);
eglQuerySurface (_gdk_mir_display_get_egl_display (display), egl_surface,
EGL_BUFFER_AGE_EXT, &buffer_age);
}
invalidate_all = FALSE;
if (buffer_age == 0 || buffer_age >= 4)
invalidate_all = TRUE;
else
{
if (buffer_age >= 2)
{
if (window->old_updated_area[0])
cairo_region_union (update_area, window->old_updated_area[0]);
else
invalidate_all = TRUE;
}
if (buffer_age >= 3)
{
if (window->old_updated_area[1])
cairo_region_union (update_area, window->old_updated_area[1]);
else
invalidate_all = TRUE;
}
}
if (invalidate_all)
{
window_rect.x = 0;
window_rect.y = 0;
window_rect.width = gdk_window_get_width (window);
window_rect.height = gdk_window_get_height (window);
/* If nothing else is known, repaint everything so that the back
buffer is fully up-to-date for the swapbuffer */
cairo_region_union_rectangle (update_area, &window_rect);
}
}
EGLSurface
_gdk_mir_window_get_egl_surface (GdkWindow *window,
EGLConfig config)
{
GdkMirWindowImpl *impl;
impl = GDK_MIR_WINDOW_IMPL (window->impl);
if (!impl->egl_surface)
{
EGLDisplay egl_display;
EGLNativeWindowType egl_window;
ensure_no_surface (window);
ensure_surface_full (window, mir_buffer_usage_hardware);
egl_display = _gdk_mir_display_get_egl_display (gdk_window_get_display (window));
egl_window = (EGLNativeWindowType) mir_surface_get_egl_native_window (impl->surface);
impl->egl_surface =
eglCreateWindowSurface (egl_display, config, egl_window, NULL);
}
return impl->egl_surface;
}
EGLSurface
_gdk_mir_window_get_dummy_egl_surface (GdkWindow *window,
EGLConfig config)
{
GdkMirWindowImpl *impl;
impl = GDK_MIR_WINDOW_IMPL (window->impl);
if (!impl->dummy_egl_surface)
{
GdkDisplay *display;
EGLDisplay egl_display;
EGLNativeWindowType egl_window;
display = gdk_window_get_display (window);
impl->dummy_surface = create_mir_surface (display, 1, 1,
mir_buffer_usage_hardware);
egl_display = _gdk_mir_display_get_egl_display (display);
egl_window = (EGLNativeWindowType) mir_surface_get_egl_native_window (impl->surface);
impl->dummy_egl_surface =
eglCreateWindowSurface (egl_display, config, egl_window, NULL);
}
return impl->dummy_egl_surface;
}
MirSurface *
gdk_mir_window_get_mir_surface (GdkWindow *window)
{
GdkMirWindowImpl *impl;
g_return_val_if_fail (GDK_IS_MIR_WINDOW (window), NULL);
impl = GDK_MIR_WINDOW_IMPL (window->impl);
return impl->surface;
}
static void
gdk_mir_window_impl_class_init (GdkMirWindowImplClass *klass)
{
@@ -1236,4 +1619,6 @@ gdk_mir_window_impl_class_init (GdkMirWindowImplClass *klass)
impl_class->get_scale_factor = gdk_mir_window_impl_get_scale_factor;
impl_class->set_opaque_region = gdk_mir_window_impl_set_opaque_region;
impl_class->set_shadow_width = gdk_mir_window_impl_set_shadow_width;
impl_class->create_gl_context = gdk_mir_window_impl_create_gl_context;
impl_class->invalidate_for_new_frame = gdk_mir_window_impl_invalidate_for_new_frame;
}
+4
View File
@@ -654,6 +654,8 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
_gdk_quartz_drag_source_context = NULL;
}
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
- (void)setStyleMask:(NSUInteger)styleMask
{
gboolean was_fullscreen;
@@ -669,4 +671,6 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
_gdk_quartz_window_update_fullscreen_state ([[self contentView] gdkWindow]);
}
#endif
@end
+3
View File
@@ -42,7 +42,10 @@
-(BOOL)trackManualResize;
-(void)showAndMakeKey:(BOOL)makeKey;
-(void)hide;
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
-(void)setStyleMask:(NSUInteger)styleMask;
#endif
@end
+6 -6
View File
@@ -44,12 +44,6 @@ static GSList *main_window_stack;
void _gdk_quartz_window_flush (GdkWindowImplQuartz *window_impl);
#ifndef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
static FullscreenSavedGeometry *get_fullscreen_geometry (GdkWindow *window);
#endif
#define FULLSCREEN_DATA "fullscreen-data"
typedef struct
{
gint x, y;
@@ -58,6 +52,12 @@ typedef struct
} FullscreenSavedGeometry;
#ifndef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
static FullscreenSavedGeometry *get_fullscreen_geometry (GdkWindow *window);
#endif
#define FULLSCREEN_DATA "fullscreen-data"
static void update_toplevel_order (void);
static void clear_toplevel_order (void);
+3 -7
View File
@@ -308,13 +308,9 @@ _gdk_wayland_display_get_cursor_for_surface (GdkDisplay *display,
if (surface)
{
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
{
double sx, sy;
cairo_surface_get_device_scale (surface, &sx, &sy);
cursor->surface.scale = (int)sx;
}
#endif
double sx, sy;
cairo_surface_get_device_scale (surface, &sx, &sy);
cursor->surface.scale = (int)sx;
cursor->surface.width = cairo_image_surface_get_width (surface);
cursor->surface.height = cairo_image_surface_get_height (surface);
}
+46 -5
View File
@@ -538,12 +538,48 @@ _gdk_wayland_device_get_keymap (GdkDevice *device)
return GDK_WAYLAND_DEVICE (device)->device->keymap;
}
static void
emit_selection_owner_change (GdkWindow *window,
GdkAtom atom)
{
GdkEvent *event;
event = gdk_event_new (GDK_OWNER_CHANGE);
event->owner_change.window = g_object_ref (window);
event->owner_change.owner = NULL;
event->owner_change.reason = GDK_OWNER_CHANGE_NEW_OWNER;
event->owner_change.selection = atom;
event->owner_change.time = GDK_CURRENT_TIME;
event->owner_change.selection_time = GDK_CURRENT_TIME;
gdk_event_put (event);
gdk_event_free (event);
}
static void
emit_selection_owner_change_forall (GdkAtom atom)
{
GdkDisplay *display = gdk_display_get_default ();
GdkScreen *screen = GDK_WAYLAND_DISPLAY (display)->screen;
GList *windows, *l;
windows = gdk_screen_get_toplevel_windows (screen);
for (l = windows; l; l = l->next)
emit_selection_owner_change (l->data, atom);
g_list_free (windows);
}
static void
data_device_data_offer (void *data,
struct wl_data_device *data_device,
struct wl_data_offer *_offer)
{
gdk_wayland_selection_set_offer (_offer);
GdkWaylandDeviceData *device = (GdkWaylandDeviceData *)data;
gdk_wayland_selection_set_offer (device->display, _offer);
emit_selection_owner_change_forall (gdk_atom_intern_static_string ("GdkWaylandSelection"));
}
static void
@@ -573,7 +609,7 @@ data_device_enter (void *data,
gdk_wayland_drop_context_update_targets (device->drop_context);
dnd_owner = gdk_selection_owner_get (gdk_drag_get_selection (device->drop_context));
dnd_owner = gdk_selection_owner_get_for_display (device->display, gdk_drag_get_selection (device->drop_context));
if (dnd_owner)
_gdk_wayland_drag_context_set_source_window (device->drop_context, dnd_owner);
@@ -585,7 +621,9 @@ data_device_enter (void *data,
wl_fixed_to_double (y));
_gdk_wayland_drag_context_emit_event (device->drop_context, GDK_DRAG_ENTER,
GDK_CURRENT_TIME);
gdk_wayland_selection_set_offer (offer);
gdk_wayland_selection_set_offer (device->display, offer);
emit_selection_owner_change (dest_window,
gdk_atom_intern_static_string ("GdkWaylandSelection"));
}
static void
@@ -645,7 +683,7 @@ data_device_drop (void *data,
g_debug (G_STRLOC ": %s data_device = %p",
G_STRFUNC, data_device);
local_dnd_owner = gdk_selection_owner_get (gdk_drag_get_selection (device->drop_context));
local_dnd_owner = gdk_selection_owner_get_for_display (device->display, gdk_drag_get_selection (device->drop_context));
if (local_dnd_owner)
{
@@ -664,10 +702,13 @@ data_device_selection (void *data,
struct wl_data_device *wl_data_device,
struct wl_data_offer *offer)
{
GdkWaylandDeviceData *device = (GdkWaylandDeviceData *) data;
g_debug (G_STRLOC ": %s wl_data_device = %p wl_data_offer = %p",
G_STRFUNC, wl_data_device, offer);
gdk_wayland_selection_set_offer (offer);
gdk_wayland_selection_set_offer (device->display, offer);
emit_selection_owner_change_forall (gdk_atom_intern_static_string ("CLIPBOARD"));
}
static const struct wl_data_device_listener data_device_listener = {
-18
View File
@@ -432,19 +432,6 @@ gdk_wayland_display_notify_startup_complete (GdkDisplay *display,
{
}
static void
gdk_wayland_display_event_data_copy (GdkDisplay *display,
const GdkEvent *src,
GdkEvent *dst)
{
}
static void
gdk_wayland_display_event_data_free (GdkDisplay *display,
GdkEvent *event)
{
}
static GdkKeymap *
_gdk_wayland_display_get_keymap (GdkDisplay *display)
{
@@ -535,8 +522,6 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass * class)
display_class->after_process_all_updates = gdk_wayland_display_after_process_all_updates;
display_class->get_next_serial = gdk_wayland_display_get_next_serial;
display_class->notify_startup_complete = gdk_wayland_display_notify_startup_complete;
display_class->event_data_copy = gdk_wayland_display_event_data_copy;
display_class->event_data_free = gdk_wayland_display_event_data_free;
display_class->create_window_impl = _gdk_wayland_display_create_window_impl;
display_class->get_keymap = _gdk_wayland_display_get_keymap;
display_class->push_error_trap = gdk_wayland_display_push_error_trap;
@@ -549,7 +534,6 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass * class)
display_class->text_property_to_utf8_list = _gdk_wayland_display_text_property_to_utf8_list;
display_class->utf8_to_string_target = _gdk_wayland_display_utf8_to_string_target;
display_class->destroy_gl_context = gdk_wayland_display_destroy_gl_context;
display_class->make_gl_context_current = gdk_wayland_display_make_gl_context_current;
}
@@ -816,9 +800,7 @@ _gdk_wayland_display_create_shm_surface (GdkWaylandDisplay *display,
cairo_surface_set_user_data (surface, &gdk_wayland_cairo_key,
data, gdk_wayland_cairo_surface_destroy);
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
cairo_surface_set_device_scale (surface, scale, scale);
#endif
status = cairo_surface_status (surface);
if (status != CAIRO_STATUS_SUCCESS)
+14 -11
View File
@@ -65,12 +65,13 @@ gdk_wayland_drag_context_finalize (GObject *object)
{
GdkWaylandDragContext *wayland_context = GDK_WAYLAND_DRAG_CONTEXT (object);
GdkDragContext *context = GDK_DRAG_CONTEXT (object);
GdkDisplay *display = gdk_window_get_display (context->source_window);
contexts = g_list_remove (contexts, context);
if (context->is_source &&
gdk_selection_owner_get (gdk_drag_get_selection (context)) == context->source_window)
gdk_wayland_selection_unset_data_source (gdk_drag_get_selection (context));
gdk_selection_owner_get_for_display (display, gdk_drag_get_selection (context)) == context->source_window)
gdk_wayland_selection_unset_data_source (display, gdk_drag_get_selection (context));
if (wayland_context->data_source)
wl_data_source_destroy (wayland_context->data_source);
@@ -191,10 +192,12 @@ gdk_wayland_drop_context_set_status (GdkDragContext *context,
gboolean accepted)
{
GdkWaylandDragContext *context_wayland;
GdkDisplay *display;
struct wl_data_offer *wl_offer;
context_wayland = GDK_WAYLAND_DRAG_CONTEXT (context);
wl_offer = gdk_wayland_selection_get_offer ();
display = gdk_window_get_display (context->source_window);
wl_offer = gdk_wayland_selection_get_offer (display);
if (!wl_offer)
return;
@@ -241,8 +244,10 @@ gdk_wayland_drag_context_drop_finish (GdkDragContext *context,
gboolean success,
guint32 time)
{
if (gdk_selection_owner_get (gdk_drag_get_selection (context)))
gdk_wayland_selection_unset_data_source (gdk_drag_get_selection (context));
GdkDisplay *display = gdk_window_get_display (context->source_window);
if (gdk_selection_owner_get_for_display (display, gdk_drag_get_selection (context)))
gdk_wayland_selection_unset_data_source (display, gdk_drag_get_selection (context));
}
static gboolean
@@ -301,14 +306,11 @@ _gdk_wayland_window_register_dnd (GdkWindow *window)
}
static GdkWindow *
create_dnd_window (void)
create_dnd_window (GdkScreen *screen)
{
GdkWindowAttr attrs;
GdkScreen *screen;
guint mask;
screen = gdk_display_get_default_screen (gdk_display_get_default ());
attrs.x = attrs.y = 0;
attrs.width = attrs.height = 100;
attrs.wclass = GDK_INPUT_OUTPUT;
@@ -343,7 +345,7 @@ _gdk_wayland_window_drag_begin (GdkWindow *window,
gdk_drag_context_set_device (context, device);
display_wayland = GDK_WAYLAND_DISPLAY (gdk_device_get_display (device));
context_wayland->dnd_window = create_dnd_window ();
context_wayland->dnd_window = create_dnd_window (gdk_window_get_screen (window));
context_wayland->dnd_surface = gdk_wayland_window_get_wl_surface (context_wayland->dnd_window);
context_wayland->data_source =
gdk_wayland_selection_get_data_source (window,
@@ -380,8 +382,9 @@ _gdk_wayland_drop_context_new (GdkDevice *device,
void
gdk_wayland_drop_context_update_targets (GdkDragContext *context)
{
GdkDisplay *display = gdk_window_get_display (context->source_window);
g_list_free (context->targets);
context->targets = g_list_copy (gdk_wayland_selection_get_targets ());
context->targets = g_list_copy (gdk_wayland_selection_get_targets (display));
}
void
+35 -36
View File
@@ -35,23 +35,7 @@
G_DEFINE_TYPE (GdkWaylandGLContext, gdk_wayland_gl_context, GDK_TYPE_GL_CONTEXT)
static void
gdk_wayland_gl_context_update (GdkGLContext *context)
{
GdkWindow *window = gdk_gl_context_get_window (context);
int width, height;
gdk_gl_context_make_current (context);
width = gdk_window_get_width (window);
height = gdk_window_get_height (window);
GDK_NOTE (OPENGL, g_print ("Updating GL viewport size to { %d, %d } for window %p (context: %p)\n",
width, height,
window, context));
glViewport (0, 0, width, height);
}
static void gdk_x11_gl_context_dispose (GObject *gobject);
void
gdk_wayland_window_invalidate_for_new_frame (GdkWindow *window,
@@ -117,9 +101,9 @@ gdk_wayland_window_invalidate_for_new_frame (GdkWindow *window,
}
static void
gdk_wayland_gl_context_flush_buffer (GdkGLContext *context,
cairo_region_t *painted,
cairo_region_t *damage)
gdk_wayland_gl_context_end_frame (GdkGLContext *context,
cairo_region_t *painted,
cairo_region_t *damage)
{
GdkWindow *window = gdk_gl_context_get_window (context);
GdkDisplay *display = gdk_window_get_display (window);
@@ -159,9 +143,10 @@ static void
gdk_wayland_gl_context_class_init (GdkWaylandGLContextClass *klass)
{
GdkGLContextClass *context_class = GDK_GL_CONTEXT_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
context_class->update = gdk_wayland_gl_context_update;
context_class->flush_buffer = gdk_wayland_gl_context_flush_buffer;
context_class->end_frame = gdk_wayland_gl_context_end_frame;
gobject_class->dispose = gdk_x11_gl_context_dispose;
}
static void
@@ -249,11 +234,11 @@ find_eglconfig_for_window (GdkWindow *window,
attrs[i++] = EGL_RGB_BUFFER;
attrs[i++] = EGL_RED_SIZE;
attrs[i++] = gdk_visual_get_bits_per_rgb (visual);
attrs[i++] = 1;
attrs[i++] = EGL_GREEN_SIZE;
attrs[i++] = gdk_visual_get_bits_per_rgb (visual);
attrs[i++] = 1;
attrs[i++] = EGL_BLUE_SIZE;
attrs[i++] = gdk_visual_get_bits_per_rgb (visual);
attrs[i++] = 1;
use_rgba = (visual == gdk_screen_get_rgba_visual (gdk_display_get_default_screen (display)));
@@ -322,6 +307,9 @@ gdk_wayland_window_create_gl_context (GdkWindow *window,
return NULL;
}
if (profile == GDK_GL_PROFILE_DEFAULT)
profile = GDK_GL_PROFILE_LEGACY;
if (profile == GDK_GL_PROFILE_3_2_CORE &&
!display_wayland->have_egl_khr_create_context)
{
@@ -358,8 +346,10 @@ gdk_wayland_window_create_gl_context (GdkWindow *window,
g_print ("Created EGL context[%p]\n", ctx));
context = g_object_new (GDK_TYPE_WAYLAND_GL_CONTEXT,
"display", display,
"window", window,
"visual", gdk_window_get_visual (window),
"profile", profile,
"shared-context", share,
NULL);
context->egl_config = config;
@@ -369,16 +359,18 @@ gdk_wayland_window_create_gl_context (GdkWindow *window,
return GDK_GL_CONTEXT (context);
}
void
gdk_wayland_display_destroy_gl_context (GdkDisplay *display,
GdkGLContext *context)
static void
gdk_x11_gl_context_dispose (GObject *gobject)
{
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
GdkWaylandGLContext *context_wayland = GDK_WAYLAND_GL_CONTEXT (context);
GdkWaylandGLContext *context_wayland = GDK_WAYLAND_GL_CONTEXT (gobject);
/* TODO: Unset as current if current? */
if (context_wayland->egl_context != NULL)
{
GdkGLContext *context = GDK_GL_CONTEXT (gobject);
GdkWindow *window = gdk_gl_context_get_window (context);
GdkDisplay *display = gdk_window_get_display (window);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
if (eglGetCurrentContext () == context_wayland->egl_context)
eglMakeCurrent(display_wayland->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
EGL_NO_CONTEXT);
@@ -389,9 +381,11 @@ gdk_wayland_display_destroy_gl_context (GdkDisplay *display,
context_wayland->egl_context);
context_wayland->egl_context = NULL;
}
G_OBJECT_CLASS (gdk_wayland_gl_context_parent_class)->dispose (gobject);
}
void
gboolean
gdk_wayland_display_make_gl_context_current (GdkDisplay *display,
GdkGLContext *context)
{
@@ -404,7 +398,7 @@ gdk_wayland_display_make_gl_context_current (GdkDisplay *display,
{
eglMakeCurrent(display_wayland->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
EGL_NO_CONTEXT);
return;
return TRUE;
}
context_wayland = GDK_WAYLAND_GL_CONTEXT (context);
@@ -422,6 +416,11 @@ gdk_wayland_display_make_gl_context_current (GdkDisplay *display,
}
if (!eglMakeCurrent (display_wayland->egl_display, egl_surface,
egl_surface, context_wayland->egl_context))
g_critical ("eglMakeCurrent failed");
egl_surface, context_wayland->egl_context))
{
g_warning ("eglMakeCurrent failed");
return FALSE;
}
return TRUE;
}
+1 -3
View File
@@ -55,9 +55,7 @@ GdkGLContext * gdk_wayland_window_create_gl_context (GdkWindow
GError **error);
void gdk_wayland_window_invalidate_for_new_frame (GdkWindow *window,
cairo_region_t *update_area);
void gdk_wayland_display_destroy_gl_context (GdkDisplay *display,
GdkGLContext *context);
void gdk_wayland_display_make_gl_context_current (GdkDisplay *display,
gboolean gdk_wayland_display_make_gl_context_current (GdkDisplay *display,
GdkGLContext *context);
G_END_DECLS
+5 -4
View File
@@ -224,9 +224,10 @@ GdkWaylandSelection * gdk_wayland_display_get_selection (GdkDisplay *display);
GdkWaylandSelection * gdk_wayland_selection_new (void);
void gdk_wayland_selection_free (GdkWaylandSelection *selection);
void gdk_wayland_selection_set_offer (struct wl_data_offer *offer);
struct wl_data_offer * gdk_wayland_selection_get_offer (void);
GList * gdk_wayland_selection_get_targets (void);
void gdk_wayland_selection_set_offer (GdkDisplay *display,
struct wl_data_offer *wl_offer);
struct wl_data_offer * gdk_wayland_selection_get_offer (GdkDisplay *display);
GList * gdk_wayland_selection_get_targets (GdkDisplay *display);
void gdk_wayland_selection_store (GdkWindow *window,
GdkAtom type,
@@ -235,7 +236,7 @@ void gdk_wayland_selection_store (GdkWindow *window,
gint len);
struct wl_data_source * gdk_wayland_selection_get_data_source (GdkWindow *owner,
GdkAtom selection);
void gdk_wayland_selection_unset_data_source (GdkAtom selection);
void gdk_wayland_selection_unset_data_source (GdkDisplay *display, GdkAtom selection);
EGLSurface gdk_wayland_window_get_egl_surface (GdkWindow *window,
EGLConfig config);
+16 -18
View File
@@ -26,6 +26,7 @@
#include "gdkwayland.h"
#include "gdkprivate-wayland.h"
#include "gdkdisplay-wayland.h"
#include "gdkdndprivate.h"
#include "gdkselection.h"
#include "gdkproperty.h"
#include "gdkprivate.h"
@@ -320,9 +321,9 @@ static const struct wl_data_offer_listener data_offer_listener = {
};
void
gdk_wayland_selection_set_offer (struct wl_data_offer *wl_offer)
gdk_wayland_selection_set_offer (GdkDisplay *display,
struct wl_data_offer *wl_offer)
{
GdkDisplay *display = gdk_display_get_default ();
GdkWaylandSelection *selection = gdk_wayland_display_get_selection (display);
if (selection->offer == wl_offer)
@@ -345,18 +346,16 @@ gdk_wayland_selection_set_offer (struct wl_data_offer *wl_offer)
}
struct wl_data_offer *
gdk_wayland_selection_get_offer (void)
gdk_wayland_selection_get_offer (GdkDisplay *display)
{
GdkDisplay *display = gdk_display_get_default ();
GdkWaylandSelection *selection = gdk_wayland_display_get_selection (display);
return selection->offer;
}
GList *
gdk_wayland_selection_get_targets (void)
gdk_wayland_selection_get_targets (GdkDisplay *display)
{
GdkDisplay *display = gdk_display_get_default ();
GdkWaylandSelection *selection = gdk_wayland_display_get_selection (display);
return selection->targets;
@@ -476,7 +475,7 @@ gdk_wayland_selection_store (GdkWindow *window,
const guchar *data,
gint len)
{
GdkDisplay *display = gdk_display_get_default ();
GdkDisplay *display = gdk_window_get_display (window);
GdkWaylandSelection *selection = gdk_wayland_display_get_selection (display);
GArray *array;
@@ -526,7 +525,7 @@ gdk_wayland_selection_store (GdkWindow *window,
static SelectionBuffer *
gdk_wayland_selection_lookup_requestor_buffer (GdkWindow *requestor)
{
GdkDisplay *display = gdk_display_get_default ();
GdkDisplay *display = gdk_window_get_display (requestor);
GdkWaylandSelection *selection = gdk_wayland_display_get_selection (display);
SelectionBuffer *buffer_data;
GHashTableIter iter;
@@ -662,16 +661,18 @@ data_source_cancelled (void *data,
{
GdkWaylandSelection *wayland_selection = data;
GdkDragContext *context;
GdkDisplay *display;
g_debug (G_STRLOC ": %s source = %p",
G_STRFUNC, source);
context = gdk_wayland_drag_context_lookup_by_data_source (source);
display = gdk_window_get_display (context->source_window);
if (source == wayland_selection->dnd_source)
gdk_wayland_selection_unset_data_source (atoms[ATOM_DND]);
gdk_wayland_selection_unset_data_source (display, atoms[ATOM_DND]);
else if (source == wayland_selection->clipboard_source)
gdk_wayland_selection_unset_data_source (atoms[ATOM_CLIPBOARD]);
gdk_wayland_selection_unset_data_source (display, atoms[ATOM_CLIPBOARD]);
if (context)
gdk_wayland_drag_context_undo_grab (context);
@@ -687,7 +688,7 @@ struct wl_data_source *
gdk_wayland_selection_get_data_source (GdkWindow *owner,
GdkAtom selection)
{
GdkDisplay *display = gdk_display_get_default ();
GdkDisplay *display = gdk_window_get_display (owner);
GdkWaylandSelection *wayland_selection = gdk_wayland_display_get_selection (display);
struct wl_data_source *source = NULL;
GdkWaylandDisplay *display_wayland;
@@ -741,18 +742,15 @@ gdk_wayland_selection_get_data_source (GdkWindow *owner,
}
void
gdk_wayland_selection_unset_data_source (GdkAtom selection)
gdk_wayland_selection_unset_data_source (GdkDisplay *display, GdkAtom selection)
{
GdkDisplay *display = gdk_display_get_default ();
GdkWaylandSelection *wayland_selection = gdk_wayland_display_get_selection (display);
if (selection == atoms[ATOM_CLIPBOARD])
{
GdkDeviceManager *device_manager;
GdkDisplay *display;
GdkDevice *device;
display = gdk_display_get_default ();
device_manager = gdk_display_get_device_manager (display);
device = gdk_device_manager_get_client_pointer (device_manager);
@@ -1023,7 +1021,7 @@ gdk_wayland_selection_add_targets (GdkWindow *window,
GdkDisplay *display;
GdkDevice *device;
display = gdk_display_get_default ();
display = gdk_window_get_display (window);
device_manager = gdk_display_get_device_manager (display);
device = gdk_device_manager_get_client_pointer (device_manager);
gdk_wayland_device_set_selection (device, data_source);
@@ -1031,7 +1029,7 @@ gdk_wayland_selection_add_targets (GdkWindow *window,
}
void
gdk_wayland_selection_clear_targets (GdkAtom selection)
gdk_wayland_selection_clear_targets (GdkDisplay *display, GdkAtom selection)
{
gdk_wayland_selection_unset_data_source (selection);
gdk_wayland_selection_unset_data_source (display, selection);
}
+1 -1
View File
@@ -45,7 +45,7 @@ gdk_wayland_selection_add_targets (GdkWindow *window,
#define gdk_wayland_selection_clear_targets gdk_wayland_selection_clear_targets_libgtk_only
GDK_AVAILABLE_IN_ALL
void
gdk_wayland_selection_clear_targets (GdkAtom selection);
gdk_wayland_selection_clear_targets (GdkDisplay *display, GdkAtom selection);
#define gdk_wayland_drag_context_get_dnd_window gdk_wayland_drag_context_get_dnd_window_libgtk_only
GDK_AVAILABLE_IN_ALL
+34 -17
View File
@@ -217,9 +217,7 @@ _gdk_wayland_screen_create_root_window (GdkScreen *screen,
impl->scale,
impl->scale);
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
cairo_surface_set_device_scale (impl->cairo_surface, impl->scale, impl->scale);
#endif
window->window_type = GDK_WINDOW_ROOT;
window->depth = 32;
@@ -420,11 +418,6 @@ window_update_scale (GdkWindow *window)
scale = MAX (scale, output_scale);
}
#ifndef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
/* Don't announce a scale if we can't support it */
scale = 1;
#endif
if (scale != impl->scale)
{
impl->scale = scale;
@@ -1283,6 +1276,32 @@ gdk_window_wayland_restack_toplevel (GdkWindow *window,
{
}
static void
gdk_window_request_transient_parent_commit (GdkWindow *window)
{
GdkWindowImplWayland *window_impl, *impl;
GdkFrameClock *frame_clock;
window_impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
if (!window_impl->transient_for)
return;
impl = GDK_WINDOW_IMPL_WAYLAND (window_impl->transient_for->impl);
if (!impl->surface || impl->pending_commit)
return;
frame_clock = gdk_window_get_frame_clock (window_impl->transient_for);
if (!frame_clock)
return;
impl->pending_commit = TRUE;
gdk_frame_clock_request_phase (frame_clock,
GDK_FRAME_CLOCK_PHASE_AFTER_PAINT);
}
static void
gdk_window_wayland_move_resize (GdkWindow *window,
gboolean with_move,
@@ -1305,15 +1324,8 @@ gdk_window_wayland_move_resize (GdkWindow *window,
if (impl->subsurface)
{
GdkWindowImplWayland *parent_impl;
wl_subsurface_set_position (impl->subsurface, x, y);
g_assert (impl->transient_for != NULL);
parent_impl = GDK_WINDOW_IMPL_WAYLAND (impl->transient_for->impl);
if (parent_impl->surface && !parent_impl->pending_commit)
wl_surface_commit (parent_impl->surface);
gdk_window_request_transient_parent_commit (window);
}
}
}
@@ -1437,8 +1449,13 @@ gdk_window_wayland_input_shape_combine_region (GdkWindow *window,
return;
g_clear_pointer (&impl->input_region, cairo_region_destroy);
impl->input_region = cairo_region_copy (shape_region);
cairo_region_translate (impl->input_region, offset_x, offset_y);
if (shape_region)
{
impl->input_region = cairo_region_copy (shape_region);
cairo_region_translate (impl->input_region, offset_x, offset_y);
}
gdk_wayland_window_sync_input_region (window);
}
-15
View File
@@ -600,19 +600,6 @@ gdk_win32_display_notify_startup_complete (GdkDisplay *display,
/* nothing */
}
static void
gdk_win32_display_event_data_copy (GdkDisplay *display,
const GdkEvent *src,
GdkEvent *dst)
{
/* nothing */
}
static void
gdk_win32_display_event_data_free (GdkDisplay *display,
GdkEvent *event)
{
/* nothing */
}
static void
gdk_win32_display_push_error_trap (GdkDisplay *display)
{
/* nothing */
@@ -665,8 +652,6 @@ gdk_win32_display_class_init (GdkWin32DisplayClass *klass)
display_class->after_process_all_updates = gdk_win32_display_after_process_all_updates;
display_class->get_next_serial = gdk_win32_display_get_next_serial;
display_class->notify_startup_complete = gdk_win32_display_notify_startup_complete;
display_class->event_data_copy = gdk_win32_display_event_data_copy;
display_class->event_data_free = gdk_win32_display_event_data_free;
display_class->create_window_impl = _gdk_win32_display_create_window_impl;
display_class->get_keymap = _gdk_win32_display_get_keymap;
-4
View File
@@ -524,9 +524,7 @@ get_surface_size (cairo_surface_t *surface,
x_scale = y_scale = 1;
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
cairo_surface_get_device_scale (surface, &x_scale, &y_scale);
#endif
/* Assume any set scaling is icon scale */
*width =
@@ -562,9 +560,7 @@ create_cursor_image (cairo_surface_t *source_surface,
height,
width * 4);
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
cairo_surface_set_device_scale (surface, scale, scale);
#endif
cr = cairo_create (surface);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+33 -32
View File
@@ -38,6 +38,7 @@
#include "gdkprivate-x11.h"
#include "gdkscreen-x11.h"
#include "gdkglcontext-x11.h"
#include "gdk-private.h"
#include <glib.h>
#include <glib/gprintf.h>
@@ -48,6 +49,7 @@
#include <X11/Xatom.h>
#include <X11/Xlibint.h>
#include <X11/Xlib-xcb.h>
#ifdef HAVE_XKB
#include <X11/XKBlib.h>
@@ -71,6 +73,10 @@
#include <X11/extensions/Xrandr.h>
#endif
#ifdef HAVE_PRESENT
#include <xcb/present.h>
#endif
typedef struct _GdkErrorTrap GdkErrorTrap;
struct _GdkErrorTrap
@@ -165,7 +171,8 @@ static const char *const precache_atoms[] = {
"_NET_WM_USER_TIME_WINDOW",
"_NET_VIRTUAL_ROOTS",
"GDK_SELECTION",
"_NET_WM_STATE_FOCUSED"
"_NET_WM_STATE_FOCUSED",
"GDK_VISUALS"
};
static char *gdk_sm_client_id;
@@ -703,7 +710,7 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
}
if (toplevel)
gdk_window_freeze_toplevel_updates_libgtk_only (window);
gdk_window_freeze_toplevel_updates (window);
_gdk_x11_window_grab_check_unmap (window, xevent->xany.serial);
}
@@ -727,7 +734,7 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
0);
if (toplevel)
gdk_window_thaw_toplevel_updates_libgtk_only (window);
gdk_window_thaw_toplevel_updates (window);
}
break;
@@ -765,11 +772,13 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
: ""));
if (window && GDK_WINDOW_TYPE (window) == GDK_WINDOW_ROOT)
{
window->width = xevent->xconfigure.width / window_impl->window_scale;
window->height = xevent->xconfigure.height / window_impl->window_scale;
window_impl->unscaled_width = xevent->xconfigure.width;
window_impl->unscaled_height = xevent->xconfigure.height;
window->width = (xevent->xconfigure.width + window_impl->window_scale - 1) / window_impl->window_scale;
window->height = (xevent->xconfigure.height + window_impl->window_scale - 1) / window_impl->window_scale;
_gdk_window_update_size (window);
_gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
_gdk_x11_window_update_size (window_impl);
_gdk_x11_screen_size_changed (screen, xevent);
}
@@ -791,8 +800,8 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
{
event->configure.type = GDK_CONFIGURE;
event->configure.window = window;
event->configure.width = xevent->xconfigure.width / window_impl->window_scale;
event->configure.height = xevent->xconfigure.height / window_impl->window_scale;
event->configure.width = (xevent->xconfigure.width + window_impl->window_scale - 1) / window_impl->window_scale;
event->configure.height = (xevent->xconfigure.height + window_impl->window_scale - 1) / window_impl->window_scale;
if (!xevent->xconfigure.send_event &&
!xevent->xconfigure.override_redirect &&
@@ -824,11 +833,13 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
{
window->x = event->configure.x;
window->y = event->configure.y;
window->width = xevent->xconfigure.width / window_impl->window_scale;
window->height = xevent->xconfigure.height / window_impl->window_scale;
window_impl->unscaled_width = xevent->xconfigure.width;
window_impl->unscaled_height = xevent->xconfigure.height;
window->width = event->configure.width;
window->height = event->configure.height;
_gdk_window_update_size (window);
_gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
_gdk_x11_window_update_size (window_impl);
if (window->resize_count >= 1)
{
@@ -1360,6 +1371,7 @@ _gdk_x11_display_open (const gchar *display_name)
GdkWindowAttr attr;
gint argc;
gchar *argv[1];
xcb_connection_t *xcb_conn;
XClassHint *class_hint;
gulong pid;
@@ -1380,6 +1392,8 @@ _gdk_x11_display_open (const gchar *display_name)
_gdk_x11_precache_atoms (display, precache_atoms, G_N_ELEMENTS (precache_atoms));
xcb_conn = XGetXCBConnection (display_x11->xdisplay);
/* RandR must be initialized before we initialize the screens */
display_x11->have_randr12 = FALSE;
display_x11->have_randr13 = FALSE;
@@ -1444,6 +1458,14 @@ _gdk_x11_display_open (const gchar *display_name)
#endif
display_x11->have_xfixes = FALSE;
#ifdef HAVE_PRESENT
if (xcb_get_extension_data (xcb_conn, &xcb_present_id))
{
(void) xcb_present_query_version (xcb_conn, XCB_PRESENT_MAJOR_VERSION, XCB_PRESENT_MINOR_VERSION);
display_x11->have_present = TRUE;
}
#endif
#ifdef HAVE_XCOMPOSITE
if (XCompositeQueryExtension (display_x11->xdisplay,
&ignore, &ignore))
@@ -2705,11 +2727,6 @@ gdk_x11_display_set_window_scale (GdkDisplay *display,
scale = MAX (scale, 1);
#ifndef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
/* Without cairo support we can't support any scale but 1 */
scale = 1;
#endif
x11_screen = GDK_X11_SCREEN (GDK_X11_DISPLAY (display)->screen);
if (!x11_screen->fixed_window_scale)
@@ -2810,19 +2827,6 @@ gdk_x11_set_sm_client_id (const gchar *sm_client_id)
g_slist_free (displays);
}
static void
gdk_x11_display_event_data_copy (GdkDisplay *display,
const GdkEvent *src,
GdkEvent *dst)
{
}
static void
gdk_x11_display_event_data_free (GdkDisplay *display,
GdkEvent *event)
{
}
static gint
pop_error_trap (GdkDisplay *display,
gboolean ignored)
@@ -2894,8 +2898,6 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class)
display_class->after_process_all_updates = _gdk_x11_display_after_process_all_updates;
display_class->get_next_serial = gdk_x11_display_get_next_serial;
display_class->notify_startup_complete = gdk_x11_display_notify_startup_complete;
display_class->event_data_copy = gdk_x11_display_event_data_copy;
display_class->event_data_free = gdk_x11_display_event_data_free;
display_class->create_window_impl = _gdk_x11_display_create_window_impl;
display_class->get_keymap = gdk_x11_display_get_keymap;
display_class->push_error_trap = gdk_x11_display_error_trap_push;
@@ -2908,7 +2910,6 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class)
display_class->text_property_to_utf8_list = _gdk_x11_display_text_property_to_utf8_list;
display_class->utf8_to_string_target = _gdk_x11_display_utf8_to_string_target;
display_class->destroy_gl_context = gdk_x11_display_destroy_gl_context;
display_class->make_gl_context_current = gdk_x11_display_make_gl_context_current;
_gdk_x11_windowing_init ();
+4
View File
@@ -68,6 +68,8 @@ struct _GdkX11Display
gboolean have_randr13;
gint xrandr_event_base;
gboolean have_present;
/* If the SECURITY extension is in place, whether this client holds
* a trusted authorization and so is allowed to make various requests
* (grabs, properties etc.) Otherwise always TRUE.
@@ -139,6 +141,8 @@ struct _GdkX11Display
guint has_glx_video_sync : 1;
guint has_glx_buffer_age : 1;
guint has_glx_sync_control : 1;
guint has_glx_multisample : 1;
guint has_glx_visual_rating : 1;
};
struct _GdkX11DisplayClass
+2
View File
@@ -62,6 +62,8 @@ _gdk_x11_window_move_resize_child (GdkWindow *window,
window->x = x;
window->y = y;
impl->unscaled_width = width * impl->window_scale;
impl->unscaled_height = height * impl->window_scale;
window->width = width;
window->height = height;
+490 -146
View File
@@ -29,6 +29,9 @@
#include "gdkx11screen.h"
#include "gdkx11window.h"
#include "gdkx11visual.h"
#include "gdkvisualprivate.h"
#include "gdkx11property.h"
#include <X11/Xatom.h>
#include "gdkinternals.h"
@@ -90,25 +93,6 @@ set_glx_drawable_info (GdkWindow *window,
drawable_info_free);
}
static void
gdk_x11_gl_context_update (GdkGLContext *context)
{
GdkWindow *window = gdk_gl_context_get_window (context);
int width, height;
gdk_gl_context_make_current (context);
width = gdk_window_get_width (window);
height = gdk_window_get_height (window);
GDK_NOTE (OPENGL, g_print ("Updating GL viewport size to { %d, %d } for window %lu (context: %p)\n",
width, height,
(unsigned long) gdk_x11_window_get_xid (window),
context));
glViewport (0, 0, width, height);
}
static void
maybe_wait_for_vblank (GdkDisplay *display,
GLXDrawable drawable)
@@ -154,6 +138,8 @@ gdk_x11_window_invalidate_for_new_frame (GdkWindow *window,
buffer_age = 0;
context_x11->do_blit_swap = FALSE;
if (display_x11->has_glx_buffer_age)
{
gdk_gl_context_make_current (window->gl_paint_context);
@@ -161,9 +147,20 @@ gdk_x11_window_invalidate_for_new_frame (GdkWindow *window,
GLX_BACK_BUFFER_AGE_EXT, &buffer_age);
}
invalidate_all = FALSE;
if (buffer_age == 0 || buffer_age >= 4)
invalidate_all = TRUE;
{
cairo_rectangle_int_t whole_window = { 0, 0, gdk_window_get_width (window), gdk_window_get_height (window) };
if (gdk_gl_context_has_framebuffer_blit (window->gl_paint_context) &&
cairo_region_contains_rectangle (update_area, &whole_window) != CAIRO_REGION_OVERLAP_IN)
{
context_x11->do_blit_swap = TRUE;
}
else
invalidate_all = TRUE;
}
else
{
if (buffer_age >= 2)
@@ -197,13 +194,32 @@ gdk_x11_window_invalidate_for_new_frame (GdkWindow *window,
}
static void
gdk_x11_gl_context_flush_buffer (GdkGLContext *context,
cairo_region_t *painted,
cairo_region_t *damage)
gdk_gl_blit_region (GdkWindow *window, cairo_region_t *region)
{
int n_rects, i;
int scale = gdk_window_get_scale_factor (window);
int wh = gdk_window_get_height (window);
cairo_rectangle_int_t rect;
n_rects = cairo_region_num_rectangles (region);
for (i = 0; i < n_rects; i++)
{
cairo_region_get_rectangle (region, i, &rect);
glScissor (rect.x * scale, (wh - rect.y - rect.height) * scale, rect.width * scale, rect.height * scale);
glBlitFramebuffer (rect.x * scale, (wh - rect.y - rect.height) * scale, (rect.x + rect.width) * scale, (wh - rect.y) * scale,
rect.x * scale, (wh - rect.y - rect.height) * scale, (rect.x + rect.width) * scale, (wh - rect.y) * scale,
GL_COLOR_BUFFER_BIT, GL_NEAREST);
}
}
static void
gdk_x11_gl_context_end_frame (GdkGLContext *context,
cairo_region_t *painted,
cairo_region_t *damage)
{
GdkX11GLContext *context_x11 = GDK_X11_GL_CONTEXT (context);
GdkWindow *window = gdk_gl_context_get_window (context);
GdkDisplay *display = gdk_window_get_display (window);
GdkDisplay *display = gdk_gl_context_get_display (context);
Display *dpy = gdk_x11_display_get_xdisplay (display);
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
DrawableInfo *info;
@@ -254,7 +270,19 @@ gdk_x11_gl_context_flush_buffer (GdkGLContext *context,
}
}
glXSwapBuffers (dpy, drawable);
if (context_x11->do_blit_swap)
{
glDrawBuffer(GL_FRONT);
glReadBuffer(GL_BACK);
gdk_gl_blit_region (window, painted);
glDrawBuffer(GL_BACK);
glFlush();
if (gdk_gl_context_has_frame_terminator (context))
glFrameTerminatorGREMEDY ();
}
else
glXSwapBuffers (dpy, drawable);
if (context_x11->do_frame_sync && info != NULL && display_x11->has_glx_video_sync)
glXGetVideoSyncSGI (&info->last_frame_counter);
@@ -277,7 +305,7 @@ glx_pixmap_destroy (void *data)
}
static GdkGLXPixmap *
glx_pixmap_get (cairo_surface_t *surface)
glx_pixmap_get (cairo_surface_t *surface, guint texture_target)
{
Display *display = cairo_xlib_surface_get_display (surface);
Screen *screen = cairo_xlib_surface_get_screen (surface);
@@ -286,50 +314,96 @@ glx_pixmap_get (cairo_surface_t *surface)
GLXFBConfig *fbconfigs;
int nfbconfigs;
XVisualInfo *visinfo;
VisualID visualid;
int i, value;
gboolean y_inverted;
const int pixmap_attributes[] = {
GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGBA_EXT,
gboolean with_alpha;
guint target = 0;
guint format = 0;
int pixmap_attributes[] = {
GLX_TEXTURE_TARGET_EXT, 0,
GLX_TEXTURE_FORMAT_EXT, 0,
None
};
with_alpha = cairo_surface_get_content (surface) == CAIRO_CONTENT_COLOR_ALPHA;
y_inverted = FALSE;
fbconfigs = glXGetFBConfigs (display, XScreenNumberOfScreen (screen), &nfbconfigs);
for (i = 0; i < nfbconfigs; i++)
{
visinfo = glXGetVisualFromFBConfig (display, fbconfigs[i]);
if (!visinfo || visinfo->visualid != XVisualIDFromVisual (visual))
continue;
if (!visinfo)
continue;
visualid = visinfo->visualid;
XFree (visinfo);
if (visualid != XVisualIDFromVisual (visual))
continue;
glXGetFBConfigAttrib (display, fbconfigs[i], GLX_DRAWABLE_TYPE, &value);
if (!(value & GLX_PIXMAP_BIT))
continue;
glXGetFBConfigAttrib (display, fbconfigs[i],
GLX_BIND_TO_TEXTURE_TARGETS_EXT,
&value);
if ((value & GLX_TEXTURE_RECTANGLE_BIT_EXT))
continue;
glXGetFBConfigAttrib (display, fbconfigs[i],
GLX_BIND_TO_TEXTURE_RGBA_EXT,
&value);
if (value == FALSE)
continue;
glXGetFBConfigAttrib (display, fbconfigs[i],
GLX_Y_INVERTED_EXT,
&value);
GLX_BIND_TO_TEXTURE_TARGETS_EXT,
&value);
if (texture_target == GL_TEXTURE_2D)
{
if (value & GLX_TEXTURE_2D_BIT_EXT)
target = GLX_TEXTURE_2D_EXT;
else
continue;
}
else if (texture_target == GL_TEXTURE_RECTANGLE_ARB)
{
if (value & GLX_TEXTURE_RECTANGLE_BIT_EXT)
target = GLX_TEXTURE_RECTANGLE_EXT;
else
continue;
}
else
continue;
if (!with_alpha)
{
glXGetFBConfigAttrib (display, fbconfigs[i],
GLX_BIND_TO_TEXTURE_RGB_EXT,
&value);
if (!value)
continue;
format = GLX_TEXTURE_FORMAT_RGB_EXT;
}
else
{
glXGetFBConfigAttrib (display, fbconfigs[i],
GLX_BIND_TO_TEXTURE_RGBA_EXT,
&value);
if (!value)
continue;
format = GLX_TEXTURE_FORMAT_RGBA_EXT;
}
glXGetFBConfigAttrib (display, fbconfigs[i],
GLX_Y_INVERTED_EXT,
&value);
if (value == TRUE)
y_inverted = TRUE;
y_inverted = TRUE;
break;
}
XFree (fbconfigs);
if (i == nfbconfigs)
return NULL;
pixmap_attributes[1] = target;
pixmap_attributes[3] = format;
glx_pixmap = g_slice_new0 (GdkGLXPixmap);
glx_pixmap->y_inverted = y_inverted;
glx_pixmap->display = display;
@@ -341,7 +415,7 @@ glx_pixmap_get (cairo_surface_t *surface)
}
static gboolean
gdk_x11_gl_context_texture_from_surface (GdkGLContext *context,
gdk_x11_gl_context_texture_from_surface (GdkGLContext *paint_context,
cairo_surface_t *surface,
cairo_region_t *region)
{
@@ -353,23 +427,30 @@ gdk_x11_gl_context_texture_from_surface (GdkGLContext *context,
int window_height;
int window_scale;
unsigned int texture_id;
gboolean use_texture_rectangle;
guint target;
double sx, sy;
float uscale, vscale;
if (cairo_surface_get_type (surface) != CAIRO_SURFACE_TYPE_XLIB)
return FALSE;
glx_pixmap = glx_pixmap_get (surface);
use_texture_rectangle = gdk_gl_context_use_texture_rectangle (paint_context);
if (use_texture_rectangle)
target = GL_TEXTURE_RECTANGLE_ARB;
else
target = GL_TEXTURE_2D;
glx_pixmap = glx_pixmap_get (surface, target);
if (glx_pixmap == NULL)
return FALSE;
window = gdk_gl_context_get_window (gdk_gl_context_get_current ())->impl_window;
window = gdk_gl_context_get_window (paint_context)->impl_window;
window_scale = gdk_window_get_scale_factor (window);
window_height = gdk_window_get_height (window);
sx = sy = 1;
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
cairo_surface_get_device_scale (window->current_paint.surface, &sx, &sy);
#endif
cairo_surface_get_device_offset (surface,
&device_x_offset, &device_y_offset);
@@ -378,8 +459,13 @@ gdk_x11_gl_context_texture_from_surface (GdkGLContext *context,
glXWaitX();
glGenTextures (1, &texture_id);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture_id);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (target, texture_id);
glEnable (target);
glTexParameteri (target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri (target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri (target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glXBindTexImageEXT (glx_pixmap->display, glx_pixmap->drawable,
GLX_FRONT_LEFT_EXT, NULL);
@@ -401,25 +487,28 @@ gdk_x11_gl_context_texture_from_surface (GdkGLContext *context,
#define FLIP_Y(_y) (window_height - (_y))
glBegin (GL_QUADS);
glTexCoord2f (src_x, src_y + src_height);
glVertex2f (rect.x * window_scale, FLIP_Y(rect.y + rect.height) * window_scale);
if (use_texture_rectangle)
{
uscale = 1.0;
vscale = 1.0;
}
else
{
uscale = 1.0 / cairo_xlib_surface_get_width (surface);
vscale = 1.0 / cairo_xlib_surface_get_height (surface);
}
glTexCoord2f (src_x + src_width, src_y + src_height);
glVertex2f ((rect.x + rect.width) * window_scale, FLIP_Y(rect.y + rect.height) * window_scale);
glTexCoord2f (src_x + src_width, src_y);
glVertex2f ((rect.x + rect.width) * window_scale, FLIP_Y(rect.y) * window_scale);
glTexCoord2f (src_x, src_y);
glVertex2f (rect.x * window_scale, FLIP_Y(rect.y) * window_scale);
glEnd();
gdk_gl_texture_quad (paint_context, target,
rect.x * window_scale, FLIP_Y(rect.y) * window_scale,
(rect.x + rect.width) * window_scale, FLIP_Y(rect.y + rect.height) * window_scale,
uscale * src_x, vscale * src_y,
uscale * (src_x + src_width), vscale * (src_y + src_height));
}
glXReleaseTexImageEXT (glx_pixmap->display, glx_pixmap->drawable,
GLX_FRONT_LEFT_EXT);
glDisable (GL_TEXTURE_RECTANGLE_ARB);
glDisable (target);
glDeleteTextures (1, &texture_id);
glx_pixmap_destroy(glx_pixmap);
@@ -427,26 +516,51 @@ gdk_x11_gl_context_texture_from_surface (GdkGLContext *context,
return TRUE;
}
static void
gdk_x11_gl_context_dispose (GObject *gobject)
{
GdkX11GLContext *context_x11 = GDK_X11_GL_CONTEXT (gobject);
if (context_x11->glx_context != NULL)
{
GdkGLContext *context = GDK_GL_CONTEXT (gobject);
GdkDisplay *display = gdk_gl_context_get_display (context);
Display *dpy = gdk_x11_display_get_xdisplay (display);
if (glXGetCurrentContext () == context_x11->glx_context)
glXMakeContextCurrent (dpy, None, None, NULL);
GDK_NOTE (OPENGL, g_print ("Destroying GLX context\n"));
glXDestroyContext (dpy, context_x11->glx_context);
context_x11->glx_context = NULL;
}
G_OBJECT_CLASS (gdk_x11_gl_context_parent_class)->dispose (gobject);
}
static void
gdk_x11_gl_context_class_init (GdkX11GLContextClass *klass)
{
GdkGLContextClass *context_class = GDK_GL_CONTEXT_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
context_class->update = gdk_x11_gl_context_update;
context_class->flush_buffer = gdk_x11_gl_context_flush_buffer;
context_class->end_frame = gdk_x11_gl_context_end_frame;
context_class->texture_from_surface = gdk_x11_gl_context_texture_from_surface;
gobject_class->dispose = gdk_x11_gl_context_dispose;
}
static void
gdk_x11_gl_context_init (GdkX11GLContext *self)
{
self->do_frame_sync = TRUE;
}
gboolean
gdk_x11_display_init_gl (GdkDisplay *display)
gdk_x11_screen_init_gl (GdkScreen *screen)
{
GdkDisplay *display = gdk_screen_get_display (screen);
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
GdkScreen *screen;
Display *dpy;
int error_base, event_base;
int screen_num;
@@ -459,7 +573,6 @@ gdk_x11_display_init_gl (GdkDisplay *display)
if (!glXQueryExtension (dpy, &error_base, &event_base))
return FALSE;
screen = gdk_display_get_default_screen (display);
screen_num = GDK_X11_SCREEN (screen)->screen_num;
display_x11->have_glx = TRUE;
@@ -480,6 +593,10 @@ gdk_x11_display_init_gl (GdkDisplay *display)
epoxy_has_glx_extension (dpy, screen_num, "GLX_EXT_buffer_age");
display_x11->has_glx_sync_control =
epoxy_has_glx_extension (dpy, screen_num, "GLX_OML_sync_control");
display_x11->has_glx_multisample =
epoxy_has_glx_extension (dpy, screen_num, "GLX_ARB_multisample");
display_x11->has_glx_visual_rating =
epoxy_has_glx_extension (dpy, screen_num, "GLX_EXT_visual_rating");
GDK_NOTE (OPENGL,
g_print ("GLX version %d.%d found\n"
@@ -519,6 +636,7 @@ find_fbconfig_for_visual (GdkDisplay *display,
int n_configs, i;
gboolean use_rgba;
gboolean retval = FALSE;
VisualID xvisual_id = XVisualIDFromVisual(gdk_x11_visual_get_xvisual (visual));
i = 0;
attrs[i++] = GLX_DRAWABLE_TYPE;
@@ -531,14 +649,13 @@ find_fbconfig_for_visual (GdkDisplay *display,
attrs[i++] = GL_TRUE;
attrs[i++] = GLX_RED_SIZE;
attrs[i++] = gdk_visual_get_bits_per_rgb (visual);
attrs[i++] = 1;
attrs[i++] = GLX_GREEN_SIZE;
attrs[i++] = gdk_visual_get_bits_per_rgb (visual);;
attrs[i++] = 1;
attrs[i++] = GLX_BLUE_SIZE;
attrs[i++] = gdk_visual_get_bits_per_rgb (visual);;
attrs[i++] = 1;
use_rgba = (visual == gdk_screen_get_rgba_visual (gdk_display_get_default_screen (display)));
if (use_rgba)
{
attrs[i++] = GLX_ALPHA_SIZE;
@@ -563,44 +680,27 @@ find_fbconfig_for_visual (GdkDisplay *display,
return FALSE;
}
/* if we don't care about an alpha channel, then the first
* valid configuration is the one we give back
*/
if (!use_rgba)
{
if (fb_config_out != NULL)
*fb_config_out = configs[0];
if (visinfo_out != NULL)
*visinfo_out = glXGetVisualFromFBConfig (dpy, configs[0]);
retval = TRUE;
goto out;
}
for (i = 0; i < n_configs; i++)
{
XVisualInfo *visinfo;
unsigned long mask;
visinfo = glXGetVisualFromFBConfig (dpy, configs[i]);
if (visinfo == NULL)
continue;
mask = visinfo->red_mask | visinfo->green_mask | visinfo->blue_mask;
if (visinfo->depth == 32 && mask != 0xffffffff)
{
if (fb_config_out != NULL)
*fb_config_out = configs[i];
if (visinfo->visualid != xvisual_id)
continue;
if (visinfo_out != NULL)
*visinfo_out = visinfo;
if (fb_config_out != NULL)
*fb_config_out = configs[i];
retval = TRUE;
goto out;
}
if (visinfo_out != NULL)
*visinfo_out = visinfo;
else
XFree (visinfo);
XFree (visinfo);
retval = TRUE;
goto out;
}
g_set_error (error, GDK_GL_ERROR,
@@ -654,6 +754,259 @@ create_gl_context (GdkDisplay *display,
True);
}
struct glvisualinfo {
int supports_gl;
int double_buffer;
int stereo;
int alpha_size;
int depth_size;
int stencil_size;
int num_multisample;
int visual_caveat;
};
static gboolean
visual_compatible (const GdkVisual *a, const GdkVisual *b)
{
return a->type == b->type &&
a->depth == b->depth &&
a->red_mask == b->red_mask &&
a->green_mask == b->green_mask &&
a->blue_mask == b->blue_mask &&
a->colormap_size == b->colormap_size &&
a->bits_per_rgb == b->bits_per_rgb;
}
static gboolean
visual_is_rgba (const GdkVisual *visual)
{
return
visual->depth == 32 &&
visual->red_mask == 0xff0000 &&
visual->green_mask == 0x00ff00 &&
visual->blue_mask == 0x0000ff;
}
/* This picks a compatible (as in has the same X visual details) visual
that has "better" characteristics on the GL side */
static GdkVisual *
pick_better_visual_for_gl (GdkX11Screen *x11_screen,
struct glvisualinfo *gl_info,
GdkVisual *compatible)
{
GdkVisual *visual;
int i;
gboolean want_alpha = visual_is_rgba (compatible);
/* First look for "perfect match", i.e:
* supports gl
* double buffer
* alpha iff visual is an rgba visual
* no unnecessary stuff
*/
for (i = 0; i < x11_screen->nvisuals; i++)
{
visual = x11_screen->visuals[i];
if (visual_compatible (visual, compatible) &&
gl_info[i].supports_gl &&
gl_info[i].double_buffer &&
!gl_info[i].stereo &&
(want_alpha ? (gl_info[i].alpha_size > 0) : (gl_info[i].alpha_size == 0)) &&
(gl_info[i].depth_size == 0) &&
(gl_info[i].stencil_size == 0) &&
(gl_info[i].num_multisample == 0) &&
(gl_info[i].visual_caveat == GLX_NONE_EXT))
return visual;
}
if (!want_alpha)
{
/* Next, allow alpha even if we don't want it: */
for (i = 0; i < x11_screen->nvisuals; i++)
{
visual = x11_screen->visuals[i];
if (visual_compatible (visual, compatible) &&
gl_info[i].supports_gl &&
gl_info[i].double_buffer &&
!gl_info[i].stereo &&
(gl_info[i].depth_size == 0) &&
(gl_info[i].stencil_size == 0) &&
(gl_info[i].num_multisample == 0) &&
(gl_info[i].visual_caveat == GLX_NONE_EXT))
return visual;
}
}
/* Next, allow depth and stencil buffers: */
for (i = 0; i < x11_screen->nvisuals; i++)
{
visual = x11_screen->visuals[i];
if (visual_compatible (visual, compatible) &&
gl_info[i].supports_gl &&
gl_info[i].double_buffer &&
!gl_info[i].stereo &&
(gl_info[i].num_multisample == 0) &&
(gl_info[i].visual_caveat == GLX_NONE_EXT))
return visual;
}
/* Next, allow multisample: */
for (i = 0; i < x11_screen->nvisuals; i++)
{
visual = x11_screen->visuals[i];
if (visual_compatible (visual, compatible) &&
gl_info[i].supports_gl &&
gl_info[i].double_buffer &&
!gl_info[i].stereo &&
(gl_info[i].visual_caveat == GLX_NONE_EXT))
return visual;
}
return compatible;
}
static gboolean
get_cached_gl_visuals (GdkDisplay *display, int *system, int *rgba)
{
gboolean found;
Atom type_return;
gint format_return;
gulong nitems_return;
gulong bytes_after_return;
guchar *data = NULL;
Display *dpy;
dpy = gdk_x11_display_get_xdisplay (display);
found = FALSE;
gdk_x11_display_error_trap_push (display);
if (XGetWindowProperty (dpy, DefaultRootWindow (dpy),
gdk_x11_get_xatom_by_name_for_display (display, "GDK_VISUALS"),
0, 2, False, XA_INTEGER, &type_return,
&format_return, &nitems_return,
&bytes_after_return, &data) == Success)
{
if (type_return == XA_INTEGER &&
format_return == 32 &&
nitems_return == 2 &&
data != NULL)
{
long *visuals = (long *) data;
*system = (int)visuals[0];
*rgba = (int)visuals[1];
found = TRUE;
}
}
gdk_x11_display_error_trap_pop_ignored (display);
if (data)
XFree (data);
return found;
}
static void
save_cached_gl_visuals (GdkDisplay *display, int system, int rgba)
{
long visualdata[2];
Display *dpy;
dpy = gdk_x11_display_get_xdisplay (display);
visualdata[0] = system;
visualdata[1] = rgba;
gdk_x11_display_error_trap_push (display);
XChangeProperty(dpy, DefaultRootWindow (dpy), gdk_x11_get_xatom_by_name_for_display (display, "GDK_VISUALS"),
XA_INTEGER, 32, PropModeReplace, (unsigned char *)visualdata, 2);
gdk_x11_display_error_trap_pop_ignored (display);
}
void
_gdk_x11_screen_update_visuals_for_gl (GdkScreen *screen)
{
GdkX11Screen *x11_screen;
GdkDisplay *display;
GdkX11Display *display_x11;
Display *dpy;
struct glvisualinfo *gl_info;
int i;
int system_visual_id, rgba_visual_id;
x11_screen = GDK_X11_SCREEN (screen);
display = x11_screen->display;
display_x11 = GDK_X11_DISPLAY (display);
dpy = gdk_x11_display_get_xdisplay (display);
/* We save the default visuals as a property on the root window to avoid
having to initialize GL each time, as it may not be used later. */
if (get_cached_gl_visuals (display, &system_visual_id, &rgba_visual_id))
{
for (i = 0; i < x11_screen->nvisuals; i++)
{
GdkVisual *visual = x11_screen->visuals[i];
int visual_id = gdk_x11_visual_get_xvisual (visual)->visualid;
if (visual_id == system_visual_id)
x11_screen->system_visual = visual;
if (visual_id == rgba_visual_id)
x11_screen->rgba_visual = visual;
}
return;
}
if (!gdk_x11_screen_init_gl (screen))
return;
gl_info = g_new0 (struct glvisualinfo, x11_screen->nvisuals);
for (i = 0; i < x11_screen->nvisuals; i++)
{
XVisualInfo *visual_list;
XVisualInfo visual_template;
int nxvisuals;
visual_template.screen = x11_screen->screen_num;
visual_template.visualid = gdk_x11_visual_get_xvisual (x11_screen->visuals[i])->visualid;
visual_list = XGetVisualInfo (x11_screen->xdisplay, VisualIDMask| VisualScreenMask, &visual_template, &nxvisuals);
if (visual_list == NULL)
continue;
glXGetConfig (dpy, &visual_list[0], GLX_USE_GL, &gl_info[i].supports_gl);
glXGetConfig (dpy, &visual_list[0], GLX_DOUBLEBUFFER, &gl_info[i].double_buffer);
glXGetConfig (dpy, &visual_list[0], GLX_STEREO, &gl_info[i].stereo);
glXGetConfig (dpy, &visual_list[0], GLX_ALPHA_SIZE, &gl_info[i].alpha_size);
glXGetConfig (dpy, &visual_list[0], GLX_DEPTH_SIZE, &gl_info[i].depth_size);
glXGetConfig (dpy, &visual_list[0], GLX_STENCIL_SIZE, &gl_info[i].stencil_size);
if (display_x11->has_glx_multisample)
glXGetConfig(dpy, &visual_list[0], GLX_SAMPLE_BUFFERS_ARB, &gl_info[i].num_multisample);
if (display_x11->has_glx_visual_rating)
glXGetConfig(dpy, &visual_list[0], GLX_VISUAL_CAVEAT_EXT, &gl_info[i].visual_caveat);
else
gl_info[i].visual_caveat = GLX_NONE_EXT;
XFree (visual_list);
}
x11_screen->system_visual = pick_better_visual_for_gl (x11_screen, gl_info, x11_screen->system_visual);
if (x11_screen->rgba_visual)
x11_screen->rgba_visual = pick_better_visual_for_gl (x11_screen, gl_info, x11_screen->rgba_visual);
g_free (gl_info);
save_cached_gl_visuals (display,
gdk_x11_visual_get_xvisual (x11_screen->system_visual)->visualid,
x11_screen->rgba_visual ? gdk_x11_visual_get_xvisual (x11_screen->rgba_visual)->visualid : 0);
}
GdkGLContext *
gdk_x11_window_create_gl_context (GdkWindow *window,
gboolean attached,
@@ -664,7 +1017,6 @@ gdk_x11_window_create_gl_context (GdkWindow *window,
GdkDisplay *display;
GdkX11GLContext *context;
GdkVisual *visual;
GdkVisual *gdk_visual;
GLXFBConfig config;
GLXContext glx_context;
GLXWindow drawable;
@@ -675,7 +1027,7 @@ gdk_x11_window_create_gl_context (GdkWindow *window,
display = gdk_window_get_display (window);
if (!gdk_x11_display_init_gl (display))
if (!gdk_x11_screen_init_gl (gdk_window_get_screen (window)))
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_NOT_AVAILABLE,
@@ -711,6 +1063,7 @@ gdk_x11_window_create_gl_context (GdkWindow *window,
/* GDK_GL_PROFILE_DEFAULT is currently
* equivalent to the LEGACY profile
*/
profile = GDK_GL_PROFILE_LEGACY;
glx_context = create_gl_context (display, config, share);
}
@@ -773,9 +1126,6 @@ gdk_x11_window_create_gl_context (GdkWindow *window,
set_glx_drawable_info (window->impl_window, info);
}
gdk_visual = gdk_x11_screen_lookup_visual (gdk_display_get_default_screen (display),
xvisinfo->visualid);
XFree (xvisinfo);
if (attached)
@@ -789,8 +1139,10 @@ gdk_x11_window_create_gl_context (GdkWindow *window,
is_direct ? "direct" : "indirect"));
context = g_object_new (GDK_TYPE_X11_GL_CONTEXT,
"display", display,
"window", window,
"visual", gdk_visual,
"profile", profile,
"shared-context", share,
NULL);
context->profile = profile;
@@ -803,25 +1155,7 @@ gdk_x11_window_create_gl_context (GdkWindow *window,
return GDK_GL_CONTEXT (context);
}
void
gdk_x11_display_destroy_gl_context (GdkDisplay *display,
GdkGLContext *context)
{
GdkX11GLContext *context_x11 = GDK_X11_GL_CONTEXT (context);
Display *dpy = gdk_x11_display_get_xdisplay (display);
if (context_x11->glx_context != NULL)
{
if (glXGetCurrentContext () == context_x11->glx_context)
glXMakeContextCurrent (dpy, None, None, NULL);
GDK_NOTE (OPENGL, g_print ("Destroying GLX context\n"));
glXDestroyContext (dpy, context_x11->glx_context);
context_x11->glx_context = NULL;
}
}
void
gboolean
gdk_x11_display_make_gl_context_current (GdkDisplay *display,
GdkGLContext *context)
{
@@ -834,36 +1168,46 @@ gdk_x11_display_make_gl_context_current (GdkDisplay *display,
if (context == NULL)
{
glXMakeContextCurrent (dpy, None, None, NULL);
return;
return TRUE;
}
context_x11 = GDK_X11_GL_CONTEXT (context);
window = gdk_gl_context_get_window (context);
// If the WM is compositing there is no particular need to delay
// the swap when drawing on the offscreen, rendering to the screen
// happens later anyway, and its up to the compositor to sync that
// to the vblank.
screen = gdk_window_get_screen (window);
do_frame_sync = ! gdk_screen_is_composited (screen);
context_x11->do_frame_sync = do_frame_sync;
GDK_NOTE (OPENGL,
g_print ("Making GLX context current to drawable %lu\n",
(unsigned long) context_x11->drawable));
glXMakeContextCurrent (dpy, context_x11->drawable, context_x11->drawable,
context_x11->glx_context);
if (!glXMakeContextCurrent (dpy, context_x11->drawable, context_x11->drawable,
context_x11->glx_context))
{
GDK_NOTE (OPENGL,
g_print ("Making GLX context current failed\n"));
return FALSE;
}
if (context_x11->is_attached && GDK_X11_DISPLAY (display)->has_glx_swap_interval)
{
if (context_x11->do_frame_sync)
glXSwapIntervalSGI (1);
else
glXSwapIntervalSGI (0);
window = gdk_gl_context_get_window (context);
/* If the WM is compositing there is no particular need to delay
* the swap when drawing on the offscreen, rendering to the screen
* happens later anyway, and its up to the compositor to sync that
* to the vblank. */
screen = gdk_window_get_screen (window);
do_frame_sync = ! gdk_screen_is_composited (screen);
if (do_frame_sync != context_x11->do_frame_sync)
{
context_x11->do_frame_sync = do_frame_sync;
if (do_frame_sync)
glXSwapIntervalSGI (1);
else
glXSwapIntervalSGI (0);
}
}
return TRUE;
}
/**
@@ -888,7 +1232,7 @@ gdk_x11_display_get_glx_version (GdkDisplay *display,
if (!GDK_IS_X11_DISPLAY (display))
return FALSE;
if (!gdk_x11_display_init_gl (display))
if (!gdk_x11_screen_init_gl (gdk_display_get_default_screen (display)))
return FALSE;
if (major != NULL)
+3 -4
View File
@@ -49,6 +49,7 @@ struct _GdkX11GLContext
guint is_direct : 1;
guint do_frame_sync : 1;
guint do_blit_swap : 1;
};
struct _GdkX11GLContextClass
@@ -56,7 +57,7 @@ struct _GdkX11GLContextClass
GdkGLContextClass parent_class;
};
gboolean gdk_x11_display_init_gl (GdkDisplay *display);
gboolean gdk_x11_screen_init_gl (GdkScreen *screen);
GdkGLContext * gdk_x11_window_create_gl_context (GdkWindow *window,
gboolean attached,
GdkGLProfile profile,
@@ -64,9 +65,7 @@ GdkGLContext * gdk_x11_window_create_gl_context (GdkWindow
GError **error);
void gdk_x11_window_invalidate_for_new_frame (GdkWindow *window,
cairo_region_t *update_area);
void gdk_x11_display_destroy_gl_context (GdkDisplay *display,
GdkGLContext *context);
void gdk_x11_display_make_gl_context_current (GdkDisplay *display,
gboolean gdk_x11_display_make_gl_context_current (GdkDisplay *display,
GdkGLContext *context);
G_END_DECLS
+5 -4
View File
@@ -1058,6 +1058,7 @@ MyEnhancedXkbTranslateKeyCode(register XkbDescPtr xkb,
int col,nKeyGroups;
unsigned preserve,effectiveGroup;
KeySym *syms;
int found_col = 0;
if (mods_rtrn!=NULL)
*mods_rtrn = 0;
@@ -1090,7 +1091,7 @@ MyEnhancedXkbTranslateKeyCode(register XkbDescPtr xkb,
break;
}
}
col= effectiveGroup*XkbKeyGroupsWidth(xkb,key);
found_col = col= effectiveGroup*XkbKeyGroupsWidth(xkb,key);
type = XkbKeyKeyType(xkb,key,effectiveGroup);
preserve= 0;
@@ -1129,7 +1130,7 @@ MyEnhancedXkbTranslateKeyCode(register XkbDescPtr xkb,
}
if (!found && ((mods&type->mods.mask) == entry->mods.mask)) {
col+= entry->level;
found_col= col + entry->level;
if (type->preserve)
preserve= type->preserve[i].mask;
@@ -1143,7 +1144,7 @@ MyEnhancedXkbTranslateKeyCode(register XkbDescPtr xkb,
}
if (keysym_rtrn!=NULL)
*keysym_rtrn= syms[col];
*keysym_rtrn= syms[found_col];
if (mods_rtrn) {
/* ---- Begin section modified for GDK ---- */
*mods_rtrn &= ~preserve;
@@ -1175,7 +1176,7 @@ MyEnhancedXkbTranslateKeyCode(register XkbDescPtr xkb,
/* ---- End stuff GDK adds to the original Xlib version ---- */
return (syms[col] != NoSymbol);
return (syms[found_col] != NoSymbol);
}
#endif /* HAVE_XKB */
-4
View File
@@ -1128,11 +1128,7 @@ _gdk_x11_screen_new (GdkDisplay *display,
/* we want this to be always non-null */
x11_screen->window_manager_name = g_strdup ("unknown");
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
scale_str = g_getenv ("GDK_SCALE");
#else
scale_str = "1";
#endif
if (scale_str)
{
x11_screen->fixed_window_scale = TRUE;
+1
View File
@@ -113,6 +113,7 @@ GdkScreen * _gdk_x11_screen_new (GdkDisplay *display,
gint screen_number);
void _gdk_x11_screen_setup (GdkScreen *screen);
void _gdk_x11_screen_update_visuals_for_gl (GdkScreen *screen);
void _gdk_x11_screen_window_manager_changed (GdkScreen *screen);
void _gdk_x11_screen_size_changed (GdkScreen *screen,
XEvent *event);
+7 -1
View File
@@ -276,7 +276,8 @@ _gdk_x11_screen_init_visuals (GdkScreen *screen)
* Additional formats (like ABGR) could be added later if they
* turn up.
*/
if (visuals[i]->depth == 32 &&
if (x11_screen->rgba_visual == NULL &&
visuals[i]->depth == 32 &&
(visuals[i]->red_mask == 0xff0000 &&
visuals[i]->green_mask == 0x00ff00 &&
visuals[i]->blue_mask == 0x0000ff))
@@ -340,6 +341,11 @@ _gdk_x11_screen_init_visuals (GdkScreen *screen)
x11_screen->visuals = visuals;
x11_screen->nvisuals = nvisuals;
/* If GL is available we want to pick better default/rgba visuals,
as we care about glx details such as alpha/depth/stencil depth,
stereo and double buffering */
_gdk_x11_screen_update_visuals_for_gl (screen);
}
gint
+142 -50
View File
@@ -38,6 +38,7 @@
#include "gdkdisplay-x11.h"
#include "gdkglcontext-x11.h"
#include "gdkprivate-x11.h"
#include "gdk-private.h"
#include <stdlib.h>
#include <stdio.h>
@@ -52,6 +53,7 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/Xlib-xcb.h>
#include <X11/extensions/shape.h>
@@ -71,6 +73,10 @@
#include <X11/extensions/Xdamage.h>
#endif
#ifdef HAVE_PRESENT
#include <xcb/present.h>
#endif
const int _gdk_x11_event_mask_table[21] =
{
ExposureMask,
@@ -180,8 +186,6 @@ _gdk_x11_window_get_toplevel (GdkWindow *window)
return impl->toplevel;
}
static const cairo_user_data_key_t gdk_x11_cairo_key;
/**
* _gdk_x11_window_update_size:
* @impl: a #GdkWindowImplX11.
@@ -195,11 +199,24 @@ _gdk_x11_window_update_size (GdkWindowImplX11 *impl)
if (impl->cairo_surface)
{
cairo_xlib_surface_set_size (impl->cairo_surface,
gdk_window_get_width (impl->wrapper) * impl->window_scale,
gdk_window_get_height (impl->wrapper) * impl->window_scale);
impl->unscaled_width, impl->unscaled_height);
}
}
void
gdk_x11_window_get_unscaled_size (GdkWindow *window,
int *unscaled_width,
int *unscaled_height)
{
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
if (unscaled_width)
*unscaled_width = impl->unscaled_width;
if (unscaled_height)
*unscaled_height = impl->unscaled_height;
}
static void
set_sync_counter(Display *display,
XSyncCounter counter,
@@ -207,10 +224,10 @@ set_sync_counter(Display *display,
{
XSyncValue sync_value;
XSyncIntsToValue(&sync_value,
value & G_GINT64_CONSTANT(0xFFFFFFFF),
value >> 32);
XSyncSetCounter(display, counter, sync_value);
XSyncIntsToValue (&sync_value,
value & G_GINT64_CONSTANT(0xFFFFFFFF),
value >> 32);
XSyncSetCounter (display, counter, sync_value);
}
static void
@@ -228,9 +245,9 @@ window_pre_damage (GdkWindow *window)
impl->toplevel->current_counter_value % 2 == 0)
{
impl->toplevel->current_counter_value += 1;
set_sync_counter(GDK_WINDOW_XDISPLAY (impl->wrapper),
impl->toplevel->extended_update_counter,
impl->toplevel->current_counter_value);
set_sync_counter (GDK_WINDOW_XDISPLAY (impl->wrapper),
impl->toplevel->extended_update_counter,
impl->toplevel->current_counter_value);
}
}
@@ -441,14 +458,6 @@ gdk_x11_window_end_frame (GdkWindow *window)
* X11 specific implementations of generic functions *
*****************************************************/
static void
gdk_x11_cairo_surface_destroy (void *data)
{
GdkWindowImplX11 *impl = data;
impl->cairo_surface = NULL;
}
static cairo_surface_t *
gdk_x11_create_cairo_surface (GdkWindowImplX11 *impl,
int width,
@@ -476,19 +485,13 @@ gdk_x11_ref_cairo_surface (GdkWindow *window)
impl->cairo_surface = gdk_x11_create_cairo_surface (impl,
gdk_window_get_width (window) * impl->window_scale,
gdk_window_get_height (window) * impl->window_scale);
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
cairo_surface_set_device_scale (impl->cairo_surface, impl->window_scale, impl->window_scale);
#endif
if (impl->cairo_surface)
cairo_surface_set_user_data (impl->cairo_surface, &gdk_x11_cairo_key,
impl, gdk_x11_cairo_surface_destroy);
if (WINDOW_IS_TOPLEVEL (window) && impl->toplevel->in_frame)
hook_surface_changed (window);
}
else
cairo_surface_reference (impl->cairo_surface);
cairo_surface_reference (impl->cairo_surface);
return impl->cairo_surface;
}
@@ -749,6 +752,8 @@ _gdk_x11_screen_init_root_window (GdkScreen *screen)
window->y = 0;
window->abs_x = 0;
window->abs_y = 0;
impl->unscaled_width = WidthOfScreen (x11_screen->xscreen);
impl->unscaled_height = HeightOfScreen (x11_screen->xscreen);
window->width = WidthOfScreen (x11_screen->xscreen) / impl->window_scale;
window->height = HeightOfScreen (x11_screen->xscreen) / impl->window_scale;
window->viewable = TRUE;
@@ -1095,6 +1100,9 @@ _gdk_x11_display_create_window_impl (GdkDisplay *display,
window->height = 32767 / impl->window_scale;
}
impl->unscaled_width = window->width * impl->window_scale;
impl->unscaled_height = window->height * impl->window_scale;
impl->xid = XCreateWindow (xdisplay, xparent,
(window->x + window->parent->abs_x) * impl->window_scale,
(window->y + window->parent->abs_y) * impl->window_scale,
@@ -1143,7 +1151,7 @@ _gdk_x11_display_create_window_impl (GdkDisplay *display,
connect_frame_clock (window);
if (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD)
gdk_window_freeze_toplevel_updates_libgtk_only (window);
gdk_window_freeze_toplevel_updates (window);
}
static GdkEventMask
@@ -1244,6 +1252,8 @@ gdk_x11_window_foreign_new_for_display (GdkDisplay *display,
win->x = attrs.x / impl->window_scale;
win->y = attrs.y / impl->window_scale;
impl->unscaled_width = attrs.width;
impl->unscaled_height = attrs.height;
win->width = attrs.width / impl->window_scale;
win->height = attrs.height / impl->window_scale;
win->window_type = GDK_WINDOW_FOREIGN;
@@ -1318,8 +1328,8 @@ gdk_x11_window_destroy (GdkWindow *window,
if (impl->cairo_surface)
{
cairo_surface_finish (impl->cairo_surface);
cairo_surface_set_user_data (impl->cairo_surface, &gdk_x11_cairo_key,
NULL, NULL);
cairo_surface_destroy (impl->cairo_surface);
impl->cairo_surface = NULL;
}
if (!recursing && !foreign_destroy)
@@ -1804,13 +1814,15 @@ window_x11_resize (GdkWindow *window,
if (impl->override_redirect)
{
impl->unscaled_width = width * impl->window_scale;
impl->unscaled_height = height * impl->window_scale;
window->width = width;
window->height = height;
_gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
}
else
{
if (width != window->width || height != window->height)
if (width * impl->window_scale != impl->unscaled_width || height * impl->window_scale != impl->unscaled_height)
window->resize_count += 1;
}
}
@@ -1850,6 +1862,8 @@ window_x11_move_resize (GdkWindow *window,
window->x = x;
window->y = y;
impl->unscaled_width = width * impl->window_scale;
impl->unscaled_height = height * impl->window_scale;
window->width = width;
window->height = height;
@@ -1857,7 +1871,7 @@ window_x11_move_resize (GdkWindow *window,
}
else
{
if (width != window->width || height != window->height)
if (width * impl->window_scale != impl->unscaled_width || height * impl->window_scale != impl->unscaled_height)
window->resize_count += 1;
}
}
@@ -1913,6 +1927,11 @@ _gdk_x11_window_set_window_scale (GdkWindow *window,
impl = GDK_WINDOW_IMPL_X11 (window->impl);
impl->window_scale = scale;
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
if (impl->cairo_surface)
cairo_surface_set_device_scale (impl->cairo_surface, impl->window_scale, impl->window_scale);
#endif
_gdk_window_update_size (window);
toplevel = _gdk_x11_window_get_toplevel (window);
if (toplevel && window->window_type != GDK_WINDOW_FOREIGN)
@@ -1932,17 +1951,30 @@ _gdk_x11_window_set_window_scale (GdkWindow *window,
(window->x + window->parent->abs_x) * impl->window_scale,
(window->y + window->parent->abs_y) * impl->window_scale);
else if (WINDOW_IS_TOPLEVEL(window))
XResizeWindow (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
window->width * impl->window_scale,
window->height * impl->window_scale);
{
if (impl->override_redirect)
{
impl->unscaled_width = window->width * impl->window_scale;
impl->unscaled_height = window->height * impl->window_scale;
}
XResizeWindow (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
window->width * impl->window_scale,
window->height * impl->window_scale);
}
else
XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
(window->x + window->parent->abs_x) * impl->window_scale,
(window->y + window->parent->abs_y) * impl->window_scale,
window->width * impl->window_scale,
window->height * impl->window_scale);
{
impl->unscaled_width = window->width * impl->window_scale;
impl->unscaled_height = window->height * impl->window_scale;
XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
(window->x + window->parent->abs_x) * impl->window_scale,
(window->y + window->parent->abs_y) * impl->window_scale,
window->width * impl->window_scale,
window->height * impl->window_scale);
}
gdk_window_invalidate_rect (window, NULL, TRUE);
@@ -2969,9 +3001,7 @@ gdk_window_x11_set_background (GdkWindow *window,
cairo_surface_get_device_offset (surface, &x, &y);
sx = sy = 1.;
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
cairo_surface_get_device_scale (surface, &sx, &sy);
#endif
/* XXX: This still bombs for non-pixmaps, but there's no way to
* detect we're not a pixmap in Cairo... */
if (x == 0.0 && y == 0.0 &&
@@ -3251,10 +3281,14 @@ gdk_x11_window_get_frame_extents (GdkWindow *window,
if (vroots)
XFree (vroots);
rect->x /= impl->window_scale;
rect->y /= impl->window_scale;
rect->width /= impl->window_scale;
rect->height /= impl->window_scale;
/* Here we extend the size to include the extra pixels if we round x/y down
as well as round the size up when we divide by scale so that the returned
size is guaranteed to cover the real pixels, but it may overshoot a bit
in case the window is not positioned/sized according to the scale */
rect->width = (rect->width + rect->x % impl->window_scale + impl->window_scale - 1) / impl->window_scale;
rect->height = (rect->height + rect->y % impl->window_scale + impl->window_scale - 1) / impl->window_scale;
rect->x = rect->x / impl->window_scale;
rect->y = rect->y / impl->window_scale;
gdk_x11_display_error_trap_pop_ignored (display);
}
@@ -3369,7 +3403,7 @@ do_shape_combine_region (GdkWindow *window,
_gdk_x11_region_get_xrectangles (shape_region,
0, 0, impl->window_scale,
&xrects, &n_rects);
if (shape == ShapeBounding)
{
_gdk_x11_window_tmp_unset_parent_bg (window);
@@ -3624,8 +3658,14 @@ gdk_x11_window_set_shadow_width (GdkWindow *window,
int top,
int bottom)
{
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
Atom frame_extents;
gulong data[4] = { left, right, top, bottom };
gulong data[4] = {
left * impl->window_scale,
right * impl->window_scale,
top * impl->window_scale,
bottom * impl->window_scale
};
frame_extents = gdk_x11_get_xatom_by_name_for_display (gdk_window_get_display (window),
"_GTK_FRAME_EXTENTS");
@@ -5648,6 +5688,56 @@ gdk_x11_window_show_window_menu (GdkWindow *window,
return TRUE;
}
static gboolean
gdk_x11_window_do_composite (GdkWindow *window)
{
GdkDisplay *display = gdk_window_get_display (window);
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
#ifdef HAVE_PRESENT
if (display_x11->have_present)
{
Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);
xcb_connection_t *xcb_conn = XGetXCBConnection (xdisplay);
XserverRegion update_region;
XRectangle *rects;
int n_rects;
double sx, sy;
double offs_x, offs_y;
cairo_surface_get_device_scale (window->current_paint.surface, &sx, &sy);
cairo_surface_get_device_offset (window->current_paint.surface, &offs_x, &offs_y);
_gdk_x11_region_get_xrectangles (window->current_paint.region,
offs_x / sx, offs_y / sy, sx, &rects, &n_rects);
update_region = XFixesCreateRegion (xdisplay, rects, n_rects);
xcb_present_pixmap (xcb_conn,
GDK_WINDOW_XID (window),
cairo_xlib_surface_get_drawable (window->current_paint.surface),
XNextRequest (xdisplay),
update_region,
update_region,
-offs_x,
-offs_y,
None, /* target_crtc */
None, /* wait_fence */
None, /* idle_fence */
0, /* options */
0, /* target_msc */
0, /* divisor */
0, /* remainder */
0, NULL /* notifies */ );
XFixesDestroyRegion (xdisplay, update_region);
return TRUE;
}
#endif
return FALSE;
}
static void
gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
{
@@ -5737,4 +5827,6 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
impl_class->show_window_menu = gdk_x11_window_show_window_menu;
impl_class->create_gl_context = gdk_x11_window_create_gl_context;
impl_class->invalidate_for_new_frame = gdk_x11_window_invalidate_for_new_frame;
impl_class->get_unscaled_size = gdk_x11_window_get_unscaled_size;
impl_class->do_composite = gdk_x11_window_do_composite;
}
+8
View File
@@ -76,6 +76,14 @@ struct _GdkWindowImplX11
gint window_scale;
/* Width and height not divided by window_scale - this matters in the
* corner-case where the window manager assigns us a size that isn't
* a multiple of window_scale - for example for a maximized window
* with an odd-sized title-bar.
*/
gint unscaled_width;
gint unscaled_height;
cairo_surface_t *cairo_surface;
#if defined (HAVE_XCOMPOSITE) && defined(HAVE_XDAMAGE) && defined (HAVE_XFIXES)
+16 -3
View File
@@ -393,6 +393,7 @@ gtk_public_h_sources = \
gtkmenushell.h \
gtkmenutoolbutton.h \
gtkmessagedialog.h \
gtkmodelbutton.h \
gtkmodules.h \
gtkmountoperation.h \
gtknotebook.h \
@@ -405,6 +406,7 @@ gtk_public_h_sources = \
gtkplacessidebar.h \
gtkplug.h \
gtkpopover.h \
gtkpopovermenu.h \
gtkprintcontext.h \
gtkprintoperation.h \
gtkprintoperationpreview.h \
@@ -624,7 +626,6 @@ gtk_private_h_sources = \
gtkmenutrackeritem.h \
gtkmnemonichash.h \
gtkmodelmenuitem.h \
gtkmodelbutton.h \
gtkmodifierstyle.h \
gtkmodulesprivate.h \
gtkmountoperationprivate.h \
@@ -1008,6 +1009,7 @@ gtk_base_c_sources = \
gtkprogressbar.c \
gtkpixelcache.c \
gtkpopover.c \
gtkpopovermenu.c \
gtkradiobutton.c \
gtkradiomenuitem.c \
gtkradiotoolbutton.c \
@@ -1403,6 +1405,7 @@ gtk.gresource.xml: Makefile.am
n=`basename $$f`; \
$(ECHO) " <file preprocess=\"to-pixdata\">theme/Adwaita/assets/$$n</file>" >> $@; \
done; \
$(ECHO) " <file alias=\"theme/HighContrast.css\">theme/HighContrast/gtk.css</file>" >> $@; \
if test "$(win32_theme)" = "yes"; then \
for f in $(srcdir)/resources/theme/win32/*.css; do \
n=`basename $$f`; \
@@ -1450,7 +1453,16 @@ adwaita_sources = \
resources/theme/Adwaita/gtk.css \
resources/theme/Adwaita/gtk-dark.css
Raleigh_sources = \
highcontrast_sources = \
resources/theme/HighContrast/_colors.scss \
resources/theme/HighContrast/_common.scss \
resources/theme/HighContrast/_drawing.scss \
resources/theme/HighContrast/Gemfile \
resources/theme/HighContrast/gtk.css \
resources/theme/HighContrast/gtk.scss \
resources/theme/HighContrast/parse-sass.sh
raleigh_sources = \
resources/theme/Raleigh/gtk-default.css
resource_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir)/resources --generate-dependencies $(builddir)/gtk.gresource.xml)
@@ -1729,7 +1741,8 @@ gsettings_SCHEMAS = \
EXTRA_DIST += \
$(resource_files) \
$(adwaita_sources) \
$(Raleigh_sources) \
$(highcontrast_sources) \
$(raleigh_sources) \
$(win32_theme_sources) \
$(gsettings_SCHEMAS) \
$(template_headers) \
+2 -2
View File
@@ -7,10 +7,10 @@
<glade-widget-classes>
<!-- base GTK+ private widgets -->
<glade-widget-class name="GtkPathBar" generic-name="pathbar" title="Path Bar" icon-name="widget-gtk-toolbar"/>
<glade-widget-class name="GtkColorEditor" generic-name="coloreditor" title="Color Editor" icon-name="widget-gtk-colorselection"/>
<glade-widget-class name="GtkColorSwatch" generic-name="colorswatch" title="Color Swatch" icon-name="widget-gtk-colorselection"/>
<glade-widget-class name="GtkColorPlane" generic-name="colorplane" title="Color Plane" icon-name="widget-gtk-colorselection"/>
<glade-widget-class name="GtkColorScale" generic-name="colorscale" title="Color Scale" icon-name="widget-gtk-colorselection"/>
<glade-widget-class name="GtkScaleButtonScale" generic-name="scalebuttonscale" title="Scale Button Scale"/>
<!-- gtkunixprint private widgets -->
<glade-widget-class name="GtkPrinterOptionWidget" generic-name="printeroptionwidget" title="Printer Option Widget"
@@ -24,10 +24,10 @@
<glade-widget-group name="gtk-private" title="Private GTK+ Classes">
<glade-widget-class-ref name="GtkPathBar"/>
<glade-widget-class-ref name="GtkColorEditor"/>
<glade-widget-class-ref name="GtkColorSwatch"/>
<glade-widget-class-ref name="GtkColorPlane"/>
<glade-widget-class-ref name="GtkColorScale"/>
<glade-widget-class-ref name="GtkScaleButtonScale"/>
<glade-widget-class-ref name="GtkPrinterOptionWidget"/>
</glade-widget-group>
</glade-catalog>
+2
View File
@@ -141,6 +141,7 @@
#include <gtk/gtkmenushell.h>
#include <gtk/gtkmenutoolbutton.h>
#include <gtk/gtkmessagedialog.h>
#include <gtk/gtkmodelbutton.h>
#include <gtk/gtkmodules.h>
#include <gtk/gtkmountoperation.h>
#include <gtk/gtknotebook.h>
@@ -152,6 +153,7 @@
#include <gtk/gtkpaned.h>
#include <gtk/gtkplacessidebar.h>
#include <gtk/gtkpopover.h>
#include <gtk/gtkpopovermenu.h>
#include <gtk/gtkprintcontext.h>
#include <gtk/gtkprintoperation.h>
#include <gtk/gtkprintoperationpreview.h>
+31 -6
View File
@@ -219,7 +219,9 @@ static void gtk_about_dialog_set_property (GObject
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_about_dialog_show (GtkWidget *widge);
static void gtk_about_dialog_realize (GtkWidget *widget);
static void gtk_about_dialog_unrealize (GtkWidget *widget);
static void gtk_about_dialog_show (GtkWidget *widget);
static void update_name_version (GtkAboutDialog *about);
static void follow_if_link (GtkAboutDialog *about,
GtkTextView *text_view,
@@ -304,6 +306,8 @@ gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
object_class->finalize = gtk_about_dialog_finalize;
widget_class->show = gtk_about_dialog_show;
widget_class->realize = gtk_about_dialog_realize;
widget_class->unrealize = gtk_about_dialog_unrealize;
klass->activate_link = gtk_about_dialog_activate_link;
@@ -736,8 +740,6 @@ gtk_about_dialog_init (GtkAboutDialog *about)
priv->documenters = NULL;
priv->artists = NULL;
priv->hand_cursor = gdk_cursor_new (GDK_HAND2);
priv->regular_cursor = gdk_cursor_new (GDK_XTERM);
priv->hovering_over_link = FALSE;
priv->wrap_license = FALSE;
@@ -791,12 +793,35 @@ gtk_about_dialog_finalize (GObject *object)
g_slist_foreach (priv->visited_links, (GFunc)g_free, NULL);
g_slist_free (priv->visited_links);
g_object_unref (priv->hand_cursor);
g_object_unref (priv->regular_cursor);
G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object);
}
static void
gtk_about_dialog_realize (GtkWidget *widget)
{
GtkAboutDialog *about = GTK_ABOUT_DIALOG (widget);
GtkAboutDialogPrivate *priv = about->priv;
GdkDisplay *display;
GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->realize (widget);
display = gtk_widget_get_display (widget);
priv->hand_cursor = gdk_cursor_new_for_display (display, GDK_HAND2);
priv->regular_cursor = gdk_cursor_new_for_display (display, GDK_XTERM);
}
static void
gtk_about_dialog_unrealize (GtkWidget *widget)
{
GtkAboutDialog *about = GTK_ABOUT_DIALOG (widget);
GtkAboutDialogPrivate *priv = about->priv;
g_clear_object (&priv->hand_cursor);
g_clear_object (&priv->regular_cursor);
GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->unrealize (widget);
}
static void
gtk_about_dialog_set_property (GObject *object,
guint prop_id,
+17 -17
View File
@@ -47,7 +47,7 @@
struct _GtkActionBarPrivate
{
GtkWidget *center_box;
GtkWidget *box;
GtkWidget *revealer;
};
@@ -101,13 +101,13 @@ gtk_action_bar_add (GtkContainer *container,
/* When constructing the widget, we want the revealer to be added
* as the first child of the bar, as an implementation detail.
* After that, the child added by the application should be added
* to center_box.
* to box.
*/
if (priv->center_box == NULL)
if (priv->box == NULL)
GTK_CONTAINER_CLASS (gtk_action_bar_parent_class)->add (container, child);
else
gtk_container_add (GTK_CONTAINER (priv->center_box), child);
gtk_container_add (GTK_CONTAINER (priv->box), child);
}
static void
@@ -119,7 +119,7 @@ gtk_action_bar_remove (GtkContainer *container,
if (child == priv->revealer)
GTK_CONTAINER_CLASS (gtk_action_bar_parent_class)->remove (container, child);
else
gtk_container_remove (GTK_CONTAINER (priv->center_box), child);
gtk_container_remove (GTK_CONTAINER (priv->box), child);
}
static void
@@ -133,8 +133,8 @@ gtk_action_bar_forall (GtkContainer *container,
if (include_internals)
(* callback) (priv->revealer, callback_data);
if (priv->center_box)
gtk_container_forall (GTK_CONTAINER (priv->center_box), callback, callback_data);
if (priv->box)
gtk_container_forall (GTK_CONTAINER (priv->box), callback, callback_data);
}
static void
@@ -187,7 +187,7 @@ gtk_action_bar_get_child_property (GtkContainer *container,
if (child == priv->revealer)
g_param_value_set_default (pspec, value);
else
gtk_container_child_get_property (GTK_CONTAINER (priv->center_box),
gtk_container_child_get_property (GTK_CONTAINER (priv->box),
child,
pspec->name,
value);
@@ -203,7 +203,7 @@ gtk_action_bar_set_child_property (GtkContainer *container,
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (GTK_ACTION_BAR (container));
if (child != priv->revealer)
gtk_container_child_set_property (GTK_CONTAINER (priv->center_box),
gtk_container_child_set_property (GTK_CONTAINER (priv->box),
child,
pspec->name,
value);
@@ -218,7 +218,7 @@ gtk_action_bar_get_path_for_child (GtkContainer *container,
if (child == priv->revealer)
return GTK_CONTAINER_CLASS (gtk_action_bar_parent_class)->get_path_for_child (container, child);
else
return gtk_container_get_path_for_child (GTK_CONTAINER (priv->center_box), child);
return gtk_container_get_path_for_child (GTK_CONTAINER (priv->box), child);
}
static void
@@ -257,10 +257,10 @@ gtk_action_bar_class_init (GtkActionBarClass *klass)
P_("Position"),
P_("The index of the child in the parent"),
-1, G_MAXINT, 0,
G_PARAM_READABLE));
G_PARAM_READWRITE));
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/ui/gtkactionbar.ui");
gtk_widget_class_bind_template_child_internal_private (widget_class, GtkActionBar, center_box);
gtk_widget_class_bind_template_child_internal_private (widget_class, GtkActionBar, box);
gtk_widget_class_bind_template_child_internal_private (widget_class, GtkActionBar, revealer);
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_PANEL);
@@ -289,7 +289,7 @@ gtk_action_bar_buildable_add_child (GtkBuildable *buildable,
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
if (type && strcmp (type, "center") == 0)
gtk_box_set_center_widget (GTK_BOX (priv->center_box), GTK_WIDGET (child));
gtk_box_set_center_widget (GTK_BOX (priv->box), GTK_WIDGET (child));
else if (!type)
gtk_container_add (GTK_CONTAINER (buildable), GTK_WIDGET (child));
else
@@ -321,7 +321,7 @@ gtk_action_bar_pack_start (GtkActionBar *action_bar,
{
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
gtk_box_pack_start (GTK_BOX (priv->center_box), child, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (priv->box), child, FALSE, TRUE, 0);
}
/**
@@ -340,7 +340,7 @@ gtk_action_bar_pack_end (GtkActionBar *action_bar,
{
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
gtk_box_pack_end (GTK_BOX (priv->center_box), child, FALSE, TRUE, 0);
gtk_box_pack_end (GTK_BOX (priv->box), child, FALSE, TRUE, 0);
}
/**
@@ -358,7 +358,7 @@ gtk_action_bar_set_center_widget (GtkActionBar *action_bar,
{
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
gtk_box_set_center_widget (GTK_BOX (priv->center_box), center_widget);
gtk_box_set_center_widget (GTK_BOX (priv->box), center_widget);
}
/**
@@ -378,7 +378,7 @@ gtk_action_bar_get_center_widget (GtkActionBar *action_bar)
g_return_val_if_fail (GTK_IS_ACTION_BAR (action_bar), NULL);
return gtk_box_get_center_widget (GTK_BOX (priv->center_box));
return gtk_box_get_center_widget (GTK_BOX (priv->box));
}
/**
+38 -3
View File
@@ -23,6 +23,8 @@
#include "gtkwidget.h"
#include "gtkwidgetprivate.h"
#include "gtkdebug.h"
#include "gtkmodelbutton.h"
#include "gtktypebuiltins.h"
#include <string.h>
@@ -66,6 +68,8 @@ struct _GtkActionHelper
gboolean enabled;
gboolean active;
GtkButtonRole role;
gint reporting;
};
@@ -74,6 +78,7 @@ enum
PROP_0,
PROP_ENABLED,
PROP_ACTIVE,
PROP_ROLE,
N_PROPS
};
@@ -107,6 +112,17 @@ gtk_action_helper_report_change (GtkActionHelper *helper,
}
break;
case PROP_ROLE:
{
GParamSpec *pspec;
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (helper->widget), "role");
if (pspec && G_PARAM_SPEC_VALUE_TYPE (pspec) == GTK_TYPE_BUTTON_ROLE)
g_object_set (G_OBJECT (helper->widget), "role", helper->role, NULL);
}
break;
default:
g_assert_not_reached ();
}
@@ -146,10 +162,19 @@ gtk_action_helper_action_added (GtkActionHelper *helper,
GTK_NOTE(ACTIONS, g_message("actionhelper: %s found and enabled", helper->action_name));
if (helper->target != NULL && state != NULL)
helper->active = g_variant_equal (state, helper->target);
{
helper->active = g_variant_equal (state, helper->target);
helper->role = GTK_BUTTON_ROLE_RADIO;
}
else if (state != NULL && g_variant_is_of_type (state, G_VARIANT_TYPE_BOOLEAN))
helper->active = g_variant_get_boolean (state);
{
helper->active = g_variant_get_boolean (state);
helper->role = GTK_BUTTON_ROLE_CHECK;
}
else
{
helper->role = GTK_BUTTON_ROLE_NORMAL;
}
if (should_emit_signals)
{
@@ -158,6 +183,8 @@ gtk_action_helper_action_added (GtkActionHelper *helper,
if (helper->active)
gtk_action_helper_report_change (helper, PROP_ACTIVE);
gtk_action_helper_report_change (helper, PROP_ROLE);
}
}
@@ -242,6 +269,10 @@ gtk_action_helper_get_property (GObject *object, guint prop_id,
g_value_set_boolean (value, helper->active);
break;
case PROP_ROLE:
g_value_set_enum (value, helper->role);
break;
default:
g_assert_not_reached ();
}
@@ -313,6 +344,10 @@ gtk_action_helper_class_init (GtkActionHelperClass *class)
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
gtk_action_helper_pspecs[PROP_ACTIVE] = g_param_spec_boolean ("active", "active", "active", FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
gtk_action_helper_pspecs[PROP_ROLE] = g_param_spec_enum ("role", "role", "role",
GTK_TYPE_BUTTON_ROLE,
GTK_BUTTON_ROLE_NORMAL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (class, N_PROPS, gtk_action_helper_pspecs);
}
+12 -2
View File
@@ -334,6 +334,7 @@ gtk_application_impl_dbus_inhibit (GtkApplicationImpl *impl,
GVariant *res;
GError *error = NULL;
guint cookie;
static gboolean warned = FALSE;
if (dbus->sm_proxy == NULL)
return 0;
@@ -352,7 +353,11 @@ gtk_application_impl_dbus_inhibit (GtkApplicationImpl *impl,
if (error)
{
g_warning ("Calling Inhibit failed: %s", error->message);
if (!warned)
{
g_warning ("Calling Inhibit failed: %s", error->message);
warned = TRUE;
}
g_error_free (error);
return 0;
}
@@ -390,6 +395,7 @@ gtk_application_impl_dbus_is_inhibited (GtkApplicationImpl *impl,
GVariant *res;
GError *error = NULL;
gboolean inhibited;
static gboolean warned = FALSE;
if (dbus->sm_proxy == NULL)
return FALSE;
@@ -403,7 +409,11 @@ gtk_application_impl_dbus_is_inhibited (GtkApplicationImpl *impl,
&error);
if (error)
{
g_warning ("Calling IsInhibited failed: %s", error->message);
if (!warned)
{
g_warning ("Calling IsInhibited failed: %s", error->message);
warned = TRUE;
}
g_error_free (error);
return FALSE;
}
+22 -6
View File
@@ -140,6 +140,23 @@ flip_buffer (guchar *dst_buffer,
#undef BLOCK_SIZE
}
/*
* Gets the size for a single box blur.
*
* Much of this, the 3 * sqrt(2 * pi) / 4, is the known value for
* approximating a Gaussian using box blurs. This yields quite a good
* approximation for a Gaussian. For more details, see:
* http://www.w3.org/TR/SVG11/filters.html#feGaussianBlurElement
* https://bugzilla.mozilla.org/show_bug.cgi?id=590039#c19
*/
#define GAUSSIAN_SCALE_FACTOR ((3.0 * sqrt(2 * G_PI) / 4))
static int
get_box_filter_size (double radius)
{
return GAUSSIAN_SCALE_FACTOR * radius;
}
static void
_boxblur (guchar *buffer,
int width,
@@ -147,6 +164,7 @@ _boxblur (guchar *buffer,
int radius)
{
guchar *flipped_buffer;
int d = get_box_filter_size (radius);
flipped_buffer = g_malloc (width * height);
@@ -154,13 +172,13 @@ _boxblur (guchar *buffer,
flip_buffer (flipped_buffer, buffer, width, height);
/* Step 2: blur rows (really columns) */
blur_rows (flipped_buffer, buffer, height, width, radius);
blur_rows (flipped_buffer, buffer, height, width, d);
/* Step 3: swap rows and columns */
flip_buffer (buffer, flipped_buffer, height, width);
/* Step 4: blur rows */
blur_rows (buffer, flipped_buffer, width, height, radius);
blur_rows (buffer, flipped_buffer, width, height, d);
g_free (flipped_buffer);
}
@@ -209,7 +227,7 @@ _gtk_cairo_blur_surface (cairo_surface_t* surface,
*
* This is just the number of pixels added by the blur radius, shadow
* offset and spread are not included.
*
*
* Much of this, the 3 * sqrt(2 * pi) / 4, is the known value for
* approximating a Gaussian using box blurs. This yields quite a good
* approximation for a Gaussian. Then we multiply this by 1.5 since our
@@ -218,10 +236,8 @@ _gtk_cairo_blur_surface (cairo_surface_t* surface,
* http://www.w3.org/TR/SVG11/filters.html#feGaussianBlurElement
* https://bugzilla.mozilla.org/show_bug.cgi?id=590039#c19
*/
#define GAUSSIAN_SCALE_FACTOR ((3.0 * sqrt(2 * G_PI) / 4) * 1.5)
int
_gtk_cairo_blur_compute_pixels (double radius)
{
return floor (radius * GAUSSIAN_SCALE_FACTOR + 0.5);
return floor (radius * GAUSSIAN_SCALE_FACTOR * 1.5 + 0.5);
}
+9 -2
View File
@@ -51,6 +51,7 @@
#include "gtkwidgetpath.h"
#include "a11y/gtkcontaineraccessible.h"
#include "a11y/gtkcontaineraccessibleprivate.h"
#include "gtkpopovermenu.h"
/**
* SECTION:gtkcontainer
@@ -608,7 +609,10 @@ gtk_container_buildable_set_child_property (GtkContainer *container,
GValue gvalue = G_VALUE_INIT;
GError *error = NULL;
if (gtk_widget_get_parent (child) != (GtkWidget *)container && !GTK_IS_ASSISTANT (container) && !GTK_IS_ACTION_BAR (container))
if (gtk_widget_get_parent (child) != (GtkWidget *)container &&
!GTK_IS_ASSISTANT (container) &&
!GTK_IS_ACTION_BAR (container) &&
!GTK_IS_POPOVER_MENU (container))
{
/* This can happen with internal children of complex widgets.
* Silently ignore the child properties in this case. We explicitly
@@ -1718,7 +1722,10 @@ gtk_container_remove (GtkContainer *container,
{
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (gtk_widget_get_parent (widget) == GTK_WIDGET (container) || GTK_IS_ASSISTANT (container) || GTK_IS_ACTION_BAR (container));
g_return_if_fail (gtk_widget_get_parent (widget) == GTK_WIDGET (container) ||
GTK_IS_ASSISTANT (container) ||
GTK_IS_ACTION_BAR (container) ||
GTK_IS_POPOVER_MENU (container));
g_object_ref (container);
g_object_ref (widget);
+94 -40
View File
@@ -44,6 +44,7 @@
#include "gtkmarshalers.h"
#include "gtkprivate.h"
#include "gtkintl.h"
#include "gtkversion.h"
/**
* SECTION:gtkcssprovider
@@ -2947,7 +2948,6 @@ _gtk_css_provider_get_theme_dir (void)
gchar *path;
var = g_getenv ("GTK_DATA_PREFIX");
if (var)
path = g_build_filename (var, "share", "themes", NULL);
else
@@ -2956,6 +2956,96 @@ _gtk_css_provider_get_theme_dir (void)
return path;
}
#if (GTK_MINOR_VERSION % 2)
#define MINOR (GTK_MINOR_VERSION + 1)
#else
#define MINOR GTK_MINOR_VERSION
#endif
/*
* Look for
* $dir/$subdir/gtk-3.16/gtk-$variant.css
* $dir/$subdir/gtk-3.14/gtk-$variant.css
* ...
* $dir/$subdir/gtk-3.0/gtk-$variant.css
* and return the first found file.
* We don't check versions before 3.14,
* since those GTK+ versions didn't have
* the versioned loading mechanism.
*/
static gchar *
_gtk_css_find_theme_dir (const gchar *dir,
const gchar *subdir,
const gchar *name,
const gchar *variant)
{
gchar *file;
gchar *base;
gchar *subsubdir;
gint i;
gchar *path;
if (variant)
file = g_strconcat ("gtk-", variant, ".css", NULL);
else
file = g_strdup ("gtk.css");
if (subdir)
base = g_build_filename (dir, subdir, name, NULL);
else
base = g_build_filename (dir, name, NULL);
for (i = MINOR; i >= 0; i = i - 2)
{
if (i < 14)
i = 0;
subsubdir = g_strdup_printf ("gtk-3.%d", i);
path = g_build_filename (base, subsubdir, file, NULL);
g_free (subsubdir);
if (g_file_test (path, G_FILE_TEST_EXISTS))
break;
g_free (path);
path = NULL;
}
g_free (file);
g_free (base);
return path;
}
#undef MINOR
static gchar *
_gtk_css_find_theme (const gchar *name,
const gchar *variant)
{
gchar *path;
const gchar *var;
/* First look in the user's config directory */
path = _gtk_css_find_theme_dir (g_get_user_data_dir (), "themes", name, variant);
if (path)
return path;
/* Next look in the user's home directory */
path = _gtk_css_find_theme_dir (g_get_home_dir (), ".themes", name, variant);
if (path)
return path;
/* Finally, try in the default theme directory */
var = g_getenv ("GTK_DATA_PREFIX");
if (!var)
var = _gtk_get_data_prefix ();
path = _gtk_css_find_theme_dir (var, "share" G_DIR_SEPARATOR_S "themes", name, variant);
return path;
}
/**
* _gtk_css_provider_load_named:
* @provider: a #GtkCssProvider
@@ -2973,7 +3063,7 @@ _gtk_css_provider_load_named (GtkCssProvider *provider,
const gchar *name,
const gchar *variant)
{
gchar *subpath, *path;
gchar *path;
gchar *resource_path;
g_return_if_fail (GTK_IS_CSS_PROVIDER (provider));
@@ -2997,44 +3087,8 @@ _gtk_css_provider_load_named (GtkCssProvider *provider,
}
g_free (resource_path);
/* Next try looking for files in the various theme directories.
*/
if (variant)
subpath = g_strdup_printf ("gtk-3.0" G_DIR_SEPARATOR_S "gtk-%s.css", variant);
else
subpath = g_strdup ("gtk-3.0" G_DIR_SEPARATOR_S "gtk.css");
/* First look in the user's config directory
*/
path = g_build_filename (g_get_user_data_dir (), "themes", name, subpath, NULL);
if (!g_file_test (path, G_FILE_TEST_EXISTS))
{
g_free (path);
/* Next look in the user's home directory
*/
path = g_build_filename (g_get_home_dir (), ".themes", name, subpath, NULL);
if (!g_file_test (path, G_FILE_TEST_EXISTS))
{
gchar *theme_dir;
g_free (path);
/* Finally, try in the default theme directory */
theme_dir = _gtk_css_provider_get_theme_dir ();
path = g_build_filename (theme_dir, name, subpath, NULL);
g_free (theme_dir);
if (!g_file_test (path, G_FILE_TEST_EXISTS))
{
g_free (path);
path = NULL;
}
}
}
g_free (subpath);
/* Next try looking for files in the various theme directories. */
path = _gtk_css_find_theme (name, variant);
if (path)
{
char *dir, *resource_file;
+1 -3
View File
@@ -431,9 +431,7 @@ make_blurred_pango_surface (cairo_t *existing_cr,
pango_layout_get_pixel_extents (layout, &ink_rect, NULL);
clip_radius = _gtk_cairo_blur_compute_pixels (radius);
x_scale = y_scale = 1;
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
cairo_surface_get_device_scale (cairo_get_target (existing_cr), &x_scale, &y_scale);
#endif
cairo_surface_get_device_scale (cairo_get_target (existing_cr), &x_scale, &y_scale);
surface = cairo_surface_create_similar_image (cairo_get_target (existing_cr),
CAIRO_FORMAT_A8,
+1 -1
View File
@@ -1840,7 +1840,7 @@ gtk_dialog_buildable_custom_finished (GtkBuildable *buildable,
else
signal_id = GTK_WIDGET_GET_CLASS (object)->activate_signal;
if (signal_id)
if (signal_id && !is_action)
{
GClosure *closure;
-2
View File
@@ -844,9 +844,7 @@ get_surface_size (cairo_surface_t *surface,
x_scale = y_scale = 1;
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
cairo_surface_get_device_scale (surface, &x_scale, &y_scale);
#endif
/* Assume any set scaling is icon scale */
*width =
-2
View File
@@ -9724,8 +9724,6 @@ bubble_targets_received (GtkClipboard *clipboard,
gtk_widget_destroy (priv->selection_bubble);
priv->selection_bubble = gtk_popover_new (GTK_WIDGET (entry));
gtk_style_context_add_class (gtk_widget_get_style_context (priv->selection_bubble),
GTK_STYLE_CLASS_OSD);
gtk_style_context_add_class (gtk_widget_get_style_context (priv->selection_bubble),
GTK_STYLE_CLASS_TOUCH_SELECTION);
gtk_popover_set_position (GTK_POPOVER (priv->selection_bubble),
+35 -1
View File
@@ -216,6 +216,7 @@ struct _GtkFileChooserWidgetPrivate {
GtkWidget *browse_files_popup_menu_size_column_item;
GtkWidget *browse_files_popup_menu_copy_file_location_item;
GtkWidget *browse_files_popup_menu_visit_file_item;
GtkWidget *browse_files_popup_menu_sort_directories_item;
GtkWidget *browse_new_folder_button;
GtkWidget *browse_path_bar_hbox;
GtkSizeGroup *browse_path_bar_size_group;
@@ -1427,6 +1428,28 @@ show_size_column_toggled_cb (GtkCheckMenuItem *item,
priv->show_size_column);
}
static void
sort_directories_toggled_cb (GtkCheckMenuItem *item,
GtkFileChooserWidget *impl)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
GtkTreeSortable *sortable;
priv->sort_directories_first = gtk_check_menu_item_get_active (item);
/* force resorting */
sortable = GTK_TREE_SORTABLE (priv->browse_files_model);
if (sortable == NULL)
return;
gtk_tree_sortable_set_sort_column_id (sortable,
GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID,
priv->sort_order);
gtk_tree_sortable_set_sort_column_id (sortable,
priv->sort_column,
priv->sort_order);
}
/* Shows an error dialog about not being able to select a dragged file */
static void
error_selecting_dragged_file_dialog (GtkFileChooserWidget *impl,
@@ -1683,6 +1706,9 @@ file_list_build_popup_menu (GtkFileChooserWidget *impl)
priv->browse_files_popup_menu_size_column_item = file_list_add_check_menu_item (impl, _("Show _Size Column"),
G_CALLBACK (show_size_column_toggled_cb));
priv->browse_files_popup_menu_sort_directories_item = file_list_add_check_menu_item (impl, _("Sort _Folders before Files"),
G_CALLBACK (sort_directories_toggled_cb));
check_file_list_menu_sensitivity (impl);
}
@@ -1716,6 +1742,13 @@ file_list_update_popup_menu (GtkFileChooserWidget *impl)
priv->show_size_column);
g_signal_handlers_unblock_by_func (priv->browse_files_popup_menu_size_column_item,
G_CALLBACK (show_size_column_toggled_cb), impl);
g_signal_handlers_block_by_func (priv->browse_files_popup_menu_sort_directories_item,
G_CALLBACK (sort_directories_toggled_cb), impl);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (priv->browse_files_popup_menu_sort_directories_item),
priv->sort_directories_first);
g_signal_handlers_unblock_by_func (priv->browse_files_popup_menu_sort_directories_item,
G_CALLBACK (sort_directories_toggled_cb), impl);
}
static void
@@ -3062,10 +3095,11 @@ settings_save (GtkFileChooserWidget *impl)
g_settings_set_boolean (settings, SETTINGS_KEY_SHOW_HIDDEN,
gtk_file_chooser_get_show_hidden (GTK_FILE_CHOOSER (impl)));
g_settings_set_boolean (settings, SETTINGS_KEY_SHOW_SIZE_COLUMN, priv->show_size_column);
g_settings_set_boolean (settings, SETTINGS_KEY_SORT_DIRECTORIES_FIRST, priv->sort_directories_first);
g_settings_set_enum (settings, SETTINGS_KEY_SORT_COLUMN, priv->sort_column);
g_settings_set_enum (settings, SETTINGS_KEY_SORT_ORDER, priv->sort_order);
g_settings_set_int (settings, SETTINGS_KEY_SIDEBAR_WIDTH,
gtk_paned_get_position (GTK_PANED (priv->browse_widgets_hpaned)));
gtk_paned_get_position (GTK_PANED (priv->browse_widgets_hpaned)));
/* Now apply the settings */
g_settings_apply (settings);
+12 -8
View File
@@ -642,7 +642,9 @@ gtk_font_chooser_widget_load_fonts (GtkFontChooserWidget *fontchooser)
qsort (families, n_families, sizeof (PangoFontFamily *), cmp_families);
g_signal_handlers_block_by_func(priv->family_face_list, cursor_changed_cb, fontchooser);
gtk_list_store_clear (list_store);
g_signal_handlers_unblock_by_func (priv->family_face_list, cursor_changed_cb, fontchooser);
/* Iterate over families and faces */
for (i = 0; i < n_families; i++)
@@ -895,18 +897,18 @@ gtk_font_chooser_widget_find_font (GtkFontChooserWidget *fontchooser,
GtkTreeIter *iter)
{
GtkFontChooserWidgetPrivate *priv = fontchooser->priv;
PangoFontDescription *desc;
PangoFontFamily *family;
gboolean valid, found;
gboolean valid;
if (pango_font_description_get_family (font_desc) == NULL)
return FALSE;
found = FALSE;
for (valid = gtk_tree_model_get_iter_first (priv->model, iter);
valid && !found;
valid;
valid = gtk_tree_model_iter_next (priv->model, iter))
{
PangoFontDescription *desc;
PangoFontFamily *family;
gtk_tree_model_get (priv->model, iter,
FAMILY_COLUMN, &family,
-1);
@@ -918,13 +920,15 @@ gtk_font_chooser_widget_find_font (GtkFontChooserWidget *fontchooser,
desc = tree_model_get_font_description (priv->model, iter);
pango_font_description_merge_static (desc, font_desc, FALSE);
if (pango_font_description_equal (desc, font_desc))
found = TRUE;
if (pango_font_description_equal (desc, font_desc)) {
pango_font_description_free (desc);
break;
}
pango_font_description_free (desc);
}
return found;
return valid;
}
static void
+743 -97
View File
File diff suppressed because it is too large Load Diff
+33
View File
@@ -68,6 +68,10 @@ struct _GtkGLAreaClass
/*< public >*/
gboolean (* render) (GtkGLArea *area,
GdkGLContext *context);
void (* resize) (GtkGLArea *area,
int width,
int height);
GdkGLContext * (* create_context) (GtkGLArea *area);
/*< private >*/
gpointer _padding[6];
@@ -79,6 +83,11 @@ GType gtk_gl_area_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_3_16
GtkWidget * gtk_gl_area_new (void);
GDK_AVAILABLE_IN_3_16
GdkGLProfile gtk_gl_area_get_profile (GtkGLArea *area);
GDK_AVAILABLE_IN_3_16
void gtk_gl_area_set_profile (GtkGLArea *area,
GdkGLProfile profile);
GDK_AVAILABLE_IN_3_16
gboolean gtk_gl_area_get_has_alpha (GtkGLArea *area);
@@ -94,11 +103,35 @@ GDK_AVAILABLE_IN_3_16
void gtk_gl_area_set_has_depth_buffer (GtkGLArea *area,
gboolean has_depth_buffer);
GDK_AVAILABLE_IN_3_16
gboolean gtk_gl_area_get_has_stencil_buffer (GtkGLArea *area);
GDK_AVAILABLE_IN_3_16
void gtk_gl_area_set_has_stencil_buffer (GtkGLArea *area,
gboolean has_stencil_buffer);
GDK_AVAILABLE_IN_3_16
gboolean gtk_gl_area_get_auto_render (GtkGLArea *area);
GDK_AVAILABLE_IN_3_16
void gtk_gl_area_set_auto_render (GtkGLArea *area,
gboolean auto_render);
GDK_AVAILABLE_IN_3_16
void gtk_gl_area_queue_render (GtkGLArea *area);
GDK_AVAILABLE_IN_3_16
GdkGLContext * gtk_gl_area_get_context (GtkGLArea *area);
GDK_AVAILABLE_IN_3_16
void gtk_gl_area_make_current (GtkGLArea *area);
GDK_AVAILABLE_IN_3_16
void gtk_gl_area_attach_buffers (GtkGLArea *area);
GDK_AVAILABLE_IN_3_16
void gtk_gl_area_set_error (GtkGLArea *area,
const GError *error);
GDK_AVAILABLE_IN_3_16
GError * gtk_gl_area_get_error (GtkGLArea *area);
G_END_DECLS
+53 -7
View File
@@ -1515,17 +1515,23 @@ gtk_header_bar_add (GtkContainer *container,
static GList *
find_child_link (GtkHeaderBar *bar,
GtkWidget *widget)
GtkWidget *widget,
gint *position)
{
GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar);
GList *l;
Child *child;
gint i;
for (l = priv->children; l; l = l->next)
for (l = priv->children, i = 0; l; l = l->next, i++)
{
child = l->data;
if (child->widget == widget)
return l;
{
if (position)
*position = i;
return l;
}
}
return NULL;
@@ -1540,7 +1546,7 @@ gtk_header_bar_remove (GtkContainer *container,
GList *l;
Child *child;
l = find_child_link (bar, widget);
l = find_child_link (bar, widget, NULL);
if (l)
{
child = l->data;
@@ -1595,6 +1601,37 @@ gtk_header_bar_forall (GtkContainer *container,
}
}
static void
gtk_header_bar_reorder_child (GtkHeaderBar *bar,
GtkWidget *widget,
gint position)
{
GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar);
GList *l;
gint old_position;
Child *child;
l = find_child_link (bar, widget, &old_position);
if (l == NULL)
return;
if (old_position == position)
return;
child = l->data;
priv->children = g_list_delete_link (priv->children, l);
if (position < 0)
l = NULL;
else
l = g_list_nth (priv->children, position);
priv->children = g_list_insert_before (priv->children, l, child);
gtk_widget_child_notify (widget, "position");
gtk_widget_queue_resize (widget);
}
static GType
gtk_header_bar_child_type (GtkContainer *container)
{
@@ -1613,7 +1650,7 @@ gtk_header_bar_get_child_property (GtkContainer *container,
GList *l;
Child *child;
l = find_child_link (bar, widget);
l = find_child_link (bar, widget, NULL);
if (l == NULL)
{
g_param_value_set_default (pspec, value);
@@ -1649,7 +1686,10 @@ gtk_header_bar_set_child_property (GtkContainer *container,
GList *l;
Child *child;
l = find_child_link (bar, widget);
l = find_child_link (bar, widget, NULL);
if (l == NULL)
return;
child = l->data;
switch (property_id)
@@ -1657,7 +1697,13 @@ gtk_header_bar_set_child_property (GtkContainer *container,
case CHILD_PROP_PACK_TYPE:
child->pack_type = g_value_get_enum (value);
_gtk_header_bar_update_separator_visibility (bar);
gtk_widget_queue_resize (widget);
break;
case CHILD_PROP_POSITION:
gtk_header_bar_reorder_child (bar, widget, g_value_get_int (value));
break;
default:
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
break;
@@ -1803,7 +1849,7 @@ gtk_header_bar_class_init (GtkHeaderBarClass *class)
P_("Position"),
P_("The index of the child in the parent"),
-1, G_MAXINT, 0,
GTK_PARAM_READABLE));
GTK_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_TITLE,
+2
View File
@@ -510,6 +510,7 @@ _gtk_icon_cache_get_icon (GtkIconCache *cache,
length = GET_UINT32 (cache->buffer, pixel_data_offset + 4);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (!gdk_pixdata_deserialize (&pixdata, length,
(guchar *)(cache->buffer + pixel_data_offset + 8),
&error))
@@ -520,6 +521,7 @@ _gtk_icon_cache_get_icon (GtkIconCache *cache,
return NULL;
}
G_GNUC_END_IGNORE_DEPRECATIONS
pixbuf = gdk_pixbuf_new_from_data (pixdata.pixel_data, GDK_COLORSPACE_RGB,
(pixdata.pixdata_type & GDK_PIXDATA_COLOR_TYPE_MASK) == GDK_PIXDATA_COLOR_TYPE_RGBA,
-2
View File
@@ -335,9 +335,7 @@ get_surface_size (GtkIconHelper *self,
{
x_scale = y_scale = 1;
#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
cairo_surface_get_device_scale (surface, &x_scale, &y_scale);
#endif
/* Assume any set scaling is icon scale */
*width =
+2 -2
View File
@@ -2305,7 +2305,7 @@ gtk_icon_theme_load_icon_for_scale (GtkIconTheme *icon_theme,
if (!icon_info)
{
g_set_error (error, GTK_ICON_THEME_ERROR, GTK_ICON_THEME_NOT_FOUND,
_("Icon '%s' not present in theme"), icon_name);
_("Icon '%s' not present in theme %s"), icon_name, icon_theme->priv->current_theme);
return NULL;
}
@@ -2369,7 +2369,7 @@ gtk_icon_theme_load_surface (GtkIconTheme *icon_theme,
if (!icon_info)
{
g_set_error (error, GTK_ICON_THEME_ERROR, GTK_ICON_THEME_NOT_FOUND,
_("Icon '%s' not present in theme"), icon_name);
_("Icon '%s' not present in theme %s"), icon_name, icon_theme->priv->current_theme);
return NULL;
}
+15 -2
View File
@@ -150,6 +150,8 @@ struct _GtkLevelBarPrivate {
GList *offsets;
gchar *cur_value_class;
guint inverted : 1;
};
@@ -336,6 +338,8 @@ gtk_level_bar_draw_fill_continuous (GtkLevelBar *self,
base_area.width -= block_margin.left + block_margin.right;
base_area.height -= block_margin.top + block_margin.bottom;
if (self->priv->cur_value_class)
gtk_style_context_remove_class (context, self->priv->cur_value_class);
gtk_style_context_add_class (context, STYLE_CLASS_EMPTY_FILL_BLOCK);
gtk_render_background (context, cr, base_area.x, base_area.y,
@@ -344,6 +348,8 @@ gtk_level_bar_draw_fill_continuous (GtkLevelBar *self,
base_area.width, base_area.height);
gtk_style_context_remove_class (context, STYLE_CLASS_EMPTY_FILL_BLOCK);
if (self->priv->cur_value_class)
gtk_style_context_add_class (context, self->priv->cur_value_class);
/* now render the filled part on top of it */
block_area = base_area;
@@ -442,7 +448,11 @@ gtk_level_bar_draw_fill_discrete (GtkLevelBar *self,
}
if (idx > num_filled - 1)
gtk_style_context_add_class (context, STYLE_CLASS_EMPTY_FILL_BLOCK);
{
gtk_style_context_add_class (context, STYLE_CLASS_EMPTY_FILL_BLOCK);
if (self->priv->cur_value_class != NULL)
gtk_style_context_remove_class (context, self->priv->cur_value_class);
}
gtk_render_background (context, cr,
block_area.x, block_area.y,
@@ -635,10 +645,12 @@ gtk_level_bar_update_level_style_classes (GtkLevelBar *self)
}
}
g_clear_pointer (&self->priv->cur_value_class, g_free);
if (value_class != NULL)
{
gtk_style_context_add_class (context, value_class);
g_free (value_class);
self->priv->cur_value_class = value_class;
}
}
@@ -884,6 +896,7 @@ gtk_level_bar_finalize (GObject *obj)
GtkLevelBar *self = GTK_LEVEL_BAR (obj);
g_list_free_full (self->priv->offsets, (GDestroyNotify) gtk_level_bar_offset_free);
g_free (self->priv->cur_value_class);
G_OBJECT_CLASS (gtk_level_bar_parent_class)->finalize (obj);
}
+2
View File
@@ -1449,6 +1449,8 @@ gtk_list_box_unselect_all_internal (GtkListBox *box)
dirty |= gtk_list_box_row_set_selected (row, FALSE);
}
BOX_PRIV (box)->selected_row = NULL;
return dirty;
}

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