Compare commits

..

510 Commits

Author SHA1 Message Date
Matthias Clasen b1038c5d19 settings: Add a :theme-change signal
This signal allows applications to intercept and override
what theme gets loaded when the theme settings change.
One possibility is to only load themes from a fixed list
of supported themes. Another is to ignore the user preference
and only load dark themes.
2020-04-13 10:40:32 -04:00
Matthias Clasen b16b44f1ae inspector: Use theme apis
We can now use gtk_theme_get_available_themes instead
of our own copy of that code.
2020-04-13 10:40:32 -04:00
Matthias Clasen 37c151ce0f Add some theme apis
Add apis to get the list of available themes,
as well as the dark or light variant of a theme.
2020-04-13 10:40:32 -04:00
Matthias Clasen eb7ad4bbad Introduce a gtk-user-theme-preference setting
This setting will be interpreted as prefers dark/
prefers light/don't care. Since we don't have any
useful metadata for themes, we simply look for
the NAME/NAME-dark naming convention when identifying
light or dark theme variants.
2020-04-13 10:20:36 -04:00
Matthias Clasen cdec487998 cssprovider: Stop supporting theme variants
We are no longer using variants, so drop the variant
argument from gtk_css_provider_load_named().
2020-04-13 10:20:36 -04:00
Matthias Clasen 80d3c68615 testsuite: Stop loading theme variants 2020-04-13 10:20:35 -04:00
Matthias Clasen ed4b3f8033 Drop the prefer-dark setting
There is no way to win with this setting, so instead
of trying to add yet more override knobs for application
developers, do away with theme variants altogether.

As a user, just pick your favorite theme, and if it
is dark, so be it.

As an app developer, you can inspect the gtk-theme-name
property and match that against your supported themes.
If that is not good enough for you, you can volunteer
to implement a theme property API that would let themes
declare whether they are dark or light.
2020-04-13 10:20:35 -04:00
Matthias Clasen 451e7a5ad2 themes: Make Adwaita-dark a separate theme
We are moving away from theme variants.
2020-04-13 10:20:35 -04:00
Matthias Clasen 89360b26af window: Stop dealing with prefer-dark
Its 2020.  If you want maching window decorations, use CSD.
2020-04-13 10:20:35 -04:00
Matthias Clasen d3d4fe14c2 inspector: Stop dealing with prefer-dark
This setting is going away.
2020-04-13 10:20:35 -04:00
Matthias Clasen 040175cd92 widget-factory: Stop dealing with prefer-dark
Instead, just toggle between known light/dark pairs
for the builtin themes.
2020-04-13 10:20:35 -04:00
Matthias Clasen 64b0c63190 Merge branch 'modal-buttons' into 'master'
Modal buttons

See merge request GNOME/gtk!1679
2020-04-13 11:15:14 +00:00
Matthias Clasen 8ff540eb4c appchooserbutton: Drop the Private struct 2020-04-13 01:08:52 -04:00
Matthias Clasen 9194b7388f Add a GtkAppChooserButton:modal property
Nowadays, dialogs are expected to be attached, typically,
and that only happens when they are marked as modal.
2020-04-13 00:43:19 -04:00
Matthias Clasen 6831d3e28e fontbutton: Drop the Private struct 2020-04-13 00:32:50 -04:00
Matthias Clasen 800f1c03d5 Add a GtkFontButton:modal property
Nowadays, dialogs are expected to be attached, typically,
and that only happens when they are marked as modal.
2020-04-13 00:28:34 -04:00
Matthias Clasen 7a0355fcb1 colorbutton: Drop the Private struct 2020-04-13 00:28:11 -04:00
Matthias Clasen 15d58a868a Add a GtkColorButton:modal property
Nowadays, dialogs are expected to be attached, typically,
and that only happens when they are marked as modal.
2020-04-13 00:17:00 -04:00
Matthias Clasen 61f21fc9e9 filechooserbutton: Make dialog modal by default
This is the expected behavior, so default to it.
2020-04-13 00:12:30 -04:00
Matthias Clasen 9e068d3a46 filechooserbutton: Drop the Private struct 2020-04-12 23:57:49 -04:00
Matthias Clasen 2aa136a19c Add a GtkFileChooserButton:modal property
Nowadays, dialogs are expected to be attached, typically,
and that only happens when they are marked as modal.
2020-04-12 23:45:03 -04:00
Matthias Clasen 1dfd514f7f Merge branch 'matthiasc/for-master' into 'master'
Adwaita: visible focus outline for color swatches

See merge request GNOME/gtk!1678
2020-04-13 03:42:26 +00:00
Matthias Clasen 08fbd012ec window: Make resize cursors work for modal dialogs
We were inadvertedly not letting the grab_widget determine
a cursor. This was showing up as resize cursors not appearing.
2020-04-12 22:18:50 -04:00
Matthias Clasen 638508fa20 gtk-demo: Group the OpenGL demos 2020-04-12 21:58:07 -04:00
Matthias Clasen ce6c7bae51 gtk-demo: Add a gears demo 2020-04-12 20:52:15 -04:00
Matthias Clasen 19f7b7ed40 Adwaita: visible focus outline for color swatches
Make the focus outline for color swatches visible
again.
2020-04-12 20:13:50 -04:00
Matthias Clasen e3dba28666 Merge branch 'arnaudb/better-substitution' into 'master'
Fix some gtk-builder-tool substitutions.

See merge request GNOME/gtk!1675
2020-04-12 22:53:54 +00:00
Matthias Clasen 88aa548965 Merge branch 'matthiasc/for-master' into 'master'
text: Fix placing the cursor on click

See merge request GNOME/gtk!1673
2020-04-12 22:07:20 +00:00
Matthias Clasen 17a9b13af2 text: Be more careful with cached layouts
If we call any functions that may call ensure_layout
themeselves, we risk having the cached layout pulled
out from underneath. Better play it safe and take a
reference.
2020-04-12 17:32:57 -04:00
Matthias Clasen 1efa781a19 window: Cosmetic cleanup
Use a convenience function to get the current event time.
2020-04-12 17:32:13 -04:00
Matthias Clasen 0a19d7ef08 textview: Fix an erroneous unref
This was left behind by accident in 0ee58e9ef4.
2020-04-12 17:32:13 -04:00
Arnaud Bonatti 926fb208ba Coding style improvements. 2020-04-12 21:21:24 +02:00
Arnaud Bonatti e76dee07c5 Fix tests for margin-left and margin-right. 2020-04-12 19:28:33 +02:00
Arnaud Bonatti 11a43cf554 Replace also margin-left and margin-right. 2020-04-12 19:28:29 +02:00
Arnaud Bonatti a7218da202 Fix tests for hexpand and vexpand. 2020-04-12 19:28:29 +02:00
Arnaud Bonatti ed362fcc5b Fix --3to4 tests for margin substitution. 2020-04-12 19:28:29 +02:00
Arnaud Bonatti 17ec74da35 Fix a gtk-builder-tool substitution.
The margin-left and margin-right properties have been
removed in favor of margin-start and margin-end ones.
2020-04-12 19:28:29 +02:00
Matthias Clasen 754d6d1a04 wayland: Avoid criticals when unsetting transient parents
Must not check the display when parent is NULL.
2020-04-12 12:10:18 -04:00
Matthias Clasen ff53d5ba11 stylecontext: Respect cursor aspect ratio everywhere
We were using the new cursor aspect ratio setting in
the snapshotting code, but not in gtk_render_insertion_cursor.

Make them both behave the same.
2020-04-12 11:44:13 -04:00
Matthias Clasen 7233a70d47 reftest: get backtraces
In the hope of making ci-only failures less of a black hole,
add a backtrace to the messsage for criticals.

This could eventually go into GLib (pass backtrace symbols along
as a log field for criticals), but for now this will do.
2020-04-12 11:44:13 -04:00
Emmanuele Bassi 12990b3520 Merge branch 'ci-error-report' into 'master'
ci: Count 'ERROR' codes as failures

See merge request GNOME/gtk!1674
2020-04-12 13:58:55 +00:00
Emmanuele Bassi 95d807ab61 ci: Count 'ERROR' codes as failures
Otherwise they'll be dropped from our reports.
2020-04-12 14:28:59 +01:00
Matthias Clasen 8a1a96a47e text: Fix placing the cursor on click
Commit c297d45b8a accidentally removed the
check for the right modifier mask, causing us to
always extend the selection.
2020-04-12 09:19:12 -04:00
sicklylife c31916081f Update Japanese translation 2020-04-12 08:53:45 +00:00
Piotr Drąg 0a1e19f4e3 Update POTFILES.in 2020-04-12 10:45:54 +02:00
Matthias Clasen 7d3f3b7ab8 Merge branch 'show-uri-async' into 'master'
Redo gtk_show_uri_on_window

See merge request GNOME/gtk!1671
2020-04-12 02:27:38 +00:00
Matthias Clasen 432b741ab7 gtk: Port all users to the new gtk_show_uri()
We were only handling the error in one place anyway.
2020-04-11 22:10:08 -04:00
Matthias Clasen 703f18ce66 Redo gtk_show_uri_on_window
Make this a full async function, and add a simple wrapper.

Call gtk_show_uri_full() if you need control over the
results, and use gtk_show_uri() if you are fine with
ignoring any errors.
2020-04-11 21:56:32 -04:00
Matthias Clasen 4da82bde7b Merge branch 'current-event-apis' into 'master'
Current event apis

See merge request GNOME/gtk!1668
2020-04-12 00:24:14 +00:00
Matthias Clasen feee281cf8 Drop gtk_get_current_ apis
We have event controller apis to replace these.
There is one remaining use of gtk_get_current_event_time
in gtkwindow.c, so we can't drop the implementation yet.

Add a section in the migration guide for this.
2020-04-11 17:29:27 -04:00
Matthias Clasen 443fd4d63d tests: Stop using gtk_get_current_ apis
Replace these by equivalent event controller
apis where needed.
2020-04-11 17:29:27 -04:00
Matthias Clasen 4b346538e2 gtk: Port widgets away from gtk_get_current_ apis
This commit handles complicated cases where we selections.
We handle this by adding extend and modify parameters to
the ::move-cursor signals, and adjust the bindings
accordingly.
2020-04-11 17:29:27 -04:00
Matthias Clasen 0ee58e9ef4 gtk: Port widgets away from gtk_get_current_ apis
Use the event controller equivalents where needed.
This commit covers the simple cases.
2020-04-11 17:29:27 -04:00
Matthias Clasen bd56bc9055 Add gtk_event_controller_get_current_event[_state]
For now these are private, to replace internal uses
of gtk_get_current_event[_state], but we may want to
make them public.
2020-04-11 17:29:27 -04:00
Matthias Clasen 3e7e862415 gtk: Just use current time for showing urls
We don't really have an event anywhere close in most
cases, and we already pass GDK_CURRENT_TIME in half
the cases anyway.

If we want to be serious about this, we need to pass
the event itself, since future focus-stealing protocols
may not rely on just a timestamp.
2020-04-11 17:29:27 -04:00
Matthias Clasen 4eeb413047 entrycompletion: Remove an unused field
No point in storing a device that is never used.
2020-04-11 17:29:27 -04:00
Matthias Clasen 661f3466c2 Merge branch 'matthiasc/for-master' into 'master'
broadway: Fix the build

See merge request GNOME/gtk!1670
2020-04-11 21:16:11 +00:00
Matthias Clasen e735554ced broadway: Fix the build
We need to depend on gdkenum_h, since we are (indirectly)
including gdkenumtypes.h in the broadway server build.
2020-04-11 16:24:05 -04:00
Matthias Clasen 520ea7c39d Merge branch 'jjardon/more_licenses' into 'master'
gtk/gtkaboutdialog: Add some more very common licenses:

See merge request GNOME/gtk!1667
2020-04-11 16:47:32 +00:00
Javier Jardón ffa345e4ab gtk/gtkaboutdialog: Add some more very common licenses:
- BSD 3-Clause "New" or "Revised" license
- Apache License 2.0
- Mozilla Public License 2.0
2020-04-11 16:49:09 +01:00
Emmanuele Bassi e072d9b28b Merge branch 'gsk-public-symbols' into 'master'
Install all headers with public symbols

Closes #2607

See merge request GNOME/gtk!1666
2020-04-11 15:21:11 +00:00
Matthias Clasen 9f5b04e65c Merge branch 'action-docs' into 'master'
Action docs

See merge request GNOME/gtk!1665
2020-04-11 15:12:22 +00:00
Emmanuele Bassi d08310096c Conditionally include the GSK broadway and vulkan symbols
In case GTK is built without these features.
2020-04-11 15:42:51 +01:00
Emmanuele Bassi 20d0d6fae2 Revert "Do not install GSK headers for missing backends"
This reverts commit cd5cded430.

The headers are public, but the symbols availability is conditional on
the GTK build.
2020-04-11 15:41:47 +01:00
Matthias Clasen 6b9ac1043b Document actions 2020-04-11 10:07:31 -04:00
Matthias Clasen c5b4066714 gdk: Small documentation fixes 2020-04-11 10:07:31 -04:00
Matthias Clasen b09b2dd2cd testsuite: Make actions test order-independent
We only want to check that the actions are what we
expect, not that they are registered in a particular
order.
2020-04-11 10:07:31 -04:00
Matthias Clasen 72a0828101 Merge branch 'respect-window-cursors' into 'master'
window: Respect widget cursors

See merge request GNOME/gtk!1663
2020-04-10 18:56:44 +00:00
Matthias Clasen 7379c34a39 window: Respect widget cursors
gtk_widget_set_cursor can be used on a GtkWindow; we
should not blow away the result when temporarily installing
resize cursors.
2020-04-10 14:36:55 -04:00
Matthias Clasen 6cd1b9955b Merge branch 'remove-style-reset' into 'master'
Remove gtk_style_context_reset_widgets

See merge request GNOME/gtk!1662
2020-04-10 17:36:03 +00:00
Matthias Clasen a6a31827bc Remove gtk_style_context_reset_widgets
This should never be necessary to call from the outside.
Whenever we fail to update styles properly, it is a bug.
2020-04-10 12:45:28 -04:00
Matthias Clasen 84939a612c Merge branch 'reduce-style-context-use' into 'master'
Use gtk_widget_add/remove_css_class more

See merge request GNOME/gtk!1661
2020-04-10 16:43:05 +00:00
Matthias Clasen 394ea32e93 Use gtk_widget_add/remove_css_class more
Replace most uses of gtk_style_context_add/remove_class
by the new APIs. The only remaining uses of the old API
are in save/restore situations.
2020-04-10 12:09:57 -04:00
Matthias Clasen 2bd36d490b Merge branch 'fix-accel-length' into 'master'
accelgroup: Fix an invalid write

Closes #2602

See merge request GNOME/gtk!1660
2020-04-10 13:27:07 +00:00
Matthias Clasen ad1bc75dd2 accelgroup: Fix an invalid write
This was lost by accident in d110fddbce.

Fixes: #2602
2020-04-10 08:24:03 -04:00
Piotr Drąg 7505c1fd7c Update POTFILES.in and POTFILES.skip 2020-04-10 13:56:58 +02:00
Matthias Clasen 8780906b93 Merge branch 'fix-radiobuttons' into 'master'
radiobutton: Fix selection on focus-in

Closes #2326

See merge request GNOME/gtk!1658
2020-04-10 04:17:37 +00:00
Matthias Clasen 0ed2e970be Merge branch 'popover-initial-focus' into 'master'
Popover initial focus

See merge request GNOME/gtk!1657
2020-04-10 04:17:15 +00:00
Matthias Clasen 58253d567f radiobutton: Fix selection on focus-in
We need to unselect the previously selected button
to preserve radioness.

Fixes: #2326
2020-04-09 22:38:30 -04:00
Matthias Clasen c09c61769c modelbutton: Catch focus-in more carefully
We need to unset the propagation limit on the focus
controller, else we miss the focus-in when the focus
enters the popover upon initial popup, when it comes
from the parent button.
2020-04-09 22:22:28 -04:00
Matthias Clasen 9b5dc35650 popovermenu: Remove debug spew 2020-04-09 21:41:02 -04:00
Matthias Clasen 3c9ada14fe Merge branch 'label-double-focus' into 'master'
Avoid double focus in labels

Closes #135

See merge request GNOME/gtk!1656
2020-04-10 01:34:49 +00:00
Matthias Clasen 6b4d6c3771 Merge branch 'scale-button-double-focus' into 'master'
scalebutton: Don't derive from GtkButton

See merge request GNOME/gtk!1655
2020-04-10 01:21:25 +00:00
Matthias Clasen b15f16e8db Adwaita: Don't render focus around labels with links
This avoids the 'double outline' problem for labels
with links.

Fixes: #135
2020-04-09 21:19:36 -04:00
Matthias Clasen e3b9dfef1c label: Improve link styling
Add a .link style class on labels that contain links,
so we can avoid the focus outline around the label
when individual links are focused, and use the link
node when rendering the focus on links.
2020-04-09 21:19:22 -04:00
Matthias Clasen 822c2aba36 scalebutton: Don't derive from GtkButton
Make GtkScaleButton a widget that has a toggle button
as a child, just like all the other button widgets now.
The immediate benefit of this arrangement is to avoid
the "double focus" problem when we pop up the popup.

Update accessible, demos and tests to match.
2020-04-09 20:43:45 -04:00
Matthias Clasen a11f9fea76 Merge branch 'wip/matthiasc/can-focus' into 'master'
Implement new focus behavior

See merge request GNOME/gtk!1652
2020-04-10 00:26:53 +00:00
Matthias Clasen f16c829190 Mention focus changes in the migration guide 2020-04-09 18:26:31 -04:00
Matthias Clasen 16c820c2f0 Small documentation tweaks
Update the docs for GtkWidget:can-focus and :focus-on-click.
2020-04-09 18:26:31 -04:00
Matthias Clasen 72ae6daa1e Move focus to the parent if a popover is dismissed
This is better than just dropping focus altogether,
and is expected behavior in most cases.
2020-04-09 18:26:31 -04:00
Matthias Clasen 35ba24d2e8 Update a11y test results 2020-04-09 18:26:10 -04:00
Matthias Clasen 508cb6160c a11y: Fix focusable state
The :can-focus property is no longer very useful to
give an indication of what is focusable, since it is
TRUE for almost all widgets now. Patch things up
to by looking at known widget types.
2020-04-09 18:14:15 -04:00
Matthias Clasen b9a76ddd75 Fix the tools tests to not set can-focus 2020-04-09 17:50:29 -04:00
Matthias Clasen 038190c5a8 Disable focus-chain test that depends on the environment
The color editor shows a color picker button only if it
finds a suitable implementation, which it does not in ci.
So disable the focus-chain test for page 3.
2020-04-09 17:50:29 -04:00
Matthias Clasen 2ae08e632c color editor: Make the sample non-focusable again
This is one of the situations, where can-focus can still
be used to tweak focus behavior of leaf widgets. Color
swatches are focusable by default to allow selecting colors
with the keyboard. But when used as color samples, they
should not take focus.
2020-04-09 17:50:29 -04:00
Matthias Clasen 99eed078bd Remove focusable-container tests
Like the previous commit, these tests were relying
on setting :can-focus to make an unsuspecting container
focusable, which does not work anymore.
2020-04-09 17:50:29 -04:00
Matthias Clasen 6720552afd Remove the focus test
This test was expecting to make existing widgets like
GtkBox focusable by setting :can-focus. That just doesn't
work anymore.

The focus chain testing that is done here is already
better covered by test-focus-chain, so lets just remove this.
2020-04-09 17:50:29 -04:00
Matthias Clasen 6f01508aa8 Fix up focus chain result
The notebook grab_focus change in the previous commit made
backwards tabbing work as expected, and thereby changed the
output of one of the focus-chain tests.
2020-04-09 17:50:29 -04:00
Matthias Clasen 632524f679 Reinstate expected focus behavior
After the :can-focus change in the previous commit, widgets
need to set suitable focus and grab_focus implementations
to implement the desired focus behavior.

This commit does that for all widgets.
2020-04-09 17:50:29 -04:00
Matthias Clasen 22e1827f84 Change the default value of GtkWidget:can-focus
Make widgets can-focus by default, and change the semantics
of can-focus to be recursive . If it is set to FALSE, focus
can not enter the widget or its descendents at all anymore.

This commit temporarily breaks focus behavior of widgets
that did not expect to receive focus.
2020-04-09 17:50:29 -04:00
Matthias Clasen 3c39613d9c widget: Add common focus vfunc implementations
Privately export a number of implementations for the focus
and grab_focus vfuncs that cover many common cases.
2020-04-09 17:50:29 -04:00
Matthias Clasen 46ff9f891a gizmo: Allow passing changing focus behavior
We need this in popovers. Maybe it could be done better
by defining one-off custom widgets.
2020-04-09 17:50:29 -04:00
Matthias Clasen 97ff1b83dc widget: Make the :has-focus property readonly
The only place where this should be set is when making
a widget the focus-widget of a window. We still keep
the property around in readonly form, since there are
a few places where we rely on property notification
for it.
2020-04-09 17:50:29 -04:00
Matthias Clasen 9416856420 testsuite: Stop setting :has-focus
This is not necessary, whenever we want to set the initial
focus in a ui file, we can set GtkWindow:focus-widget.
2020-04-09 17:50:29 -04:00
Matthias Clasen c1459cc45b widget: Drop the :is-focus property
This property doesn't carry any new information compared
to GtkWindow:focus-widget. We still keep the gtk_widget_is_focus
getter, as a convenient shortcut.
2020-04-09 17:50:29 -04:00
Matthias Clasen 4fe8c037c7 reftests: Stop using can-focus 2020-04-09 17:50:29 -04:00
Matthias Clasen b1afe5ff23 a11y tests: Stop using can-focus 2020-04-09 17:50:29 -04:00
Matthias Clasen bbd4fb8798 testsuite: Stop using can-focus 2020-04-09 17:50:29 -04:00
Matthias Clasen b3b29e37fd inspector: Drop more uses of can-focus 2020-04-09 17:50:29 -04:00
Matthias Clasen f996ba6585 inspector: Remove can-focus from ui files 2020-04-09 17:50:29 -04:00
Matthias Clasen 7ca36cd2d4 Stop setting can-focus in ui files
None of these settings are necessary.
2020-04-09 17:50:29 -04:00
Matthias Clasen 2a18f2150d window: Make set_focus equal to grab_focus
Make gtk_window_set_focus call gtk_widget_grab_focus internally.
This means that set_focus can now end up putting the focus on
a child of the passed-in widget, and makes the focus-widget
property work for setting initial focus to (the child of) an
entry in a ui file.
2020-04-09 17:50:28 -04:00
Matthias Clasen a65fd81106 root: Reorganize focus handling
Make :focus-widget a GtkWindow property and add vfuncs
to the GtkRoot interface instead of the property.
2020-04-09 17:50:28 -04:00
Matthias Clasen ff8217db40 Add more focus chain tests
Test page 2 and 3 of widget-factory as well, and try other directions.
2020-04-09 17:50:28 -04:00
Matthias Clasen a3861bf9a0 Fix running focus-chain tests in ci
The widget-factory ui files require geettings
(for the color chooser), so set GSETTINGS_SCHEMA_DIR.
2020-04-09 17:50:28 -04:00
Matthias Clasen b86c1446a4 notbook: Fix a bug in focus handling
After the header widget was introduced, focus would get
stuck in a loop between actions and tabs.

This could be seen in the notebook on page 3 of
widget-factory.
2020-04-09 17:50:28 -04:00
Matthias Clasen 9ce58bdb0c coloreditor: Draw a focus around the color plane
Not doing it was just an oversight.
2020-04-09 14:11:18 -04:00
Matthias Clasen 9f252f0ceb colorplane: Set a css name
Every widget should have one.
2020-04-09 14:10:23 -04:00
Matthias Clasen 7008a531bb Merge branch 'wip/xdg-popup-move' into 'master'
Wayland popup moving

See merge request GNOME/gtk!1017
2020-04-08 23:59:02 +00:00
Jonas Ådahl 458b8a6554 wayland: Move transient-for field to GdkWaylandToplevel
A toplevel will only ever be transient-for to another toplevel, and only
a toplevel will ever be transient-for, so move the field into the
GdkWaylandToplevel, and make it a pointer to another GdkWaylandToplevel.
2020-04-08 23:32:47 +02:00
Jonas Ådahl 307cc69adb wayland: Add surface to toplevel list only if toplevel
It was using another check (has parent) to do this, but now we have a
much more obvious way of creating surfaces, so we can use the type
directly.
2020-04-08 23:32:47 +02:00
Jonas Ådahl ab6b5ae568 wayland: Remove own pointer to the popup parent
It's there already as the GdkSurface::parent, no need to duplicate.
2020-04-08 23:32:47 +02:00
Jonas Ådahl 0e601c0a70 wayland: Move toplevel/popup/drag surface definitions higher up
We them up there, so that code higher up compared to where they are
defined now can make use of them. Also add a few macros for type
checking and casting.
2020-04-08 23:32:47 +02:00
Jonas Ådahl 5425edff82 wayland: Move popups with xdg_popup.reposition
The third version of xdg-shell introduces support for explicit popup
repositioning. If available, make use of this to implement popup
repositioning.

Note that this does *NOT* include atomic parent-child state
synchronization. For that,
https://gitlab.freedesktop.org/wayland/wayland-protocols/issues/13 will
be needed.

This currently uses my own fork of wayland-protocols which adds meson
support, so that we can use it as a subproject. Eventually when
wayland-protocols' meson support lands upstream, we should change it to
point there.

Silence some meson warnings while at it to make CI happy.

This also bumps the glib requirement, since g_warning_once() is used.
2020-04-08 23:32:47 +02:00
Jonas Ådahl 213c471bb7 build: Change wrap revisions to use master instead of origin/master
Using origin/master crashes meson.
2020-04-08 23:32:47 +02:00
Jakub Steiner 9ae0fe7f3a Merge branch 'Gtk4_blue_focus_rings' into 'master'
Blue outlines / focus rings

See merge request GNOME/gtk!1629
2020-04-08 21:12:57 +00:00
Frederik F abe6876f7c Blue outlines / focus rings
- introduce two new colors: $focus_border_color for focused / outlined elements and $_coloured_focus_border_color for focused / outlined elements with a colored background color, like suggested/destructive buttons or selected elements
- set outline / focus color, offset and style accordingly for all widgets
- adapt entry focus color
2020-04-08 21:12:57 +00:00
Matthias Clasen 53d74fd2dc Merge branch 'render-node-types' into 'master'
Turn GskRenderNode into a fundamental type

See merge request GNOME/gtk!1649
2020-04-08 20:55:14 +00:00
Emmanuele Bassi 3f0a830f3c Properly annotate the render node constructors
Now that the GskRenderNode subclasses are recognised as proper
sub-types, we can annotate the constructors with their type. The C API
remains the same.
2020-04-08 16:17:08 +01:00
Emmanuele Bassi e0323fcdc2 Add get_type() functions for GskRenderNode subclasses
The introspection scanner tries to match a type name with a get_type()
function, in order to correctly identify a type as a class.

If the function is not available, we have two choices:

 - add some special case inside the introspection scanner, similar to
   how GParamSpec subclasses are handled in GObject
 - add a simple get_type() function

The latter is the simplest approach, and we don't need to change that
much, since we still register all render nodes at once.
2020-04-08 16:07:04 +01:00
Emmanuele Bassi cd5cded430 Do not install GSK headers for missing backends
Broadway and Vulkan renderers are optional; if GTK hasn't been built
with their GSK renderers, we should not install their headers.
2020-04-08 15:41:21 +01:00
Emmanuele Bassi 54e4e6cd23 Improve the gtktypefuncs.inc generator
Remove the plug/socket exception, and add exceptions for non-X11
windowing systems.

Additionally, speed up the file generation by avoiding string
concatenation in Python.
2020-04-08 15:41:19 +01:00
Emmanuele Bassi 59852d3425 Add missing transfer annotation 2020-04-08 15:40:15 +01:00
Emmanuele Bassi d701a89281 Turn GskRenderNode into a derivable type
Language bindings—especially ones based on introspection—cannot deal
with custom type hiearchies. Luckily for us, GType has a derivable type
with low overhead: GTypeInstance.

By turning GskRenderNode into a GTypeInstance, and creating derived
types for each class of node, we can provide an introspectable API to
our non-C API consumers, with no functional change to the C API itself.
2020-04-08 15:40:15 +01:00
Emmanuele Bassi 5e095cd208 Add macro for exported variables
The logic is based on the similar macro in GLib, but with the
appropriate GDK symbols.
2020-04-08 15:40:15 +01:00
Emmanuele Bassi d2bdf3d5a1 Merge branch 'ci-meson-bump' into 'master'
ci: Update the version of Meson in our Docker image

See merge request GNOME/gtk!1651
2020-04-08 12:17:50 +00:00
Emmanuele Bassi e692385baa ci: Update the version of Meson in our Docker image
Needed for !1017.
2020-04-08 12:26:58 +01:00
Matthias Clasen 1e8df851e9 Merge branch 'matthiasc/for-master' into 'master'
Remove an unused backend includes

See merge request GNOME/gtk!1648
2020-04-07 20:30:43 +00:00
Matthias Clasen 904db0a8f7 Merge branch 'imcontextsimple-drop-ifdefs' into 'master'
impcontextsimple: Drop ifdef'ed platform dependencies

See merge request GNOME/gtk!1647
2020-04-07 19:27:51 +00:00
Matthias Clasen 6b7cc8baa6 Remove an unused backend includes
These includes are just leftovers.

Every time where we do an #ifdef GDK_WINDOWING... in gtk/,
something went wrong. Don't do it needlessly.
2020-04-07 15:13:18 -04:00
Matthias Clasen 71fe843d99 impcontextsimple: Drop ifdef'ed platform dependencies
The proper way to do this would be to adapt the tables
to have the right data for the platform. Since 4.0 is
a new start in many ways, lets clean this up.
2020-04-07 14:54:04 -04:00
Matthias Clasen 552a681816 Merge branch 'private-x11-types' into 'master'
Do not parse all GDK-X11 source files

See merge request GNOME/gtk!1646
2020-04-07 18:18:55 +00:00
Emmanuele Bassi 2f0016eb08 Rename gdkx11keys.h
The header is now private, so it should follow the same naming scheme
for private GDK-X11 headers.
2020-04-07 18:12:58 +01:00
Emmanuele Bassi f87291cac2 Hide GdkX11Keymap's GType function
It's not a public object.
2020-04-07 18:10:01 +01:00
Emmanuele Bassi 37c3ba2645 Do not parse all GDK-X11 source files
We don't need all of them, only the ones that contain public API. This
allows us to reduce the chance of a stray symbol getting incorrectly
added to the introspection data.
2020-04-07 18:06:08 +01:00
Matthias Clasen ba05787a06 Merge branch 'attribute-docs' into 'master'
entry: Document buildable support

See merge request GNOME/gtk!1643
2020-04-07 04:15:33 +00:00
Matthias Clasen 12b97ffd24 entry: Document buildable support 2020-04-06 23:33:22 -04:00
Matthias Clasen 1ae60cb713 entry: Add <attributes> support
Make entries support the same <attributes> syntax
as labels.

Closes: #1335
2020-04-06 22:59:54 -04:00
Matthias Clasen 3371e3aa49 Move label attribute parser code
We want to reuse the parser for <attributes> in several
widgets, so move it to a shared place.
2020-04-06 22:59:45 -04:00
Matthias Clasen baeae71d12 Merge branch 'cross-postinstall' into 'master'
meson: Don't execute post-install.py if cross compiling

See merge request GNOME/gtk!1636
2020-04-06 23:59:33 +00:00
Matthias Clasen f8be3229b1 Merge branch 'fix-event-match' into 'master'
shortcuttrigger: Don't trigger on key releases

See merge request GNOME/gtk!1642
2020-04-06 23:44:32 +00:00
Matthias Clasen b9cfcf07e0 Merge branch 'wip/chergert/fix-shortcut-param-order' into 'master'
widget: fix parameter ordering to match implementation

Closes #2586

See merge request GNOME/gtk!1641
2020-04-06 23:30:26 +00:00
Matthias Clasen eb649d8204 shortcuttrigger: Don't trigger on key releases
This broke when the event type check in gdk_key_event_matches
was removed and replaced by a precondition that accepts both
key press and release events.

Add the check in gtk_keyval_trigger_trigger instead.
2020-04-06 19:16:41 -04:00
Christian Hergert 4a00f3bc9a widget: fix parameter ordering to match implementation
Fixes https://gitlab.gnome.org/GNOME/gtk/issues/2586
2020-04-06 15:44:19 -07:00
Matthias Clasen 0b17658a82 Replace most uses of <Primary> with <Control>
The only place where we are still using <Primary> is
in tests, to ensure we keep parsing it. Otherwise,
<Control> is now the preferred syntax.
2020-04-06 17:05:52 -04:00
Matthias Clasen 2486f46c0b Merge branch 'keymap-rework-2' into 'master'
Keymap rework 2

See merge request GNOME/gtk!1635
2020-04-06 20:56:06 +00:00
Matthias Clasen c03b7e4d45 reftests: Comment out a test that fails only in ci
Fixing such only-in-ci failures is just too hard,
unfortunately.
2020-04-06 16:32:03 -04:00
Matthias Clasen e7a8a4eb06 Update migration guide
Rewrite the sections about keymaps and menus, and add
hints about modifiers.
2020-04-06 16:32:03 -04:00
Matthias Clasen 70fbf8dbb6 accelgroup: Small documentation updates
Mention GtkShortcutTrigger, and remove references
to <Release>.
2020-04-06 16:32:03 -04:00
Matthias Clasen 93a1b3027d Reshuffle keymap docs
Since GdkKeymap api is on longer public, move relevant
documentation to the long description.
2020-04-06 16:32:03 -04:00
Matthias Clasen 1de7719e34 Drop gtk_accelerator_set_default_mod_mask
Our new approach to modifiers works with a fixed set,
there is really no need to customize the modifier
masks if the backends are all supposed to deliver
the same modifiers.
2020-04-06 16:32:03 -04:00
Matthias Clasen f7f103a322 gdk: Remove gdk_keymap_get_modifier_mask
This function is no longer public and no longer used.
2020-04-06 16:32:03 -04:00
Matthias Clasen 14be8f6b73 Remove uses of modifier intents in gdkevents.c
This removes the use of the context menu and shift group
intents in gdkevents.c. If it turns out to be important,
we need to introduce vfuncs for gdk_event_triggers_context_menu
and gdk_event_matches.
2020-04-06 16:32:03 -04:00
Matthias Clasen 99a344f791 display: Remove gdk_display_get_modifier_mask
This is not used anymore.
2020-04-06 16:32:03 -04:00
Matthias Clasen 3419d9c04f gtk: Drop gtk_widget_get_modifier_mask
This is not used anymore.
2020-04-06 16:32:03 -04:00
Matthias Clasen c297d45b8a gtk: Stop using modifier intents
Reviewing the existing settings, the only backend with
some differences in the modifier intent settings is OS X,
and we would rather have that implemented by interpreting
the existing modifiers in the appropriate way.

                X11      Wayland  Win32    OS X

primary         ctrl     ctrl     ctrl     mod2
mnemonic        alt      alt      alt      alt
context menu    -        -        -        ctrl
extend sel      shift    shift    shift    shift
modify sel      ctrl     ctrl     ctrl     mod2
no text         alt|ctrl alt|ctrl alt|ctrl mod2|ctrl
shift group     varies   -        -        alt

GTK now uses the following modifiers:

primary         ctrl
mnemonic        alt
extend sel      shift
modify sel      ctrl
no text         alt|ctrl

The context menu and shift group intents were not used
in GTK at all.

Update tests to no longer expect <Primary> to roundtrip
through the accelerator parsing and formatting code.
2020-04-06 16:32:03 -04:00
Matthias Clasen dce8d251c6 keymap: Remove virtual modifier mapping functions
These are not used anymore.

Drop the vfuncs and their implementations in the
broadway, x11, wayland and win32 backends as well.
2020-04-06 16:32:03 -04:00
Matthias Clasen 89ad7893ad gdk: Make GdkKeymap a private api
We have replacement apis in GdkDevice and GdkDisplay.
2020-04-06 16:32:03 -04:00
Matthias Clasen da6faf321c Merge branch 'misc-meson-fixes' into 'master'
Reduce useless relinking on configure and fix check for buildtype arguments

See merge request GNOME/gtk!1614
2020-04-06 20:22:01 +00:00
Justin van Steijn c8b791a763 Update Dutch translation 2020-04-06 19:40:22 +00:00
Matthias Clasen 0eb728aa51 imcontextsimple: Disable some win32-only code
This code needs to be redone differently, since keymaps are no
longer going to be exposed. There should really not be this much
ifdef-ed backend-specific code here anyway. Or any, really.
2020-04-06 15:33:49 -04:00
Matthias Clasen 3300686bef gdk: Clean up GdkModifierType
Remove MOD2..MOD5. Backends are expected to just set
the named modifiers.
2020-04-06 15:13:54 -04:00
Matthias Clasen 0a96a483c6 gdk: Redo key events
Add all of the keyboard translation results in the key event,
so we can translate the keyboard state at the time the event
is created, and avoid doing state translation at match time.

We actually need to carry two sets of translation results,
since we ignore CapsLock when matching accelerators, in
gdk_event_matches().

At the same time, drop the scancode field - it is only ever
set on win32, and is basically unused in GTK.

Update all callers.
2020-04-06 15:13:54 -04:00
Matthias Clasen 5071367794 gtk: Remove handling of virtual modifiers
These are going away. We expect to just have
named modifiers in modifier masks now, so we
longer juggle 'real' and 'virtual' modifiers.
2020-04-06 15:13:54 -04:00
Matthias Clasen 5ce05a8fd0 events: Stop doing elaborate virtual modifier handling
These are going away in the GdkModifierType cleanup.
Just compare the modifiers we got.
2020-04-06 15:13:54 -04:00
Matthias Clasen be2a0971c2 broadway: Stop using MOD2..MOD5
These are going away in the GdkModifierType cleanup.
2020-04-06 15:13:53 -04:00
Matthias Clasen 25e9a54902 win32: Stop using MODx modifiers
The win32 backend is using GDK_MOD2_MASK for AltGr,
so define GDK_MOD2_MASK locally to keep this working,
but remove any mention of GDK_MOD3_MASK,...,GDK_MOD5_MASK.
2020-04-06 15:13:00 -04:00
Yuri Chornoivan df1c6b6b68 Update Ukrainian translation 2020-04-06 15:46:52 +00:00
Yuri Chornoivan 00c791fcf9 Update Ukrainian translation 2020-04-06 14:06:17 +00:00
Matthias Clasen a5e73820da Merge branch 'fno-common' into 'master'
Add a missing extern, to fix building with -fno-common

See merge request GNOME/gtk!1631
2020-04-06 12:47:55 +00:00
Matthias Clasen 7fa103717d wayland: Stop setting MOD2..MOD5
These are going away in the GdkModifierType cleanup.
2020-04-06 01:40:49 -04:00
Matthias Clasen f8646b9733 gdk: Remove reserved bit from GdkModifierType
This really has no purpose and obscures the header.
2020-04-06 01:40:49 -04:00
Matthias Clasen d110fddbce gtk: Stop using GDK_MODx_MASK
These are never used in practice, and we never want to
see them in the UI, so stop supporting them. This is
in preparation for cleaning up GdkModifierType.
2020-04-06 01:40:49 -04:00
Matthias Clasen b02db72e17 Rename GDK_MOD1_MASK to GDK_ALT_MASK
We've hardcoded Mod1 = Alt for a long time, there is
no need to keep the confusing naming around anymore.
2020-04-06 01:40:49 -04:00
Matthias Clasen e8f30c836d tests: Stop using gtk_accelerator_set_default_mod_mask
This is not doing anything useful here.
2020-04-06 01:40:49 -04:00
Matthias Clasen 6eaadba008 testsuite: Stop using keymap apis 2020-04-06 01:40:49 -04:00
Matthias Clasen 4495bacfd1 gtk: Use display apis for keymap mapping
This removes the last uses of GdkKeymap from GTK.
2020-04-06 01:40:49 -04:00
Matthias Clasen 234a21905c gtk: Stop using keymap apis
Stop using most keymap apis in GTK. Only a few calls
related to virtual modifiers are left.
2020-04-06 01:40:49 -04:00
Matthias Clasen 13213c710f x11: Notify new device properties 2020-04-06 01:40:49 -04:00
Matthias Clasen e165267924 wayland: Notify new device properties 2020-04-06 01:40:49 -04:00
Matthias Clasen 00b25d5594 Move keymap mapping functions to GdkDisplay
We want to stop exposing GdkKeymap, so this
functionality needs a new home.
2020-04-06 01:40:40 -04:00
Matthias Clasen 31fb5c287a Move GdkKeymapKey to gdktypes.h
We are going to use this type in a different header.
2020-04-05 23:43:41 -04:00
Matthias Clasen 416ec580dc gdk: Move modifier mask api to GdkDisplay
GdkKeymap is on the way out.
2020-04-05 23:43:41 -04:00
Matthias Clasen ee14be8ac1 gdk: Add keymap properties to GdkDevice
GdkKeymap is on the way out.
2020-04-05 23:43:41 -04:00
Matthias Clasen f27470aaf4 passwordentry: Show caps lock warning more
Show the caps lock warning regardless of whether we
have the peek icon or not.
2020-04-05 23:43:41 -04:00
Matthias Clasen 90eda2b17c Drop some no longer used code 2020-04-05 23:43:41 -04:00
Matthias Clasen 68d43c8e5c cell renderer accel: Use gdk_event_get_match 2020-04-05 23:43:41 -04:00
Matthias Clasen c9aef3fc4d Add gdk_event_get_match
This is a counterpart to gdk_event_matches() that can
be used to obtain a shortcut matching an event.
2020-04-05 23:37:13 -04:00
Matthias Clasen e8330c5eec Add gdk_event_matches
Move the elaborate key event matching code from
GtkShortcutTrigger to GdkEvent, which greatly reduces
the amount of keymap api use outside of GDK.
2020-04-05 23:37:13 -04:00
Martin Storsjö 531766fe64 meson: Don't execute post-install.py if cross compiling 2020-04-05 22:57:22 +03:00
Martin Storsjö 25a53276e0 Add a missing extern, to fix building with -fno-common
With C compilers defaulting to -fcommon, this isn't an issue, but
upcoming compilers (GCC 10 and Clang 11) will default to -fno-common,
ending up with duplicate definitions of these variables.
2020-04-05 00:43:16 +03:00
Matthias Clasen 1149502767 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1630
2020-04-04 21:09:12 +00:00
Matthias Clasen 33928a52c3 gtk-demo: Fix a crash
Using the assistant demo repeatedly was crashing.
2020-04-04 15:35:18 -04:00
Matthias Clasen b636df7784 Merge branch 'matthiasc/for-master' into 'master'
shortcuts: documentation fixes

See merge request GNOME/gtk!1628
2020-04-04 15:33:41 -04:00
Matthias Clasen 005739371c Merge branch 'matthiasc/for-master' into 'master'
shortcuts: documentation fixes

See merge request GNOME/gtk!1628
2020-04-04 16:31:43 +00:00
Matthias Clasen ec854fc503 shortcuts: documentation fixes
Update symbol lists, and add examples for parsing triggers
and actions.
2020-04-04 12:22:43 -04:00
Piotr Drąg e75e975a38 Update POTFILES.skip 2020-04-04 11:56:04 +02:00
Matthias Clasen 2bf81b51d9 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1626
2020-04-04 05:00:22 +00:00
Matthias Clasen 22211f29fb colorbutton: Don't add a customize menu
The color swatch in the button does not need a
context menu. Turn it off.
2020-04-04 00:28:52 -04:00
Matthias Clasen 8991275fbd colorbutton: Fix focus
The colorbutton contains a button which contains a colorswatch.
We want the focus to go straight to the button, nowhere else,
so mark the swatch as !can-focus.

Adapt tests to match.
2020-04-04 00:28:45 -04:00
Matthias Clasen f2d6a7b36a demos: Remove can-focus from ui files 2020-04-04 00:28:34 -04:00
Matthias Clasen e43eb951d6 Merge branch 'scrollbar-a11y' into 'master'
Add GtkScrollbarAccessible

See merge request GNOME/gtk!1623
2020-04-04 04:03:40 +00:00
Matthias Clasen 5205fa0ff7 scrollbar: Be more defensive
Somehow the scrollbar accessible manages to call
gtk_scrollbar_get_adjustment when priv->range is NULL.
Survive taht.
2020-04-03 23:31:45 -04:00
Matthias Clasen 842af79e97 Merge branch 'shortcut-action-parse' into 'master'
Shortcut action parse

See merge request GNOME/gtk!1625
2020-04-04 03:12:10 +00:00
Matthias Clasen 6b292af6ac testsuite: Add tests for parsing shortcut actions 2020-04-03 22:42:00 -04:00
Matthias Clasen 1424dd9786 Add an api to parse shortcut actions
This is so we can test this code. While doing it
I also fixed the missing else that was caused it
not to work.
2020-04-03 22:41:15 -04:00
Matthias Clasen 339d3e41b0 Add GtkScrollbarAccessible
When GtkScrollbar stopped being a GtkRange,
GtkRangeAccessible stopped working for scrollbars.

Update a11y tests to match.
2020-04-03 15:20:27 -04:00
Carlos Garnacho 9a2f7338df Merge branch 'wip/carlosg/fix-surrounding-text-master' into 'master'
imwayland: Clamp the surrounding string end correctly

Closes #2565

See merge request GNOME/gtk!1621
2020-04-03 18:37:44 +00:00
Matthias Clasen bdb127e54c Merge branch 'focus-test' into 'master'
Focus test

See merge request GNOME/gtk!1622
2020-04-03 18:23:27 +00:00
Carlos Garnacho e5d23aaaaf imwayland: Clamp the surrounding string end correctly
In the paths where len > MAX_LEN and cursor/anchor are separated by
at least MAX_LEN from text edges, we were clamping the right end of
the surrounding string at MAX_LEN. Oops.

This end anchor may go as far as the string length, although just
up to len - MAX_LEN in real terms (due to the condition above that
caches cursor/anchor positions being near enough the text end).

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2565

(cherry-picked from commit d7fb15c822)
2020-04-03 19:55:55 +02:00
Matthias Clasen d662512c44 testsuite: Add a big focus chain testcase 2020-04-03 11:35:34 -04:00
Matthias Clasen 324af2f701 testsuite: Try harder to record a full focus chain
It is hard to avoid widgets with the same name in a
large ui file - try harder to record a full focus chain
before decide that we've wrapped, by including the widget
address in the comparison. Note that we don't include
the addresses in the generated output, since that would
make expected output vary from run to run.
2020-04-03 11:35:26 -04:00
Emmanuele Bassi de481a7b5e Merge branch 'gir-fixes' into 'master'
Annotation fixes

See merge request GNOME/gtk!1616
2020-04-03 15:21:59 +00:00
Matthias Clasen c8018e267a Merge branch 'move-gdkgrab-decl' into 'master'
gdk: Move GdkGrabStatus and GdkGrabOwnership decl.

See merge request GNOME/gtk!1615
2020-04-03 15:03:51 +00:00
Emmanuele Bassi 4e264a74be Annotation fixes
Match the arguments name in the declaration and the definition, and make
sure we have the proper transfer annotations.
2020-04-03 15:30:56 +01:00
Olivier Fourdan 4f49d83e43 gdk: Move GdkGrabStatus and GdkGrabOwnership decl.
With the removal of `gdk_seat_grab` we do not need to keep the
definitions of `GdkGrabStatus` and `GdkGrabOwnership` public.

Move those definitions to become internal only.
2020-04-03 15:23:01 +02:00
Nirbheek Chauhan eaef24c527 meson: Fix check for builtype arguments
`get_option('buildtype')` will return `'custom'` for most combinations
of `-Doptimization` and `-Ddebug`, but those two will always be set
correctly if only `-Dbuildtype` is set. So we should look at those
options directly.

For the two-way mapping between `buildtype` and `optimization`
+ `debug`, see this table:
https://mesonbuild.com/Builtin-options.html#build-type-options
2020-04-03 18:41:55 +05:30
Nirbheek Chauhan 777435c470 meson: Reduce useless relinking on reconfigure
When we reconfigure, `configure_file()` is called again, and
`*.gresource.xml` files are regenerated, which causes many (all?)
binaries to be relinked. Now we only write those out if the contents
actually changed (or if the output didn't already exist).

This is exactly what Meson already does with `configure_file()` when
`command:` is not used.

While we're at it, also do the same for `gen-c-array.py` and
`gentypefuncs.py` for completeness. Now even if the input to those
changes, re-building of those custom targets may not result in
relinking if the outputted C files have the same contents.
2020-04-03 18:41:55 +05:30
Timm Bäder fb325afc79 shortcutcontroller: fix transfer full annotation 2020-04-03 08:03:32 +02:00
Timm Bäder 046190cb8a window: Don't leak toplevel layout 2020-04-03 07:37:54 +02:00
Matthias Clasen 53592497a4 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1611
2020-04-03 01:07:14 +00:00
Matthias Clasen cffa45d5ff wayland: Add a comment about keyboard state handling
Clarify a point that took me a few hours to fully track
down, so lets preserve what I found for the next poor
sould coming this way.
2020-04-02 17:43:14 -04:00
Matthias Clasen 14166b09b5 a11y tests: Update for focus state changes 2020-04-02 17:35:15 -04:00
Matthias Clasen 8a0035333a a11y: Set focus-related states properly
Entries and menubuttons are no longer focusable themselves,
they have focusable children. Since we don't have accessible
objects for those, transfer the focus-related state (focusable
and focused) from the children to the main accessible object.
2020-04-02 17:35:09 -04:00
Matthias Clasen 1f8e633fff window: tie focus to surface state changes
We don't get a focus-out on the event controller, when
the surface is losing keyboard focus, since we are not
moving our focus to some other widget, so we are never
unsetting the mnemonics-visible property. Do that in
response to surface state changes instead.
2020-04-02 17:21:01 -04:00
Matthias Clasen 6e6b4a851f Merge branch 'cherry-picked-wayland-keyboard-fix' into 'master'
gdk/wayland: Clear modifiers when we lose keyboard focus

Closes #2112

See merge request GNOME/gtk!1610
2020-04-02 20:43:29 +00:00
Jan Alexander Steffens (heftig) 7444b15d47 gdk/wayland: Clear modifiers when we lose keyboard focus
When we `Alt+Tab` away from a GTK application, it loses keyboard focus.
If we don't clear the modifiers, events from other devices that we
receive while unfocused will assume `Alt` is still pressed. This results
in e.g. Firefox navigating through the history instead of scrolling the
page when using the mouse wheel on it.

We don't get any information about modifiers while we are missing
keyboard focus, so assuming no modifiers are active is the best we can
do.

The shell sends us a modifier update immediately before we regain
keyboard focus, so the state shouldn't get out of sync.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/2112
2020-04-02 16:18:18 -04:00
Matthias Clasen dd625abfc1 Merge branch 'wip/smcv/libdir-independent-valgrind-suppressions' into 'master'
supp: Use a single suppressions file for lib, lib64 and multiarch

See merge request GNOME/gtk!1603
2020-04-02 14:46:45 +00:00
Matthias Clasen b6f6df9662 Merge branch 'im-context-wayland-fixes' into 'master'
Im context wayland fixes

See merge request GNOME/gtk!1605
2020-04-02 13:29:32 +00:00
Matthias Clasen aaa4e40a1f imcontexsimple: Move Compose file loading to class_init
This ensures that it is done only once.
2020-04-02 09:04:23 -04:00
Matthias Clasen 8ec254e2bb imcontextsimple: Simpify Compose file loading
We are not loading the Compose file for individual contexts,
it just gets added to a global list. So don't pass an im context
along. This will let us move the loading out of the initialization
of individual contexts, and only do it once.
2020-04-02 09:02:05 -04:00
Matthias Clasen 2a9911724f imcontextsimple: Load ~/.Compose unconditionally
There is nothing display-specific in the ~/.Compose file,
so we can just try to load it without looking at the
display we are on.
2020-04-02 09:02:05 -04:00
Matthias Clasen a9b4ac3d59 imcontextsimple: Add a profiler mark for IO
We are loading a file here, thankfully in a thread, but
we do it every time an entry is created. Add a profiler
mark, to make this visible.
2020-04-02 09:02:05 -04:00
Simon McVittie 9df7f0197d supp: Use a single suppressions file for lib, lib64 and multiarch
In addition to the traditional library directory lib and the 64-bit
multilib directory lib64, this will cover Debian-style multiarch
(lib/x86_64-linux-gnu etc.), Arch Linux 32-bit (lib32), x32 and
various others.

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-04-02 09:18:55 +01:00
Matthias Clasen f169d23cdb Merge branch 'fix-menu-flicker' into 'master'
Fix crossing event generation

Closes #2536

See merge request GNOME/gtk!1601
2020-04-02 05:19:13 +00:00
Matthias Clasen fcd36e59b1 Fix crossing event generation
We were not properly setting the new_descendent field
in Crossing structs for GTK_CROSSING_OUT events. This
was causing extraneous ::leave signals to be emitted,
and make model buttons in popover menus flicker when
hovered.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2536
2020-04-02 00:39:46 -04:00
Matthias Clasen 8196478b19 Merge branch 'drop-popover-demo' into 'master'
gtk-demo: Remove the popover demo

Closes #2429

See merge request GNOME/gtk!1600
2020-04-01 20:40:17 +00:00
Matthias Clasen e31bbb41d2 gtk-demo: Remove the popover demo
It doesn't work anymore, since popovers now need
support in the parent, and we don't really need
a demo just for popovers. They are used everywhere
already.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2429
2020-04-01 15:45:13 -04:00
Emmanuele Bassi 9c948909ac Merge branch 'flow-box-typo' into 'master'
gtkflowbox: Fix a minor typo in the documentation

See merge request GNOME/gtk!1599
2020-04-01 13:45:19 +00:00
Philip Withnall 544b8d5a7f gtkflowbox: Fix a minor typo in the documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-04-01 14:04:46 +01:00
Matthias Clasen 6ae5d9ac22 Merge branch 'matthiasc/for-master' into 'master'
keynav: Fix Shift-Tab

See merge request GNOME/gtk!1598
2020-04-01 05:04:02 +00:00
Matthias Clasen 63c6af8d13 Merge branch 'cursor-aspect-ratio' into 'master'
Add a cursor-aspect-ratio setting

See merge request GNOME/gtk!1597
2020-04-01 05:02:15 +00:00
Matthias Clasen 199a539ae7 Update the settings test 2020-04-01 00:24:56 -04:00
Matthias Clasen dc3d778e01 keynav: Fix Shift-Tab
This was broken by the shortcuts branch merge.
2020-04-01 00:21:19 -04:00
Matthias Clasen 2154b8e745 Add a cursor-aspect-ratio setting
Add a setting that controls how thick the text caret is drawn.
The default value is 0.04.
2020-03-31 23:30:20 -04:00
Matthias Clasen 9f93464ea4 3.98.2 2020-03-31 21:09:30 -04:00
Matthias Clasen 5987bc5d71 Merge branch 'wip/carlosg/stuck-pointer-focus' into 'master'
gtkmain: Do not try to coalesce/ignore crossing events

See merge request GNOME/gtk!1594
2020-04-01 00:16:26 +00:00
Matthias Clasen 298218b1d2 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1593
2020-03-31 23:19:09 +00:00
Carlos Garnacho fa7f6ad910 gtkmain: Do not try to coalesce/ignore crossing events
Under grabbing circumstances we used to get several crossing events,
some corresponding to the grab itself and some corresponding to
pointer motion.

The backends now do a better job at keeping those simple, which
means we sit listening for events that don't actually arrive. This
triggers pointer focus issues when dragging windows or opening
grabbing popups.

Actually obey those events, they will be the only ones we get now.
2020-04-01 00:40:17 +02:00
Matthias Clasen b92b7f45b5 testsuite: Add a test for transforms in builder files 2020-03-31 16:49:51 -04:00
Matthias Clasen 2bacc0d4ef testsuite: Add a test for parsing layout properties
and drop the child properties test that doesn't
do anything anymore.
2020-03-31 16:49:51 -04:00
Matthias Clasen e4fb4b635c Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1591
2020-03-31 18:32:18 +00:00
Matthias Clasen 5432f73095 window: Fix residual resizing issues
After the GdkToplevel split, GtkWindow occasionally
forgets its minimum size. Fix this by keeping a GdkToplevelLayout
around and reusing it.
2020-03-31 13:07:44 -04:00
Chun-wei Fan 2f64651a3f meson.build: Fix Visual Studio builds
We need to make the C++ language available before we can access the C++
compiler object...
2020-03-31 12:00:26 +08:00
Matthias Clasen 0852d66f6e NEWS: Updates 2020-03-30 21:58:24 -04:00
Matthias Clasen f3e826f4d6 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1589
2020-03-31 00:39:37 +00:00
Matthias Clasen 15eb3bbbf1 shortcutcontroller: Document buildable support 2020-03-30 20:09:29 -04:00
Matthias Clasen 96f822434f testsuite: Add a builder test for shortcut controllers 2020-03-30 20:08:25 -04:00
Matthias Clasen ace183f38f shortcutcontroller: Fix builder support
The GtkBuilder support was not working anymore after
triggers and actions have been turned into objects.

Fix this.
2020-03-30 19:02:35 -04:00
Matthias Clasen 5bf030413b Add new api to the docs 2020-03-30 14:12:14 -04:00
Matthias Clasen 2a3dab5b94 Merge branch 'wip/hadess/portal-fixes' into 'master'
Portal fixes

See merge request GNOME/gtk!1585
2020-03-30 17:45:40 +00:00
Matthias Clasen 96f0c26306 Merge branch 'issue982' into 'master'
gdk: Add gdk_toplevel_inhibit_system_shortcuts API

Closes #982

See merge request GNOME/gtk!1542
2020-03-30 17:41:12 +00:00
Bastien Nocera 8cf41c1b66 filechoosernativeportal: Fall back if portal is too old
Add portal version checking as originally implemented for the GTK 3.x
branch.

See: 35fec1c6b2
2020-03-30 18:31:24 +02:00
Bastien Nocera 027ca22def Add portal version checking helper
Add gtk_get_portal_interface_version() to check the version of a portal.
2020-03-30 18:31:23 +02:00
Bastien Nocera bd55c5842e colorpickerportal: Simplify version fetching code
Simplify version checking code by using a function to fetch the uint out
of the GVariant and don't throw a warning if it can't be fetched.
2020-03-30 18:31:23 +02:00
Olivier Fourdan c3ff175e3f win32: Add inhibit shortcut properties
Win32 backend doesn't have support for inhibit shortcuts, yet it needs
support the standard set of GdkToplevel properties.

Add support for the "inhibit-list" object property to GdkToplevel on
win32.
2020-03-30 18:25:36 +02:00
Olivier Fourdan b22c7b8b77 broadway: Add inhibit shortcut properties
Broadway doesn't have support for inhibit shortcuts, yet it needs to
support the standard set of GdkToplevel properties.

Add support for the "inhibit-list" object property to GdkToplevel on
Broadway.
2020-03-30 18:25:36 +02:00
Olivier Fourdan 83027c68f1 x11: Implement inhibit_system_shortcuts API
On X11, there is no such equivalent to the inhibit shortcut protocol
found on Wayland.

To implement the inhibit_system_shortcuts API on X11, we emulate the
same behavior using grabs on the keyboard.

To avoid keeping active grabs on the keyboard that would affect other
X11 applications even when the surface isn't focused, the X11
implementation takes care of releasing the grabs as soon as the toplevel
loses focus.
2020-03-30 18:25:36 +02:00
Olivier Fourdan 44931a66df x11: Use gdk_x11_* rather than gdk_wayland_*
Rename the local functions for the x11 backend as gdk_x11_* rather than
gdk_wayland_*
2020-03-30 18:25:36 +02:00
Olivier Fourdan 36d986f33c wayland: Implement inhibit_system_shortcuts API
On Wayland, this is a direct mapping with the inhibit shortcut protocol
that GDK already supports.

Simply wire the new API to the existing entries.
2020-03-30 18:25:36 +02:00
Olivier Fourdan 5ac73be976 wayland: Use a GdkSeat as key for our internal hash table
With the current implementation, we use a `wl_seat` as the key for our
internal has table where we store the Wayland shortcuts inhibitors.

There is however no technical reason for this, and we could use a
GdkSeat instead, which will ease the implementation of the GdkToplevel
shortcut inhibition API.
2020-03-30 18:25:36 +02:00
Olivier Fourdan a07a69e24e gdk: add internal gdk_surface_get_seat_from_event()
This can come handy to get the seat from a surface/event.
2020-03-30 18:25:36 +02:00
Olivier Fourdan 3e1f59af61 gdk: Add gdk_toplevel_inhibit_system_shortcuts API
With the removal of grabs from the public API, we need a replacement API
to let applications bypass system keyboard shortcuts.

A typical use case for this API is remote desktop or virtual machine
viewers which need to inhibit the default system keyboard shortcuts so
that the remote session or virtual host gets those instead of the local
environment.

Close: https://gitlab.gnome.org/GNOME/gtk/issues/982
2020-03-30 18:25:36 +02:00
Matthias Clasen da47ccaf3c Merge branch 'wip/jimmac/avoid-t-word' into 'master'
widget-factory: avoid the T word

See merge request GNOME/gtk!1586
2020-03-30 15:15:51 +00:00
Jakub Steiner e9082fd9f3 widget-factory: avoid the T word
- style variant sound more appropriate
2020-03-30 14:28:47 +02:00
Matthias Clasen 61e88c7421 Merge branch 'matthiasc/for-master' into 'master'
widget: Remove a leftover vfunc

See merge request GNOME/gtk!1584
2020-03-30 11:37:57 +00:00
Matthias Clasen de31bb59a1 window: Remove initial-focus leftovers
We removed the way to set initial_focus a year ago,
time to get rid of the leftovers.
2020-03-29 23:39:54 -04:00
Matthias Clasen 07bb29153b widget: Remove a leftover vfunc
The popup-menu signal is gone, so we can remove the vfunc.
2020-03-29 23:18:56 -04:00
Yosef Or Boczko b35e5eeaf6 Update Hebrew translation 2020-03-29 15:34:36 +00:00
Yosef Or Boczko c0a450e41b Update Hebrew translation 2020-03-29 15:33:40 +00:00
Timm Bäder 785b33f169 widget: Return an array from list_controllers
Minimize the GList usage throughout the code base.
2020-03-29 15:32:54 +02:00
Matthias Clasen af749dc1dc Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1583
2020-03-29 13:18:35 +00:00
Matthias Clasen 47982ae272 coloreditor: Drop the Private struct 2020-03-29 09:04:19 -04:00
Matthias Clasen 0020b735d9 colorchooserdialog: Drop the Private struct 2020-03-29 09:04:19 -04:00
Matthias Clasen e05c1b0244 colorchooserwidget: Drop the Private struct 2020-03-29 09:04:19 -04:00
Matthias Clasen d0b4f9eb29 notebook: Drop the Private struct 2020-03-29 09:04:19 -04:00
Matthias Clasen 03375b723a listbox: Drop the Private struct 2020-03-29 09:04:19 -04:00
Matthias Clasen e2beb6ec50 levelbar: Drop the Private struct 2020-03-29 09:04:19 -04:00
Matthias Clasen ef32cff771 spinbutton: Drop the Private struct 2020-03-29 09:04:19 -04:00
Matthias Clasen 366b007024 filechooserwidget: Drop the Private struct 2020-03-29 09:04:19 -04:00
Matthias Clasen 40337aa1b3 printunixdialog: Drop the Private struct 2020-03-29 09:04:19 -04:00
Matthias Clasen 0bb38b903e printjob: Drop the Private struct 2020-03-29 09:04:19 -04:00
Matthias Clasen 8acd9ffc76 testsuite: Fix notify test no not fail on the 30th
We are setting the month property to 10 different values,
checking that the change succeeds. But the calendar defaults
to the current date, so on every 30th of the month, we
try to set a date of Febuary 30, which fails.

Lets fix this before the 31st, by setting the calendar
to a good date.
2020-03-29 09:04:19 -04:00
Piotr Drąg 23b29341ba Update Polish translation 2020-03-29 14:08:56 +02:00
Matthias Clasen 6e52820fd2 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1582
2020-03-28 21:17:29 +00:00
Matthias Clasen 173b1333ca printing: Avoid a crash
When no printer has been selected (e.g. because we don't
find any printers), the 'print at' radio group should be
insensitive, except for the 'now' choice. Selecting another
option in this situation will lead to a crash.
2020-03-28 15:36:15 -04:00
Matthias Clasen 784d6f8d0c printing: Fix initial page range radio group
Only set one radio button as active in the ui file.
Otherwise we end up with multiple options appearing
as selected initially.
2020-03-28 15:36:15 -04:00
Matthias Clasen 3437f85aaf Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1580
2020-03-28 19:35:36 +00:00
Matthias Clasen 7916b95bc5 gesture: Fix gtk_gesture_get_bounding_box
When we stopped translating event coordinates in-place,
this function inadvertently started returning surface-relative
bounding boxes instead of widget-relative ones, as expected.

Fix this by using the widget-relative coordinates that we
already store.
2020-03-28 15:03:33 -04:00
Matthias Clasen 7b135c96e4 cellarea: Fix cell editing
We need to translate the event coordinates to
widget-relative coordinates. This broke when
we stopped translating event coordinates in-place.
2020-03-28 14:56:26 -04:00
Matthias Clasen e662438675 button: Fix an event handling gotcha
We no longer translate event coordinates in-place,
so gdk_event_get_position() returns surface-relative
coordinates, not widget-relative ones. Just use the
coordinates we are given.
2020-03-28 14:33:01 -04:00
Matthias Clasen aa2ca80817 imcontextsimple: Don't use g_object_unref on events
Events are not objects anymore.
2020-03-28 14:29:08 -04:00
Matthias Clasen 9ccd514682 x11: Don't use g_object_unref on events
Events are not object anymore.
2020-03-28 14:28:36 -04:00
Matthias Clasen 2c7afc0556 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1579
2020-03-28 16:09:01 +00:00
Piotr Drąg 182cb81bdb Update POTFILES.in and POTFILES.skip 2020-03-28 16:04:52 +01:00
Matthias Clasen ceef86895f appchooserdialog: Drop the Private struct 2020-03-28 10:59:12 -04:00
Matthias Clasen 001d076e61 image: Drop the Private struct 2020-03-28 10:49:54 -04:00
Matthias Clasen 408dd37944 infobar: Drop the Private struct 2020-03-28 10:48:15 -04:00
Matthias Clasen 9287e0e7fb texthandle: Drop the Private struct 2020-03-28 10:36:09 -04:00
Matthias Clasen 28eb1fce04 searchentry: Drop the Private struct 2020-03-28 10:28:22 -04:00
Matthias Clasen 49427119ab statusbar: Drop the Private struct 2020-03-28 10:28:01 -04:00
Matthias Clasen 05891b1238 settings: Drop the Private struct
Also drop class padding - pointless for final types.
2020-03-28 10:22:44 -04:00
Matthias Clasen b14d99ad7a accellabel: Drop unused class fields
We are not using these anymore.
2020-03-28 10:15:50 -04:00
Matthias Clasen 329638280c accellabel: Drop the Private struct 2020-03-28 10:06:26 -04:00
Matthias Clasen 06365cdc38 actionbar: Drop the Private struct 2020-03-28 09:59:49 -04:00
Matthias Clasen 1f808c479a aboutdialog: Drop the Private struct 2020-03-28 09:59:07 -04:00
Matthias Clasen 7e8d61b92c menubutton: Drop the Private struct 2020-03-28 09:49:29 -04:00
Timm Bäder d01e664c79 applicationaccels: Fix shortcut memory leaks
g_list_model_get_item() is transfer-full.
2020-03-28 08:34:35 +01:00
Matthias Clasen 858997d172 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #2489

See merge request GNOME/gtk!1578
2020-03-28 04:40:52 +00:00
Matthias Clasen f3d061e879 gtk-demo: Fix the stack demo
The GtkSpinner:active property was renamed to :spinning.
2020-03-28 00:08:12 -04:00
Matthias Clasen e2c327e025 gtk-demo: Fix the sliding puzzle
Update for a change in gtk_shortcut_controller_add_shortcut
behavior.
2020-03-28 00:08:12 -04:00
Matthias Clasen 48910a6d8e gtk-demo: Fix the shortcuts demo
We don't have margins anymore.
2020-03-28 00:08:12 -04:00
Matthias Clasen fbed55dff9 gtk-demo: Fix the rotated text demo
Off-by-one on the heart!
2020-03-28 00:08:12 -04:00
Matthias Clasen 059917b83c gtk-demo: Fix the overlay demo
We must use two separate boxes for the label and
the entry, otherwise we can't keep their can-target
properties apart.
2020-03-28 00:08:12 -04:00
Matthias Clasen 163aa82d45 gtk-demo: Use mnemonics in menu buttons
Use GtkMenuButton:use-underline in the modelbutton demo.
2020-03-28 00:08:12 -04:00
Matthias Clasen ba25e08e7b menubutton: Add a use-underline property
This is necessary since apps no longer have direct
access to the label.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2489
2020-03-28 00:08:12 -04:00
Matthias Clasen bc2c341d60 gtk-demo: Visual fixes to the model button demo 2020-03-28 00:08:12 -04:00
Matthias Clasen 7e0266004e Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1577
2020-03-27 21:10:19 +00:00
Matthias Clasen 93d54ba10b gtk-demo: Fix the search entry demo
Avoid critical warnings when setting up the context
menu actions.
2020-03-27 16:24:20 -04:00
Matthias Clasen 5d07a66d1d widget-factory: Fix the radio button example
We only want one of the sensitive buttons to be active,
so don't tell them all to be active.
2020-03-27 16:06:03 -04:00
Matthias Clasen 8997dc6f31 Merge branch 'rename-theme-resources' into 'master'
Rename GResources for standard GTK themes

See merge request GNOME/gtk!1576
2020-03-27 16:37:31 +00:00
Matthias Clasen 9f72f4225d Merge branch 'trigger-parser' into 'master'
Improve GtkShortcutTrigger parser

See merge request GNOME/gtk!1572
2020-03-27 15:45:08 +00:00
Emmanuele Bassi f1003d6ae8 Rename GResources for standard GTK themes
After commit 2ab9be54fb we had to rename
the generated CSS files to be included into the GResource bundle; we
kept the URI stable to avoid too much churn, and allow backporting the
change to the 3.24 stable branch. This had the adverse effect of making
it harder to debug issues, as the on-disk file name does not match the
location in the GResource that will be used to print out warnings,
errors, and debugging messages.
2020-03-27 15:20:59 +00:00
Emmanuele Bassi b1327167e2 Improve GtkShortcutTrigger parsing tests
Split off all possible cases into sub-tests, and add more thorough
checks on the invalid strings unit.
2020-03-27 14:56:05 +00:00
Emmanuele Bassi 6719d3044d Add parsing for GtkAlternativeTrigger
Alternative triggers are separate by a pipe character.
2020-03-27 14:35:00 +00:00
Emmanuele Bassi c75fdda8dd tests: Add more cases for the trigger parser 2020-03-27 13:57:19 +00:00
Emmanuele Bassi 170e8bd605 Parse keyval name directly for mnemonic triggers
We don't need to parse the full accelerator format for mnemonic
triggers.
2020-03-27 13:57:19 +00:00
Emmanuele Bassi 96ccb25f97 Return a full reference when parsing triggers
We're not returning a full reference for GtkNeverTrigger, but we are
returning full references for mnemonic and keyval triggers; this means
we're either going to leak mnemonic and keyval triggers if we consider
this function a "transfer none" one, or we are going to trigger an
assertion failure when finalizing a never trigger, if we consider this
function a "transfer full" one.

Let's be consistent, and always return a full reference to the caller.
2020-03-27 13:57:19 +00:00
Timm Bäder c3c06e60dc calendar: Only highlight one day as today
Fixes #2490
2020-03-27 09:50:30 +01:00
Timm Bäder ecb8dda309 shortcutscontroller: Make add_shortcut transfer-full
Like all the other shortcut api
2020-03-27 08:36:32 +01:00
Timm Bäder f7975828bc filechooserwidget: Plug a memory leak 2020-03-27 08:36:32 +01:00
Matthias Clasen 5fdb897f06 Merge branch 'widget-factory-theme' into 'master'
widget-factory: Add theme switch

See merge request GNOME/gtk!1573
2020-03-26 18:23:11 +00:00
Matthias Clasen 8ab2e31b58 widget-factory: Add theme switch
Add a submenu to test the builtin themes. This is mainly
for the benefit of the artists working on those themes.
2020-03-26 13:51:59 -04:00
Matthias Clasen 0d710b0353 Merge branch 'wip/jimmac/HC-redesign' into 'master'
HC: derive from Adwaita

Closes #1450

See merge request GNOME/gtk!1571
2020-03-26 17:24:42 +00:00
Jakub Steiner 06fe4f0205 Adwaita: make insensitive slightly less sensitive
- will expose itself even more in HC
2020-03-26 17:22:47 +01:00
Jakub Steiner 910dd7a20a HC: derive from Adwaita
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/1450
2020-03-26 17:21:47 +01:00
Jakub Steiner 8d8990ccd7 Revert "Adwaita: make insensitive slightly less sensitive"
This reverts commit bf3ccaa1bf.
2020-03-26 17:19:19 +01:00
Jakub Steiner bf3ccaa1bf Adwaita: make insensitive slightly less sensitive
- will expose itself even more in HC
2020-03-26 15:55:42 +01:00
Matthias Clasen eaa20f5cdf Merge branch 'wip/matthiasc/shortcut-4' into 'master'
Shortcuts

See merge request GNOME/gtk!1569
2020-03-26 03:40:22 +00:00
Matthias Clasen d07e22dc03 Some documentation fixes 2020-03-25 23:14:45 -04:00
Matthias Clasen 1ec2d1d9f1 shortcutmanager: Add some more docs 2020-03-25 23:14:45 -04:00
Matthias Clasen f59cd392ba shortcuttrigger: Some documentation fixups 2020-03-25 23:14:45 -04:00
Matthias Clasen 6bacb0b0ae shortcutaction: Some documentation fixups 2020-03-25 23:14:45 -04:00
Matthias Clasen 530b571d89 shortcutcontroller: Expand the docs 2020-03-25 23:14:45 -04:00
Matthias Clasen ce22ef18f9 docs: Update the overview input chapter
Update the wording around events to reflect current
usage, and add information about shortcuts and the
shortcut controller.
2020-03-25 23:14:45 -04:00
Matthias Clasen 591f6bd7a9 popovermenu: Show mnemonics on keynav
This is the expected behavior for menus.
2020-03-25 23:14:45 -04:00
Matthias Clasen 642503afb4 popover: Implement auto mnemonics
Unfortunately, this involves copying a bunch of
code from gtkwindow.c. The only difference here
is that we add a private method to turn this off,
which will be used by GtkPopoverMenu to implement
its own auto mnemonics.
2020-03-25 23:14:45 -04:00
Matthias Clasen fc0b0b14a8 label: Respect GtkPopover::mnemonics-visible
When inside a popover, look to the popover for
whether to show mnemonics or not.
2020-03-25 23:14:45 -04:00
Matthias Clasen 2de4fc3ec0 popover: Add a mnemonics-visible property
This will be handled separately for popovers, so we
need our own property for it.
2020-03-25 23:14:45 -04:00
Matthias Clasen b2ac42e576 label: Disconnect visible mnemonics in popovers
The controller handling mnemonics is limited to same-native,
so showing mnemonics in other natives.
2020-03-25 23:14:45 -04:00
Matthias Clasen b19d4b9006 modelbutton: Install accels when inside a popover
When a model button in a popover displays a shortcut,
it is probably from the global shortcut controllers,
and will not work inside the popover, since that is
a different native. Install a shortcut using the same
trigger that just activates the model button. This
shortcut will end up in the managed shortcut controller
of the popover.
2020-03-25 23:14:45 -04:00
Matthias Clasen 2c28a0713d popovermenu: Make mnemonics work without Alt
This is expected menu behavior.
2020-03-25 23:14:45 -04:00
Matthias Clasen b423f974db shortcutcontroller: Inject accels into the action muxer
This is the way model button pic up accels for their actions.
2020-03-25 23:14:45 -04:00
Matthias Clasen 4a430820bd popover: Implement GtkShortcutManager
This makes mnemonics work in popovers.
2020-03-25 23:14:45 -04:00
Matthias Clasen 5153cdc01d modelbutton: Make activatable
This is expected of button-like widgets, and is necessary
to make keynav in popover menus work as expected.
2020-03-25 23:14:45 -04:00
Matthias Clasen 1db5382c6d modelbutton: Remove accel poking
Stop manually poking GtkApplication for accels.
GtkApplication already feeds them into the action
muxer machinery, so that is where will get them.
2020-03-25 23:14:45 -04:00
Emmanuele Bassi 6e8c78714d Turn GtkShortcutAction into a GObject
Just like we did for GtkShortcutTrigger.

This allows language bindings to properly deal with all the actions.
2020-03-25 23:14:45 -04:00
Emmanuele Bassi 457b6657bb Turn GtkShortcutTrigger into an object
The lightweight inheritance mechanism used for GtkShortcutTrigger is not
going to be usable by bindings, because boxed types cannot have derived
types.

We could use GTypeInstance and derive everything from that, like
GParamSpec, but in the end shortcuts are not really a performance
critical paths, unlike CSS values or render nodes.
2020-03-25 23:14:45 -04:00
Emmanuele Bassi 1ddd8586dd Add definition macro for internal types
GTK defines various types that are meant to be derivable only within GTK
itself, and "final" from the perspective of consumers of the GTK API.
The existing macros defined by GObject, such as G_DECLARE_FINAL_TYPE and
G_DECLARE_DERIVABLE_TYPE, lack this functionality.

While we wait for GObject to get this kind of macro, we should define
our own.
2020-03-25 23:14:45 -04:00
Matthias Clasen 5ea45bf57d widget: Remove some leftover accel group plumbing
The ::can-activate-accel and ::accel-closures-changed signals
are not used anymore, remove them.
2020-03-25 23:14:45 -04:00
Matthias Clasen 4e978d6b7a shortcutcontroller: Only activate shortcuts of visible widgets
Our shortcuts are like mnemonics in this respect - they only
activate when the widget is viewable.
2020-03-25 23:14:45 -04:00
Matthias Clasen b4722b43a1 Drop GtkKeyHash 2020-03-25 23:14:45 -04:00
Matthias Clasen fd95cc56b1 window: Remove GtkKeyHash remnants
It is not used anymore.
2020-03-25 23:14:45 -04:00
Matthias Clasen d66121c61e Drop the keyhash test
GtkKeyHash is going away.
2020-03-25 23:14:45 -04:00
Matthias Clasen 35332eb3b0 shortcutcontroller: Implement mnemonic cycling
Make GtkShortcutController collect matching shortcuts
in the same way GtkKeyHash did (accept fuzzy matches
if we don't have any exact matches), and cycle among
the matches if we have multiple.
2020-03-25 23:14:45 -04:00
Matthias Clasen 586e7749d5 shortcuttrigger: Do elaborate matching for key events
Copy the logic from GtkKeyHash for matching key events
to shortcuts.

Adapt shortcuts test to work with the better matching,
by creating more complete key events.
2020-03-25 23:14:45 -04:00
Matthias Clasen 904835d4b1 shortcuttrigger: Introduce partial matches
Allow GtkShortcutTrigger to return partial matches.
Currently, no triggers produce such results, and
GtkShortcutController treats partial matches like
exact ones.
2020-03-25 23:14:45 -04:00
Matthias Clasen cb821d5df3 Add tests for shortcut actions 2020-03-25 23:14:45 -04:00
Matthias Clasen ff056af249 Add a test for shortcut triggers 2020-03-25 23:14:45 -04:00
Matthias Clasen 9cce474106 widget: Drop the ::popup-menu signal
This is now done in widgets which have context
menus.
2020-03-25 23:14:45 -04:00
Matthias Clasen 9d84996fea placesview: Stop using ::popup-menu
This signal is going away.
2020-03-25 23:14:45 -04:00
Matthias Clasen c2d77a1f37 filechooser: Stop using ::popup-menu
This signal is going away.
2020-03-25 23:14:45 -04:00
Matthias Clasen 54a0037c45 mountoperation: Stop using ::popup-menu
We can just use a shortcut controller directly.
2020-03-25 23:14:45 -04:00
Matthias Clasen 80b988ef6c gtk-demo: Stop emitting ::popup-menu
The signal was not used anyway, in the font explorer demo.
2020-03-25 23:14:45 -04:00
Matthias Clasen 844801580f colorchooser: Stop using ::popup-menu
This signal is going away. Use an action instead.
2020-03-25 23:14:44 -04:00
Matthias Clasen 28b05eea67 range: Remove ::popup-menu emission
This signal is going away, and having context menus
on sliders is not really a thing anyway.
2020-03-25 23:14:44 -04:00
Matthias Clasen ca1d4322a2 scrollbar: Remove :popup-menu forwarding
This signal is going away.
2020-03-25 23:14:44 -04:00
Matthias Clasen c94ec4a204 emojichooser: Stop using ::popup-menu
This signal is going away. Use an action instead.
2020-03-25 23:14:44 -04:00
Matthias Clasen 778d884f70 Use an action for the context menu keybinding
The ::popup-menu signal is going away.
2020-03-25 23:14:44 -04:00
Matthias Clasen e8be45fabc Print mnemonic triggers clearly 2020-03-25 23:14:44 -04:00
Matthias Clasen c90b0581dd inspector: Show shortcuts
At a tab that lists the shortcuts contained in a
GtkShortcutController.
2020-03-25 23:14:44 -04:00
Benjamin Otte 43c0ea676d filechooser: Trigger the location popup via bindings
Simplifies code quite a bit.
2020-03-25 23:14:44 -04:00
Benjamin Otte bb4fbe3d8f accels: Remove GtkAccelGroup 2020-03-25 23:14:44 -04:00
Benjamin Otte 7c4d8d49b6 testmenubutton: Don't create a GtkAccelGroup
It's unused.
2020-03-25 23:14:28 -04:00
Benjamin Otte cac39526a9 testsuite: Remove GtkAccelGroup usage 2020-03-25 23:14:28 -04:00
Benjamin Otte 4c45410d43 widget: Remove gtk_widget_add_accelerator()
People should use shortcut controllers instead (global, capture).

A side effect of this is that GtkAccelLabel now lost its method to
magically look up accelerators to display. Somebody needs to add that
back later.
2020-03-25 23:14:28 -04:00
Benjamin Otte 8e9218df03 doc tools: Create AccelLabel image without using GtkAccelGroup 2020-03-25 23:14:28 -04:00
Emmanuele Bassi 541c478eeb testgtk: Port keyval example to shortcut controllers 2020-03-25 23:14:28 -04:00
Benjamin Otte 78e3e42042 shortcutcontroller: Implement GtkBuildable
Use it to allow adding shortcuts to the controller via the usual <child>
method.
2020-03-25 23:14:28 -04:00
Benjamin Otte 33045c3e0b shortcutaction: Integrate with GtkBuilder property parsing
<property name="action">action(win.quit)</property> style action
specifications now work for GtkShortcutAction properties.
2020-03-25 23:14:28 -04:00
Benjamin Otte 7974751e24 shortcuttrigger: Add gtk_shortcut_triger_new_parse_string()
And hook it up into the GtkBuilder infrastructure.
2020-03-25 23:14:28 -04:00
Benjamin Otte daa7d9072d application: Replace accelerator handling with shortcuts
API remains the same, but activation is now done via a
shortcutcontroller.

The code uses a controller with global scope so that the
shortcuts are managed with all the other global shortcuts.
2020-03-25 23:14:28 -04:00
Benjamin Otte 90a34312d4 accel: Add display arg to gtk_accelerator_parse_with_keycode()
It was using the default display unconditionally.
2020-03-25 23:14:28 -04:00
Benjamin Otte 580863b112 accelerators: Make gtk_accelerator_parse() return TRUE/FALSE
A parse function should return success or not. So do that.
2020-03-25 23:14:28 -04:00
Benjamin Otte fb6a8f5fc1 shortcuttrigger: Add hash(), equal(), and compare() functions
Those are useful for putting triggers in hash tables or getting sorted
output.
2020-03-25 23:14:28 -04:00
Matthias Clasen c2e2e2993b shortcutmanager: Use list models 2020-03-25 23:14:28 -04:00
Matthias Clasen 5763514ab8 shortcutcontroller: Use a list model for shortcuts 2020-03-25 23:14:28 -04:00
Benjamin Otte 4c5d8547be shortcutaction: Add gtk_shortcut_action_to_string()
For all but the callback action, we can print something useful.
2020-03-25 23:14:27 -04:00
Matthias Clasen 34987c0b5c widget: Only create a controller if we have shortcuts
No point in creating objects that just hold empty lists.
2020-03-25 23:14:27 -04:00
Benjamin Otte 3cd4eb0310 widget: Keep keybindings as a GListStore
This way, we can use shortcut_controller_new_for_model() and avoid all
the special casing about run_class.
2020-03-25 23:14:27 -04:00
Benjamin Otte a1e9ae5259 shortcutcontroller: Add gtk_shortcut_controller_new_for_model()
This is mainly for internal use, but I can't see a reason to not have it
public for people who want to maintain their own lists.

I'm sure gnome-builder will never ever find a way to misuse it.
2020-03-25 23:14:27 -04:00
Benjamin Otte e738a4d129 shortcutcontroller: Implement GListModel
After all, this controller is a list of shortcuts.
2020-03-25 23:14:27 -04:00
Benjamin Otte 1ec950d14a gtk-demo: Port the sliding puzzle demo to shortcuts 2020-03-25 23:14:27 -04:00
Benjamin Otte 92e20deca1 shortcut: Change the API for creating shortcuts
When creating shortcuts, there almost always are a trigger and an action
available for use. So make gtk_shortcut_new() take those as arguments.

Also add gtk_shortcut_new_with_arguments() so people can easily pass
those in, too.
2020-03-25 23:14:27 -04:00
Benjamin Otte cd0332aad5 shortcut: Add GtkShortcutAction
Similar to GtkShortcutTrigger, GtkShortCutAction provides all the
different ways to activate a shortcut.

So far, these different ways are supported:

 - do nothing
 - Call a user-provided callback
 - Call gtk_widget_activate()
 - Call gtk_widget_mnemonic_activate()
 - Emit an action signal
 - Activate an action from the widget's action muxer
2020-03-25 23:14:27 -04:00
Benjamin Otte cdd33bbee6 accelgroup: Remove unneeded APIs
After the removal of GtkAccelMap, these things are no longer necessary.
2020-03-25 23:14:27 -04:00
Emmanuele Bassi bca1f6b64f gtk: Remove GtkAccelMap
Now that accel paths are gone, the object managing them isn't needed
anymore either.
2020-03-25 23:14:27 -04:00
Benjamin Otte 9b99b89807 gtk: Remove accel paths
It's an outdated technology now that everybody is using GActionGroups.

If somebody wanted to support changeable shortcuts, they'd need to
reintroduce it in another way.
2020-03-25 23:14:27 -04:00
Benjamin Otte 62f96bfda6 Remove GtkMnemonicHash
It's not used anymore.
2020-03-25 23:14:27 -04:00
Emmanuele Bassi 2c62cde780 window: Remove all old mnemonic handling API 2020-03-25 23:14:27 -04:00
Emmanuele Bassi aab10ea43b Add GtkShortcutManager
This adds an interface for taking care of shortcut controllers with
managed scope.

Only GtkWindow currently implements this interface, so we need to ensure
that we check if any top-level widget we reach is a shortcuts manager
before we call into it.
2020-03-25 23:14:27 -04:00
Benjamin Otte 9428807c57 label: Implement mnemonics using shortcuts 2020-03-25 23:14:27 -04:00
Benjamin Otte 21e6e4c026 shortcut: Add gtk_shortcut_set_mnemonic_activate()
Makes the shortcut call gtk_widget_mnemonic_activate() upon activation.
2020-03-25 23:14:27 -04:00
Benjamin Otte bde4cbe377 shortcuttrigger: Add support for mnemonics
Mnemonics need to be triggered with help from the controllers (who
determine the modifiers). Support for that has been added, too.

Mnemonics do not use this yet though.
2020-03-25 23:14:27 -04:00
Benjamin Otte 0b7e74318b window: Put F10 accelerator into its own shortcut controller
So instead of relying on gtk_window_activate_key(), it's now using
proper infrastructure.
2020-03-25 23:14:27 -04:00
Benjamin Otte e398f63bf6 window: Get rid of public APIs that shouldn't be
Event controllers should have replaced all of them.
And if they haven't, apps need to fix their code (I'm
looking at you Gimp).
2020-03-25 23:14:27 -04:00
Benjamin Otte 2244eeb727 gdk: Remove GDK_RELEASE_MASK
It was only ever supported by keybindings and those are gone now.
2020-03-25 23:14:27 -04:00
Benjamin Otte c3af47f5d9 gtk-demo: Add a dumb demo for shortcut triggers 2020-03-25 23:14:27 -04:00
Benjamin Otte 730154df7d shortcutcontroller: Add GtkShortcutScope
Allow setting the scope for a controller. The scope determines at what
point in event propagation the shortcuts will be activated.

Local scope is the usual activation, global scope means that the root
widget activates the shortcuts - ie they are activated at the very
start of event propagation (for global capture events) or the very end
(for global bubble events).
Managed scope so far is unimplemented.

This is supposed to be used to replace accelerators and mnemonics.
2020-03-25 23:14:27 -04:00
Benjamin Otte 2309e1dd38 shortcuttrigger: Add gtk_shortcut_trigger_to_label()
Provide a user-presentable string.
2020-03-25 23:14:27 -04:00
Benjamin Otte 90c7f4608a accelgroup: Add gtk_accel_group_print_label() 2020-03-25 23:14:27 -04:00
Benjamin Otte 66102dacf1 accellabel: Move gtk_accelerator_get_label() code
The function lives in gtkaccelgroup.c, so there's no need to have that
call a private function in another source file. Instead, make that
other source file call gtk_accelerator_get_label() instead.
2020-03-25 23:14:27 -04:00
Benjamin Otte d84b60e5f9 accellabel: Get rid of class variables
We can just look them up as-needed, no need to cache them.
2020-03-25 23:14:27 -04:00
Benjamin Otte 9a03c8b4d8 gtk: Remove bindings
The whole binding functionality is now handled by shortcuts.
2020-03-25 23:14:27 -04:00
Emmanuele Bassi f02521c502 Remove bindings activation from GtkEventControllerKey
We're going to use shortcuts soon.
2020-03-25 22:36:03 -04:00
Matthias Clasen c1247a7993 popover: Add keynav keybindings
The shortcut controllers are limited to same-native,
so we need to duplicate the Tab and arrow key bindings
for focus handling, as well as the Enter bindings for
activation.
2020-03-25 22:36:03 -04:00
Emmanuele Bassi b2a747b4d4 popovermenu: Port to shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte c1ee2fd54a accelgroup: Actually have a default mod mask
Don't just use a value without initializing it.
2020-03-25 22:36:03 -04:00
Benjamin Otte 4c7b00fd20 treeview: Redo event forwarding hack
Reorder the event controllers so that key forwarding to the search
entries really happens after shortcut triggering.
2020-03-25 22:36:03 -04:00
Benjamin Otte 3fba7f9dce combobox: Redo key event forwarding hack
Instead of manualling invoking bindings, we now reorder event
controllers inside the treemenu, so that shortcuts run before the event
forwarding.
2020-03-25 22:36:03 -04:00
Emmanuele Bassi 7ca4a94768 widget: Add private accessor to event controllers 2020-03-25 22:36:03 -04:00
Benjamin Otte 1df0a5eab5 iconview: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte 6a005c815e infobar: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte cb09211ace label: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte e430e0e2ff listbox: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte 6ad1078595 notebook: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte cd7e9dcc27 scale: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte 8752f613d7 scalebutton: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte f54d3a3aca scrolledwindow: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte db525ef213 searchentry: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte 3f00e42ec9 shortcutssection: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte d5fa5b9594 shortcutswindow: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte 2e5fc35e51 flowbox: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte 6ff94f3637 paned: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte 80888d7111 spinbutton: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte 48b46c8d08 textview: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte df457cadfc filechooserwidget: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte 58e8f2332d shortcutcontroller: Add gtk_shortcut_controller_add_shortcut()
... and gtk_shortcut_controller_remove_shortcut().
2020-03-25 22:36:03 -04:00
Benjamin Otte 376dc4d169 shortcutcontroller: Add private API for running class shortcuts
We don't want regular users to be able to run class shortcuts in their
controllers, so we have to special case that.
2020-03-25 22:36:03 -04:00
Benjamin Otte dfd81f9c64 treeview: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte 6d418134ee widget: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte 02646d74f4 dialog: Port binding to use shortcuts 2020-03-25 22:36:03 -04:00
Emmanuele Bassi d62be573ad text: Port to widget shortcuts 2020-03-25 22:36:03 -04:00
Emmanuele Bassi 17eef48835 Allow installing bindings bound to actions
This is just convenience code around GtkShortcut, just like bindings for
signal emission and callback invocation.
2020-03-25 22:36:03 -04:00
Emmanuele Bassi 7ffea02eb4 shortcut: Add action activation 2020-03-25 22:36:03 -04:00
Emmanuele Bassi 0b75edc0e1 bindings: Export action activation internally
We're going to use it, just like we use the signal emission code.
2020-03-25 22:36:03 -04:00
Benjamin Otte d4bba7de88 shortcut: Add gtk_shortcut_set_callback()
... and gtk_widget_class_add_binding() to go with it.

This allows shortcuts to invoke manually added callbacks.
2020-03-25 22:36:03 -04:00
Benjamin Otte a8902da4bc assistant: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte 8ff18b3d39 combobox: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte 81fa63260e trigger: Add an alternative trigger
And use it.

I just added it to GtkWidget just to show that I can.
The real reason I want it is for gamepad/joystick triggers
in games, so that it becomes possible to select 2 different
triggers (gamepad and keyboard) for the same shortcut.
2020-03-25 22:36:03 -04:00
Matthias Clasen 6d452f1eb8 shortcut: Add GtkShortcutTrigger
Triggers are meant to describe how to trigger a shortcut.
So far only a keyval + modifiers trigger exists.
2020-03-25 22:36:03 -04:00
Benjamin Otte d51b8ff058 window: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte b11263ae91 bindings: Add more variant types
Also marshal types that the code in gtkbindings.c doesn't use. These
will be used by gtk_widget_class_add_binding_signal().
2020-03-25 22:36:03 -04:00
Benjamin Otte 0eb1228902 widget: Add gtk_widget_class_add_shortcut()
This allows adding shortcuts as a replacement for keybindings.
2020-03-25 22:36:03 -04:00
Benjamin Otte d8603864a9 gtk: Add GtkShortcut
This is the base class for what is about to take over all sorts of
keyboard shortcuts. The initial version barely deals with keybindings.
2020-03-25 22:36:03 -04:00
Benjamin Otte f9ee703af4 bindings: Split out function to invoke an action signal
We want to use that in shortcuts later.
2020-03-25 22:36:03 -04:00
Benjamin Otte a232107122 shortcutcontroller: Introduce
This is a very barebones controller that currently does nothing but
activate the binding signals. Yay.

And because we have bindings on every widget (Yes, a GtkGrid has a
keybinding - 2 in fact), we need that controller everywhere.
2020-03-25 22:36:03 -04:00
Benjamin Otte 27834b04ae bindings: Make gtk_binding_parse_signal() use GVariantBuilder
And because it's the last user of GtkBindingArg and
gtk_binding_entry_add_signall(), also remove those two.
2020-03-25 22:36:03 -04:00
Benjamin Otte cbe207a8de bindings: Parse into GVariantBuilder directly
Avoids the indirection via GtkBindingArg
2020-03-25 22:36:03 -04:00
Benjamin Otte 1cab5e03ca bindings: Add gtk_binding_entry_add_signal_variant()
This function is the replacement for
gtk_binding_entry_add_signall().

The GVariant will be demarshalled and passed to the action signal upon
binding activation. The same rules apply as used to apply for
GtkBindingArg, in that long, double and string args are now replaced by
"x", "d" and "s" variant types.
2020-03-25 22:36:03 -04:00
Benjamin Otte f8c523fa72 bindings: Replace GtkBindingArg arguments with GVariant
So far, this only replaces invocation, not yet parsing.
2020-03-25 22:36:03 -04:00
Matthias Clasen e17db0abde Merge branch 'matthiasc/for-master2' into 'master'
Matthiasc/for master2

See merge request GNOME/gtk!1568
2020-03-26 02:30:54 +00:00
Matthias Clasen cc9c45a47a Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1567
2020-03-26 01:54:30 +00:00
Emmanuele Bassi a9c3a33620 passwordentry: Remove unused include 2020-03-25 21:53:12 -04:00
Emmanuele Bassi f61d520ab1 entry: Remove unused include 2020-03-25 21:53:06 -04:00
Matthias Clasen 7672e6c833 text view: Fix touch selection
We forgot to allocated that popover.
2020-03-25 18:48:01 -04:00
Matthias Clasen faf61cd112 event controller focus: drop include
This header is not needed here, and it is going away.
2020-03-25 18:47:54 -04:00
Matthias Clasen 1308ecb0ae flattenlistmodel: Give access to child models
Add an api to retrieve the model containing a given
item in a flatten listmodel. This is useful when the
individual items in the list don't have backpointers.
2020-03-25 18:47:46 -04:00
Matthias Clasen 4f6096947e Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1565
2020-03-25 21:48:38 +00:00
Matthias Clasen dc18572a59 Merge branch 'wip/chergert/muxer-robustness-fix' into 'master'
muxer: force muxer dispoal as part of widget dispose

See merge request GNOME/gtk!1564
2020-03-25 21:34:56 +00:00
Matthias Clasen 8493ebfe98 filechoosererrorstack: Fix object life-cycle
Unparent children in dispose, not in finalize.
2020-03-25 17:04:29 -04:00
Matthias Clasen 5870d9d72a testsuite: Set NO_AT_BRIDGE for gtk tests
The a11y stack insists on spewing hard to control warnings
that make our tests fail. So, no accessibility for gtk tests :(
2020-03-25 17:03:58 -04:00
Christian Hergert b5b836668a muxer: force muxer dispoal as part of widget dispose
We need to cleanup state here immediately so that we do not potentially
access the g_class private data after it been finalized. This ensures that
the borrowed reference is dropped by the muxer.
2020-03-25 14:02:59 -07:00
Timm Bäder c155ac98c8 Merge branch 'wip/sadiq/fix-leak' into 'master'
singleselection: Fix a memory leak

See merge request GNOME/gtk!1554
2020-03-25 09:13:50 +00:00
Timm Bäder 600952e295 magnifier: Don't try to use a null widget paintable
We destroy the paintable in dispose, which can be called multiple times.
2020-03-24 10:44:06 +01:00
Timm Bäder 3b2adf5d1f inspector: Fix child widget life cycle
unparent them in dispose
2020-03-24 10:44:06 +01:00
Timm Bäder 56d99ab5cd Merge branch 'patch-2' into 'master'
gtkfilechoosernative: Remove duplicate "the" in the documentation

See merge request GNOME/gtk!1557
2020-03-24 06:08:26 +00:00
LingMan 29c9776daa gtkfilechoosernative: Remove duplicate "the" in the documentation 2020-03-24 04:58:13 +00:00
Marc-Antoine Perennou eb8e0910c3 testsuite/gtk/flattenlistmodel.c: fix build
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2020-03-22 10:53:59 +01:00
Mohammed Sadiq cfc44e09a0 singleselection: Fix a memory leak 2020-03-22 14:05:56 +05:30
713 changed files with 65815 additions and 50716 deletions
+5 -5
View File
@@ -27,14 +27,14 @@ variables:
style-check-diff:
extends: .only-default
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v15
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16
stage: .pre
allow_failure: true
script:
- .gitlab-ci/run-style-check-diff.sh
fedora-x86_64:
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v15
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16
stage: build
variables:
EXTRA_MESON_FLAGS: "--buildtype=debug --default-library=both"
@@ -66,7 +66,7 @@ fedora-x86_64:
<<: *cache-paths
release-build:
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v15
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16
stage: build
variables:
EXTRA_MESON_FLAGS: "--buildtype=release"
@@ -168,7 +168,7 @@ flatpak-master:icon-browser:
<<: *flatpak-master
static-scan:
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v15
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16
stage: analysis
variables:
EXTRA_MESON_FLAGS: "--buildtype=debug"
@@ -181,7 +181,7 @@ static-scan:
allow_failure: true
reference:
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v15
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16
stage: docs
variables:
EXTRA_MESON_FLAGS: "--buildtype=release"
+1 -1
View File
@@ -82,7 +82,7 @@ RUN dnf -y install \
xorg-x11-server-Xvfb \
&& dnf clean all
RUN pip3 install meson==0.52.1
RUN pip3 install meson==0.53.1
ARG HOST_USER_ID=5555
ENV HOST_USER_ID ${HOST_USER_ID}
+20 -20
View File
@@ -174,7 +174,7 @@ ul.images li {
<div class="failures">
<h4><a name="{{ suite_result.suite_name }}-failed">Failures</a></h4>
<ul class="failed">
{% for failure in suite_result.failures if failure.result in [ 'FAIL', 'UNEXPECTEDPASS' ] %}
{% for failure in suite_result.failures if failure.result in [ 'ERROR', 'FAIL', 'UNEXPECTEDPASS' ] %}
<li><a name="{{ failure.name }}">{{ failure.name }}</a> - result: <span class="result fail">{{ failure.result }}</span><br/>
{% if failure.stdout %}
Output: <pre>{{ failure.stdout }}</pre>
@@ -207,24 +207,6 @@ ul.images li {
</div>
<div class="successes">
<h4><a name="{{ suite_result.suite_name }}-skipped">Skipped</a></h4>
<ul>
{% for success in suite_result.successes if success.result == 'SKIP' %}
<li>{{ success.name }} - result: <span class="result skip">{{ success.result }}</li>
{% else %}
<li>None</li>
{% endfor %}
</ul>
<h4><a name="{{ suite_result.suite_name }}-passed">Passed</a></h4>
<ul class="passed">
{% for success in suite_result.successes if success.result == 'OK' %}
<li>{{ success.name }} - result: <span class="result pass">{{ success.result }}</li>
{% else %}
<li>None</li>
{% endfor %}
</ul>
<h4><a name="{{ suite_result.suite_name }}-expected-fail">Expected failures</a></h4>
<ul>
{% for success in suite_result.successes if success.result == 'EXPECTEDFAIL' %}
@@ -244,6 +226,24 @@ ul.images li {
<li>None</li>
{% endfor %}
</ul>
<h4><a name="{{ suite_result.suite_name }}-skipped">Skipped</a></h4>
<ul>
{% for success in suite_result.successes if success.result == 'SKIP' %}
<li>{{ success.name }} - result: <span class="result skip">{{ success.result }}</li>
{% else %}
<li>None</li>
{% endfor %}
</ul>
<h4><a name="{{ suite_result.suite_name }}-passed">Passed</a></h4>
<ul class="passed">
{% for success in suite_result.successes if success.result == 'OK' %}
<li>{{ success.name }} - result: <span class="result pass">{{ success.result }}</li>
{% else %}
<li>None</li>
{% endfor %}
</ul>
</div>
</div>
@@ -331,7 +331,7 @@ for name, units in suites.items():
print('Processing {} suite {}:'.format(project_name, suite_name))
def if_failed(unit):
if unit['result'] in ['FAIL', 'UNEXPECTEDPASS', 'TIMEOUT']:
if unit['result'] in ['FAIL', 'UNEXPECTEDPASS', 'TIMEOUT', 'ERROR',]:
return True
return False
+1 -1
View File
@@ -70,7 +70,7 @@ for name, units in suites.items():
print('Processing suite {} (units: {})'.format(name, len(units)))
def if_failed(unit):
if unit['result'] in ['FAIL', 'UNEXPECTEDPASS', 'TIMEOUT']:
if unit['result'] in ['ERROR', 'FAIL', 'UNEXPECTEDPASS', 'TIMEOUT']:
return True
return False
+20
View File
@@ -1,3 +1,23 @@
Overview of Changes in GTK 3.98.2
=================================
* Introduce GtkShortcutController, and replace key bindings,
mnemonics and accelerators by GtkShortcut
* Derive the HighContrast theme from Adwaita
* GtkMenuButton: Add a use-underline property
* GtkTreeView: Fix cell editing
* Add gdk_toplevel_inhibit_system_shortcuts
* gtk-demo: Fix issues in multiple demos
* Translation updates:
Polish
Overview of Changes in GTK 3.98.1
=================================
+2 -2
View File
@@ -214,7 +214,7 @@ constraint_view_add_child (ConstraintView *view,
label = gtk_label_new (name);
frame = gtk_frame_new (NULL);
gtk_style_context_add_class (gtk_widget_get_style_context (frame), "child");
gtk_widget_add_css_class (frame, "child");
gtk_widget_set_name (frame, name);
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_widget_set_parent (frame, GTK_WIDGET (view));
@@ -257,7 +257,7 @@ constraint_view_add_guide (ConstraintView *view,
G_BINDING_DEFAULT);
frame = gtk_frame_new (NULL);
gtk_style_context_add_class (gtk_widget_get_style_context (frame), "guide");
gtk_widget_add_css_class (frame, "guide");
g_object_set_data (G_OBJECT (frame), "internal", (char *)"yes");
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_widget_insert_after (frame, GTK_WIDGET (view), NULL);
+1 -1
View File
@@ -11,7 +11,7 @@
<item>
<attribute name="label" translatable="yes">_Quit</attribute>
<attribute name="action">app.quit</attribute>
<attribute name="accel">&lt;Primary&gt;q</attribute>
<attribute name="accel">&lt;Control&gt;q</attribute>
</item>
</section>
</menu>
+6 -11
View File
@@ -7,7 +7,6 @@
#include <gtk/gtk.h>
/*static GtkWidget *assistant = NULL;*/
static GtkWidget *progress_bar = NULL;
static gboolean
@@ -42,10 +41,7 @@ on_assistant_apply (GtkWidget *widget, gpointer data)
static void
on_assistant_close_cancel (GtkWidget *widget, gpointer data)
{
GtkWidget **assistant = (GtkWidget **) data;
gtk_widget_destroy (*assistant);
*assistant = NULL;
gtk_widget_destroy (widget);
}
static void
@@ -182,6 +178,8 @@ do_assistant (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (assistant),
gtk_widget_get_display (do_widget));
g_signal_connect (assistant, "destroy",
G_CALLBACK (gtk_widget_destroyed), &assistant);
create_page1 (assistant);
create_page2 (assistant);
@@ -189,9 +187,9 @@ do_assistant (GtkWidget *do_widget)
create_page4 (assistant);
g_signal_connect (G_OBJECT (assistant), "cancel",
G_CALLBACK (on_assistant_close_cancel), &assistant);
G_CALLBACK (on_assistant_close_cancel), NULL);
g_signal_connect (G_OBJECT (assistant), "close",
G_CALLBACK (on_assistant_close_cancel), &assistant);
G_CALLBACK (on_assistant_close_cancel), NULL);
g_signal_connect (G_OBJECT (assistant), "apply",
G_CALLBACK (on_assistant_apply), NULL);
g_signal_connect (G_OBJECT (assistant), "prepare",
@@ -201,10 +199,7 @@ do_assistant (GtkWidget *do_widget)
if (!gtk_widget_get_visible (assistant))
gtk_widget_show (assistant);
else
{
gtk_widget_destroy (assistant);
assistant = NULL;
}
gtk_widget_destroy (assistant);
return assistant;
}
-1
View File
@@ -25,7 +25,6 @@
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow">
<property name="can-focus">1</property>
<property name="vexpand">1</property>
<property name="shadow-type">in</property>
<property name="min-content-width">150</property>
+12 -14
View File
@@ -131,13 +131,11 @@ blur_overlay_child_update_style_classes (BlurOverlay *overlay,
GtkAlign valign, halign;
gboolean is_left, is_right, is_top, is_bottom;
gboolean has_left, has_right, has_top, has_bottom;
GtkStyleContext *context;
context = gtk_widget_get_style_context (child);
has_left = gtk_style_context_has_class (context, GTK_STYLE_CLASS_LEFT);
has_right = gtk_style_context_has_class (context, GTK_STYLE_CLASS_RIGHT);
has_top = gtk_style_context_has_class (context, GTK_STYLE_CLASS_TOP);
has_bottom = gtk_style_context_has_class (context, GTK_STYLE_CLASS_BOTTOM);
has_left = gtk_widget_has_css_class (child, GTK_STYLE_CLASS_LEFT);
has_right = gtk_widget_has_css_class (child, GTK_STYLE_CLASS_RIGHT);
has_top = gtk_widget_has_css_class (child, GTK_STYLE_CLASS_TOP);
has_bottom = gtk_widget_has_css_class (child, GTK_STYLE_CLASS_BOTTOM);
is_left = is_right = is_top = is_bottom = FALSE;
@@ -160,24 +158,24 @@ blur_overlay_child_update_style_classes (BlurOverlay *overlay,
is_bottom = (child_allocation->y + child_allocation->height == height);
if (has_left && !is_left)
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_LEFT);
gtk_widget_remove_css_class (child, GTK_STYLE_CLASS_LEFT);
else if (!has_left && is_left)
gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT);
gtk_widget_add_css_class (child, GTK_STYLE_CLASS_LEFT);
if (has_right && !is_right)
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_RIGHT);
gtk_widget_remove_css_class (child, GTK_STYLE_CLASS_RIGHT);
else if (!has_right && is_right)
gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT);
gtk_widget_add_css_class (child, GTK_STYLE_CLASS_RIGHT);
if (has_top && !is_top)
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TOP);
gtk_widget_remove_css_class (child, GTK_STYLE_CLASS_TOP);
else if (!has_top && is_top)
gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP);
gtk_widget_add_css_class (child, GTK_STYLE_CLASS_TOP);
if (has_bottom && !is_bottom)
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BOTTOM);
gtk_widget_remove_css_class (child, GTK_STYLE_CLASS_BOTTOM);
else if (!has_bottom && is_bottom)
gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM);
gtk_widget_add_css_class (child, GTK_STYLE_CLASS_BOTTOM);
}
static void
+6 -4
View File
@@ -104,6 +104,10 @@
<file>gtkfishbowl.c</file>
<file>gtkfishbowl.h</file>
</gresource>
<gresource prefix="/gears">
<file>gtkgears.c</file>
<file>gtkgears.h</file>
</gresource>
<gresource prefix="/iconscroll">
<file>iconscroll.ui</file>
</gresource>
@@ -176,6 +180,7 @@
<file>font_features.c</file>
<file>fontplane.c</file>
<file>fontrendering.c</file>
<file>gears.c</file>
<file>gestures.c</file>
<file>glarea.c</file>
<file>headerbar.c</file>
@@ -202,7 +207,6 @@
<file>peg_solitaire.c</file>
<file>pickers.c</file>
<file>pixbufs.c</file>
<file>popover.c</file>
<file>printing.c</file>
<file>revealer.c</file>
<file>rotated_text.c</file>
@@ -210,6 +214,7 @@
<file>search_entry.c</file>
<file>search_entry2.c</file>
<file>shortcuts.c</file>
<file>shortcut_triggers.c</file>
<file>sizegroup.c</file>
<file>sidebar.c</file>
<file>sliding_puzzle.c</file>
@@ -239,9 +244,6 @@
<file>messages.txt</file>
<file>apple-red.png</file>
</gresource>
<gresource prefix="/popover">
<file>popover.ui</file>
</gresource>
<gresource prefix="/glarea">
<file>glarea-gl.fs.glsl</file>
<file>glarea-gl.vs.glsl</file>
+8 -8
View File
@@ -29,29 +29,29 @@
<item>
<attribute name="label" translatable="yes">_New</attribute>
<attribute name="action">win.new</attribute>
<attribute name="accel">&lt;Primary&gt;n</attribute>
<attribute name="accel">&lt;Control&gt;n</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Open</attribute>
<attribute name="action">win.open</attribute>
<attribute name="accel">&lt;Primary&gt;o</attribute>
<attribute name="accel">&lt;Control&gt;o</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Save</attribute>
<attribute name="action">win.save</attribute>
<attribute name="accel">&lt;Primary&gt;s</attribute>
<attribute name="accel">&lt;Control&gt;s</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Save _As</attribute>
<attribute name="action">win.save-as</attribute>
<attribute name="accel">&lt;Primary&gt;q</attribute>
<attribute name="accel">&lt;Control&gt;q</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">_Quit</attribute>
<attribute name="action">win.quit</attribute>
<attribute name="accel">&lt;Primary&gt;&lt;Shift&gt;s</attribute>
<attribute name="accel">&lt;Control&gt;&lt;Shift&gt;s</attribute>
</item>
</section>
</submenu>
@@ -61,17 +61,17 @@
<item>
<attribute name="label" translatable="yes">_Copy</attribute>
<attribute name="action">win.copy</attribute>
<attribute name="accel">&lt;Primary&gt;c</attribute>
<attribute name="accel">&lt;Control&gt;c</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Cut</attribute>
<attribute name="action">win.cut</attribute>
<attribute name="accel">&lt;Primary&gt;x</attribute>
<attribute name="accel">&lt;Control&gt;x</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Paste</attribute>
<attribute name="action">win.paste</attribute>
<attribute name="accel">&lt;Primary&gt;v</attribute>
<attribute name="accel">&lt;Control&gt;v</attribute>
</item>
</section>
</submenu>
+2 -2
View File
@@ -81,7 +81,7 @@ deserialize_widget (GtkDemoWidget *demo)
else if (demo->type == GTK_TYPE_SPINNER)
{
widget = g_object_new (demo->type, "spinning", demo->active, NULL);
gtk_style_context_add_class (gtk_widget_get_style_context (widget), "demo");
gtk_widget_add_css_class (widget, "demo");
}
else
{
@@ -114,7 +114,7 @@ new_spinner_cb (GtkWidget *button,
GtkWidget *widget;
widget = gtk_spinner_new ();
gtk_style_context_add_class (gtk_widget_get_style_context (widget), "demo");
gtk_widget_add_css_class (widget, "demo");
gtk_spinner_start (GTK_SPINNER (widget));
gtk_fixed_put (fixed, widget, pos_x, pos_y);
-3
View File
@@ -56,7 +56,6 @@
</child>
<child>
<object class="GtkTreeView" id="treeview1">
<property name="can-focus">1</property>
<property name="model">liststore1</property>
<property name="headers-clickable">0</property>
<child internal-child="selection">
@@ -95,7 +94,6 @@
</child>
<child>
<object class="GtkTreeView" id="treeview2">
<property name="can-focus">1</property>
<property name="headers-clickable">0</property>
<property name="search-column">0</property>
<child internal-child="selection">
@@ -178,7 +176,6 @@
</child>
<child>
<object class="GtkTreeView" id="treeview3">
<property name="can-focus">1</property>
<property name="headers-clickable">0</property>
<property name="search-column">0</property>
<child internal-child="selection">
+1 -1
View File
@@ -62,7 +62,7 @@ create_blurred_button (void)
{
GtkWidget *w = gtk_button_new ();
gtk_style_context_add_class (gtk_widget_get_style_context (w), "blurred-button");
gtk_widget_add_css_class (w, "blurred-button");
return w;
}
+1 -1
View File
@@ -52,7 +52,7 @@ create_faces (void)
/* Add a face */
faces[i].face = gtk_frame_new (NULL);
gtk_widget_set_size_request (faces[i].face, face_size, face_size);
gtk_style_context_add_class (gtk_widget_get_style_context (faces[i].face), faces[i].css_class);
gtk_widget_add_css_class (faces[i].face, faces[i].css_class);
gtk_container_add (GTK_CONTAINER (fixed), faces[i].face);
/* Set up the transformation for each face */
-4
View File
@@ -10,7 +10,6 @@
<property name="title">Font Explorer</property>
<child>
<object class="GtkButton" id="reset">
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="tooltip-text">Reset</property>
<signal name="clicked" handler="font_features_reset_features" swapped="no"/>
@@ -27,7 +26,6 @@
<object class="GtkBox">
<child>
<object class="GtkScrolledWindow">
<property name="can-focus">1</property>
<property name="hscrollbar-policy">never</property>
<child>
<object class="GtkViewport">
@@ -41,7 +39,6 @@
<property name="spacing">6</property>
<child>
<object class="GtkFontButton" id="font">
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="font">Sans 12</property>
<property name="level">family|style|size|variations|features</property>
@@ -64,7 +61,6 @@
<property name="orientation">vertical</property>
<child>
<object class="GtkComboBox" id="script_lang">
<property name="can-focus">1</property>
<property name="margin-top">10</property>
<signal name="changed" handler="font_features_script_changed" swapped="no"/>
<child>
-27
View File
@@ -140,17 +140,6 @@ update_value (GtkFontPlane *plane,
gtk_widget_queue_draw (widget);
}
static void
hold_action (GtkGestureLongPress *gesture,
gdouble x,
gdouble y,
GtkFontPlane *plane)
{
gboolean handled;
g_signal_emit_by_name (plane, "popup-menu", &handled);
}
static void
plane_drag_gesture_begin (GtkGestureDrag *gesture,
gdouble start_x,
@@ -161,13 +150,6 @@ plane_drag_gesture_begin (GtkGestureDrag *gesture,
button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
if (button == GDK_BUTTON_SECONDARY)
{
gboolean handled;
g_signal_emit_by_name (plane, "popup-menu", &handled);
}
if (button != GDK_BUTTON_PRIMARY)
{
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_DENIED);
@@ -207,8 +189,6 @@ gtk_font_plane_init (GtkFontPlane *plane)
{
GtkGesture *gesture;
gtk_widget_set_can_focus (GTK_WIDGET (plane), TRUE);
gesture = gtk_gesture_drag_new ();
g_signal_connect (gesture, "drag-begin",
G_CALLBACK (plane_drag_gesture_begin), plane);
@@ -218,13 +198,6 @@ gtk_font_plane_init (GtkFontPlane *plane)
G_CALLBACK (plane_drag_gesture_end), plane);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0);
gtk_widget_add_controller (GTK_WIDGET (plane), GTK_EVENT_CONTROLLER (gesture));
gesture = gtk_gesture_long_press_new ();
g_signal_connect (gesture, "pressed",
G_CALLBACK (hold_action), plane);
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture),
TRUE);
gtk_widget_add_controller (GTK_WIDGET (plane), GTK_EVENT_CONTROLLER (gesture));
}
static void
+137
View File
@@ -0,0 +1,137 @@
/* OpenGL/Gears
*
* This is a classic OpenGL demo, running in a GtkGLArea.
*/
#include <stdlib.h>
#include <gtk/gtk.h>
#include "gtkgears.h"
/************************************************************************
* DEMO CODE *
************************************************************************/
static void
on_axis_value_change (GtkAdjustment *adjustment,
gpointer data)
{
GtkGears *gears = GTK_GEARS (data);
int axis = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (adjustment), "axis"));
gtk_gears_set_axis (gears, axis, gtk_adjustment_get_value (adjustment));
}
static GtkWidget *
create_axis_slider (GtkGears *gears,
int axis)
{
GtkWidget *box, *label, *slider;
GtkAdjustment *adj;
const char *text;
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE);
switch (axis)
{
case GTK_GEARS_X_AXIS:
text = "X";
break;
case GTK_GEARS_Y_AXIS:
text = "Y";
break;
case GTK_GEARS_Z_AXIS:
text = "Z";
break;
default:
g_assert_not_reached ();
}
label = gtk_label_new (text);
gtk_container_add (GTK_CONTAINER (box), label);
gtk_widget_show (label);
adj = gtk_adjustment_new (gtk_gears_get_axis (gears, axis), 0.0, 360.0, 1.0, 12.0, 0.0);
g_object_set_data (G_OBJECT (adj), "axis", GINT_TO_POINTER (axis));
g_signal_connect (adj, "value-changed",
G_CALLBACK (on_axis_value_change),
gears);
slider = gtk_scale_new (GTK_ORIENTATION_VERTICAL, adj);
gtk_scale_set_draw_value (GTK_SCALE (slider), FALSE);
gtk_container_add (GTK_CONTAINER (box), slider);
gtk_widget_set_vexpand (slider, TRUE);
gtk_widget_show (slider);
gtk_widget_show (box);
return box;
}
GtkWidget *
do_gears (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
GtkWidget *box, *hbox, *fps_label, *gears, *overlay, *frame;
int i;
if (!window)
{
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Gears");
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
gtk_window_set_default_size (GTK_WINDOW (window), 640, 640);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
overlay = gtk_overlay_new ();
gtk_widget_set_margin_start (overlay, 12);
gtk_widget_set_margin_end (overlay, 12);
gtk_widget_set_margin_top (overlay, 12);
gtk_widget_set_margin_bottom (overlay, 12);
gtk_container_add (GTK_CONTAINER (window), overlay);
frame = gtk_frame_new (NULL);
gtk_widget_set_halign (frame, GTK_ALIGN_START);
gtk_widget_set_valign (frame, GTK_ALIGN_START);
gtk_widget_add_css_class (frame, "app-notification");
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), frame);
fps_label = gtk_label_new ("");
gtk_widget_set_halign (fps_label, GTK_ALIGN_START);
gtk_container_add (GTK_CONTAINER (frame), fps_label);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE);
gtk_box_set_spacing (GTK_BOX (box), 6);
gtk_container_add (GTK_CONTAINER (overlay), box);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE);
gtk_box_set_spacing (GTK_BOX (box), 6);
gtk_container_add (GTK_CONTAINER (box), hbox);
gears = gtk_gears_new ();
gtk_widget_set_hexpand (gears, TRUE);
gtk_widget_set_vexpand (gears, TRUE);
gtk_container_add (GTK_CONTAINER (hbox), gears);
for (i = 0; i < GTK_GEARS_N_AXIS; i++)
gtk_container_add (GTK_CONTAINER (hbox), create_axis_slider (GTK_GEARS (gears), i));
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE);
gtk_box_set_spacing (GTK_BOX (hbox), 6);
gtk_container_add (GTK_CONTAINER (box), hbox);
gtk_gears_set_fps_label (GTK_GEARS (gears), GTK_LABEL (fps_label));
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_widget_destroy (window);
return window;
}
+1 -1
View File
@@ -1,4 +1,4 @@
/* OpenGL Area
/* OpenGL/OpenGL Area
*
* GtkGLArea is a widget that allows custom drawing using OpenGL calls.
*/
+1 -1
View File
@@ -42,7 +42,7 @@ do_headerbar (GtkWidget *do_widget)
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_style_context_add_class (gtk_widget_get_style_context (box), "linked");
gtk_widget_add_css_class (box, "linked");
button = gtk_button_new ();
gtk_container_add (GTK_CONTAINER (button), gtk_image_new_from_icon_name ("pan-start-symbolic"));
gtk_container_add (GTK_CONTAINER (box), button);
-8
View File
@@ -38,7 +38,6 @@
<property name="baseline-position">top</property>
<child>
<object class="GtkButton" id="button2">
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="valign">baseline</property>
<property name="relief">none</property>
@@ -109,7 +108,6 @@
<child>
<object class="GtkLinkButton" id="resent_by_button">
<property name="label" translatable="0">reshareer</property>
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="relief">none</property>
<property name="uri">http://www.gtk.org</property>
@@ -127,7 +125,6 @@
<child>
<object class="GtkButton" id="expand_button">
<property name="label" translatable="yes">Expand</property>
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="relief">none</property>
<signal name="clicked" handler="expand_clicked" swapped="yes"/>
@@ -140,7 +137,6 @@
<child>
<object class="GtkButton" id="reply-button">
<property name="label" translatable="yes">Reply</property>
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="relief">none</property>
</object>
@@ -148,7 +144,6 @@
<child>
<object class="GtkButton" id="reshare-button">
<property name="label" translatable="yes">Reshare</property>
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="relief">none</property>
<signal name="clicked" handler="reshare_clicked" swapped="yes"/>
@@ -157,7 +152,6 @@
<child>
<object class="GtkButton" id="favorite-buttton">
<property name="label" translatable="yes">Favorite</property>
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="relief">none</property>
<signal name="clicked" handler="favorite_clicked" swapped="yes"/>
@@ -165,7 +159,6 @@
</child>
<child>
<object class="GtkMenuButton" id="more-button">
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="menu-model">menu1</property>
<property name="relief">none</property>
@@ -231,7 +224,6 @@ FAVORITES</property>
<child>
<object class="GtkButton" id="button5">
<property name="label" translatable="yes">Details</property>
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="relief">none</property>
<style>
-1
View File
@@ -310,7 +310,6 @@ static const char *types[] =
"GtkIconView ",
"GtkCellRendererText ",
"GtkContainer ",
"GtkAccelGroup ",
"GtkPaned ",
"GtkPrintOperation ",
"GtkPrintContext ",
-8
View File
@@ -34,7 +34,6 @@
<child>
<object class="GtkButton">
<property name="valign">center</property>
<property name="can-focus">1</property>
<property name="action-name">win.run</property>
<style>
<class name="text-button"/>
@@ -62,12 +61,10 @@
<child>
<object class="GtkScrolledWindow">
<property name="width-request">120</property>
<property name="can-focus">1</property>
<property name="hscrollbar-policy">never</property>
<property name="min-content-width">150</property>
<child>
<object class="GtkTreeView" id="treeview">
<property name="can-focus">1</property>
<property name="model">treestore</property>
<property name="headers-visible">0</property>
<child internal-child="selection">
@@ -99,7 +96,6 @@
</child>
<child>
<object class="GtkNotebook" id="notebook">
<property name="can-focus">1</property>
<property name="scrollable">1</property>
<property name="enable-popup">1</property>
<property name="show-border">0</property>
@@ -110,10 +106,8 @@
<property name="tab-expand">1</property>
<property name="child">
<object class="GtkScrolledWindow">
<property name="can-focus">1</property>
<child>
<object class="GtkTextView" id="info-textview">
<property name="can-focus">1</property>
<property name="left-margin">20</property>
<property name="right-margin">20</property>
<property name="top-margin">20</property>
@@ -141,10 +135,8 @@
<property name="tab-expand">1</property>
<property name="child">
<object class="GtkScrolledWindow" id="source-scrolledwindow">
<property name="can-focus">1</property>
<child>
<object class="GtkTextView" id="source-textview">
<property name="can-focus">1</property>
<property name="left-margin">20</property>
<property name="right-margin">20</property>
<property name="top-margin">20</property>
+12 -12
View File
@@ -5,7 +5,7 @@
<item>
<attribute name="label" translatable="yes">_New</attribute>
<attribute name="action">app.new</attribute>
<attribute name="accel">&lt;Primary&gt;n</attribute>
<attribute name="accel">&lt;Control&gt;n</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Open</attribute>
@@ -14,19 +14,19 @@
<item>
<attribute name="label" translatable="yes">_Save</attribute>
<attribute name="action">app.save</attribute>
<attribute name="accel">&lt;Primary&gt;s</attribute>
<attribute name="accel">&lt;Control&gt;s</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Save _As...</attribute>
<attribute name="action">app.save-as</attribute>
<attribute name="accel">&lt;Primary&gt;s</attribute>
<attribute name="accel">&lt;Control&gt;s</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">_Quit</attribute>
<attribute name="action">app.quit</attribute>
<attribute name="accel">&lt;Primary&gt;q</attribute>
<attribute name="accel">&lt;Control&gt;q</attribute>
</item>
</section>
</menu>
@@ -45,19 +45,19 @@
<attribute name="label" translatable="yes">_Red</attribute>
<attribute name="action">app.color</attribute>
<attribute name="target">red</attribute>
<attribute name="accel">&lt;Primary&gt;r</attribute>
<attribute name="accel">&lt;Control&gt;r</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Green</attribute>
<attribute name="action">app.color</attribute>
<attribute name="target">green</attribute>
<attribute name="accel">&lt;Primary&gt;g</attribute>
<attribute name="accel">&lt;Control&gt;g</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Blue</attribute>
<attribute name="action">app.color</attribute>
<attribute name="target">blue</attribute>
<attribute name="accel">&lt;Primary&gt;b</attribute>
<attribute name="accel">&lt;Control&gt;b</attribute>
</item>
</section>
</submenu>
@@ -68,26 +68,26 @@
<attribute name="label" translatable="yes">_Square</attribute>
<attribute name="action">win.shape</attribute>
<attribute name="target">square</attribute>
<attribute name="accel">&lt;Primary&gt;s</attribute>
<attribute name="accel">&lt;Control&gt;s</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Rectangle</attribute>
<attribute name="action">win.shape</attribute>
<attribute name="target">rectangle</attribute>
<attribute name="accel">&lt;Primary&gt;r</attribute>
<attribute name="accel">&lt;Control&gt;r</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Oval</attribute>
<attribute name="action">win.shape</attribute>
<attribute name="target">oval</attribute>
<attribute name="accel">&lt;Primary&gt;o</attribute>
<attribute name="accel">&lt;Control&gt;o</attribute>
</item>
</section>
</submenu>
<item>
<attribute name="label" translatable="yes">_Bold</attribute>
<attribute name="action">win.bold</attribute>
<attribute name="accel">&lt;Primary&gt;&lt;Shift&gt;b</attribute>
<attribute name="accel">&lt;Control&gt;&lt;Shift&gt;b</attribute>
</item>
</section>
</submenu>
@@ -96,7 +96,7 @@
<item>
<attribute name="label" translatable="yes">_About</attribute>
<attribute name="action">win.about</attribute>
<attribute name="accel">&lt;Primary&gt;a</attribute>
<attribute name="accel">&lt;Control&gt;a</attribute>
</item>
</submenu>
</menu>
+2 -1
View File
@@ -28,6 +28,7 @@ demos = files([
'fishbowl.c',
'fixed.c',
'fontrendering.c',
'gears.c',
'gestures.c',
'glarea.c',
'headerbar.c',
@@ -54,7 +55,6 @@ demos = files([
'peg_solitaire.c',
'pickers.c',
'pixbufs.c',
'popover.c',
'printing.c',
'revealer.c',
'rotated_text.c',
@@ -62,6 +62,7 @@ demos = files([
'search_entry.c',
'search_entry2.c',
'shortcuts.c',
'shortcut_triggers.c',
'sidebar.c',
'sizegroup.c',
'sliding_puzzle.c',
+16 -17
View File
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkWindow" id="window1">
<property name="resizable">0</property>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="show-title-buttons">1</property>
@@ -17,31 +18,33 @@
<child>
<object class="GtkMenuButton">
<property name="popover">thing_a</property>
<property name="label">Color</property>
<property name="label">_Color</property>
<property name="use-underline">1</property>
</object>
</child>
<child>
<object class="GtkMenuButton">
<property name="popover">thing_b</property>
<property name="label">Flavors</property>
<property name="label">_Flavors</property>
<property name="use-underline">1</property>
</object>
</child>
<child>
<object class="GtkMenuButton">
<property name="popover">thing_c</property>
<property name="label">Tools</property>
<property name="label">_Tools</property>
<property name="use-underline">1</property>
</object>
</child>
</object>
</child>
</object>
<object class="GtkPopover" id="thing_a">
<style>
<class name="menu"/>
</style>
<child>
<object class="GtkBox">
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkModelButton">
@@ -68,14 +71,12 @@
</child>
</object>
<object class="GtkPopover" id="thing_b">
<style>
<class name="menu"/>
</style>
<child>
<object class="GtkBox">
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<child>
<object class="GtkModelButton">
<property name="action-name">win.chocolate</property>
@@ -101,14 +102,12 @@
</child>
</object>
<object class="GtkPopover" id="thing_c">
<style>
<class name="menu"/>
</style>
<child>
<object class="GtkBox">
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<child>
<object class="GtkModelButton">
<property name="text">Hammer</property>
+6 -4
View File
@@ -56,23 +56,25 @@ do_overlay (GtkWidget *do_widget)
}
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), vbox);
gtk_widget_set_can_target (vbox, FALSE);
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), vbox);
gtk_widget_set_halign (vbox, GTK_ALIGN_CENTER);
gtk_widget_set_valign (vbox, GTK_ALIGN_CENTER);
gtk_widget_set_valign (vbox, GTK_ALIGN_START);
label = gtk_label_new ("<span foreground='blue' weight='ultrabold' font='40'>Numbers</span>");
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
gtk_widget_set_can_target (label, FALSE);
gtk_widget_set_margin_top (label, 8);
gtk_widget_set_margin_bottom (label, 50);
gtk_widget_set_margin_bottom (label, 8);
gtk_container_add (GTK_CONTAINER (vbox), label);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), vbox);
gtk_widget_set_halign (vbox, GTK_ALIGN_CENTER);
gtk_widget_set_valign (vbox, GTK_ALIGN_CENTER);
gtk_entry_set_placeholder_text (GTK_ENTRY (entry), "Your Lucky Number");
gtk_widget_set_margin_top (entry, 50);
gtk_widget_set_margin_top (entry, 8);
gtk_widget_set_margin_bottom (entry, 8);
gtk_container_add (GTK_CONTAINER (vbox), entry);
+1 -1
View File
@@ -74,7 +74,7 @@ do_password_entry (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (box), entry2);
button = gtk_button_new_with_mnemonic ("_Done");
gtk_style_context_add_class (gtk_widget_get_style_context (button), "suggested-action");
gtk_widget_add_css_class (button, "suggested-action");
g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window);
gtk_widget_set_sensitive (button, FALSE);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
-185
View File
@@ -1,185 +0,0 @@
/* Popovers
*
* A bubble-like window containing contextual information or options.
* GtkPopovers can be attached to any widget, and will be displayed
* within the same window, but on top of all its content.
*/
#include <gtk/gtk.h>
static void
toggle_changed_cb (GtkToggleButton *button,
GtkWidget *popover)
{
gtk_widget_set_visible (popover,
gtk_toggle_button_get_active (button));
}
static GtkWidget *
create_popover (GtkWidget *parent,
GtkWidget *child,
GtkPositionType pos)
{
GtkWidget *popover;
popover = gtk_popover_new ();
gtk_widget_set_parent (popover, parent);
gtk_popover_set_position (GTK_POPOVER (popover), pos);
gtk_container_add (GTK_CONTAINER (popover), child);
gtk_widget_set_margin_start (child, 6);
gtk_widget_set_margin_end (child, 6);
gtk_widget_set_margin_top (child, 6);
gtk_widget_set_margin_bottom (child, 6);
gtk_widget_show (child);
return popover;
}
static GtkWidget *
create_complex_popover (GtkWidget *parent,
GtkPositionType pos)
{
GtkWidget *popover, *window, *content;
GtkBuilder *builder;
builder = gtk_builder_new ();
gtk_builder_add_from_resource (builder, "/popover/popover.ui", NULL);
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
content = gtk_bin_get_child (GTK_BIN (window));
g_object_ref (content);
gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (content)),
content);
gtk_widget_destroy (window);
g_object_unref (builder);
popover = create_popover (parent, content, GTK_POS_BOTTOM);
g_object_unref (content);
return popover;
}
static void
entry_size_allocate_cb (GtkEntry *entry,
int width,
int height,
int baseline,
gpointer user_data)
{
GtkEntryIconPosition popover_pos;
GtkPopover *popover = user_data;
cairo_rectangle_int_t rect;
if (gtk_widget_is_visible (GTK_WIDGET (popover)))
{
popover_pos =
GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (entry),
"popover-icon-pos"));
gtk_entry_get_icon_area (entry, popover_pos, &rect);
gtk_popover_set_pointing_to (GTK_POPOVER (popover), &rect);
}
}
static void
entry_icon_press_cb (GtkEntry *entry,
GtkEntryIconPosition icon_pos,
gpointer user_data)
{
GtkWidget *popover = user_data;
cairo_rectangle_int_t rect;
gtk_entry_get_icon_area (entry, icon_pos, &rect);
gtk_popover_set_pointing_to (GTK_POPOVER (popover), &rect);
gtk_widget_show (popover);
g_object_set_data (G_OBJECT (entry), "popover-icon-pos",
GUINT_TO_POINTER (icon_pos));
}
static void
day_selected_cb (GtkCalendar *calendar,
gpointer user_data)
{
cairo_rectangle_int_t rect;
GtkWidget *popover;
GdkEvent *event;
gdouble x, y;
GtkWidget *widget;
event = gtk_get_current_event ();
if (gdk_event_get_event_type (event) != GDK_BUTTON_PRESS)
return;
gdk_event_get_position (event, &x, &y);
widget = gtk_native_get_for_surface (gdk_event_get_surface (event));
gtk_widget_translate_coordinates (widget,
GTK_WIDGET (calendar),
x, y,
&rect.x, &rect.y);
rect.width = rect.height = 1;
popover = create_popover (GTK_WIDGET (calendar),
gtk_entry_new (),
GTK_POS_BOTTOM);
gtk_popover_set_pointing_to (GTK_POPOVER (popover), &rect);
gtk_widget_show (popover);
gdk_event_unref (event);
}
GtkWidget *
do_popover (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
GtkWidget *popover, *box, *widget;
if (!window)
{
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Popovers");
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 24);
gtk_widget_set_margin_start (box, 24);
gtk_widget_set_margin_end (box, 24);
gtk_widget_set_margin_top (box, 24);
gtk_widget_set_margin_bottom (box, 24);
gtk_container_add (GTK_CONTAINER (window), box);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
widget = gtk_toggle_button_new_with_label ("Button");
popover = create_popover (widget,
gtk_label_new ("This popover does not grab input"),
GTK_POS_TOP);
gtk_popover_set_autohide (GTK_POPOVER (popover), FALSE);
g_signal_connect (widget, "toggled",
G_CALLBACK (toggle_changed_cb), popover);
gtk_container_add (GTK_CONTAINER (box), widget);
widget = gtk_entry_new ();
popover = create_complex_popover (widget, GTK_POS_TOP);
gtk_entry_set_icon_from_icon_name (GTK_ENTRY (widget),
GTK_ENTRY_ICON_PRIMARY, "edit-find");
gtk_entry_set_icon_from_icon_name (GTK_ENTRY (widget),
GTK_ENTRY_ICON_SECONDARY, "edit-clear");
g_signal_connect (widget, "icon-press",
G_CALLBACK (entry_icon_press_cb), popover);
g_signal_connect (widget, "size-allocate",
G_CALLBACK (entry_size_allocate_cb), popover);
gtk_container_add (GTK_CONTAINER (box), widget);
widget = gtk_calendar_new ();
g_signal_connect (widget, "day-selected",
G_CALLBACK (day_selected_cb), NULL);
gtk_container_add (GTK_CONTAINER (box), widget);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_widget_destroy (window);
return window;
}
-85
View File
@@ -1,85 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkListStore" id="liststore1">
<columns>
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Item 1</col>
</row>
<row>
<col id="0" translatable="yes">Item 2</col>
</row>
<row>
<col id="0" translatable="yes">Item 3</col>
</row>
<row>
<col id="0" translatable="yes">Item 4</col>
</row>
<row>
<col id="0" translatable="yes">Item 5</col>
</row>
<row>
<col id="0" translatable="yes">Item 6</col>
</row>
<row>
<col id="0" translatable="yes">Item 7</col>
</row>
<row>
<col id="0" translatable="yes">Item 8</col>
</row>
<row>
<col id="0" translatable="yes">Item 9</col>
</row>
<row>
<col id="0" translatable="yes">Item 10</col>
</row>
</data>
</object>
<object class="GtkWindow" id="window">
<child>
<object class="GtkBox" id="box">
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkEntry" id="entry1">
<property name="can-focus">1</property>
<property name="primary-icon-name">edit-find</property>
<property name="secondary-icon-name">edit-clear</property>
</object>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="can-focus">1</property>
<property name="shadow-type">in</property>
<property name="max-content-height">100</property>
<child>
<object class="GtkTreeView" id="treeview1">
<property name="can-focus">1</property>
<property name="vexpand">1</property>
<property name="model">liststore1</property>
<property name="headers-visible">0</property>
<property name="enable-search">0</property>
<property name="search-column">2</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
</child>
<child>
<object class="GtkTreeViewColumn" id="column1">
<child>
<object class="GtkCellRendererText" id="cellrenderer1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>
+2 -3
View File
@@ -28,7 +28,7 @@ fancy_shape_renderer (cairo_t *cr,
(double) attr->ink_rect.width / PANGO_SCALE,
(double) attr->ink_rect.height / PANGO_SCALE);
if (GPOINTER_TO_UINT (attr->data) == 0x2664) /* U+2665 BLACK HEART SUIT */
if (GPOINTER_TO_UINT (attr->data) == 0x2665) /* U+2665 BLACK HEART SUIT */
{
cairo_move_to (cr, .5, .0);
cairo_line_to (cr, .9, -.4);
@@ -190,8 +190,7 @@ do_rotated_text (GtkWidget *do_widget)
/* Add a drawing area */
drawing_area = gtk_drawing_area_new ();
gtk_container_add (GTK_CONTAINER (box), drawing_area);
gtk_style_context_add_class (gtk_widget_get_style_context (drawing_area),
GTK_STYLE_CLASS_VIEW);
gtk_widget_add_css_class (drawing_area, GTK_STYLE_CLASS_VIEW);
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area),
rotated_text_draw,
-3
View File
@@ -43,7 +43,6 @@
</child>
<child>
<object class="GtkScale" id="scale_plain">
<property name="can-focus">1</property>
<property name="width-request">200</property>
<property name="draw-value">0</property>
<property name="adjustment">adjustment1</property>
@@ -72,7 +71,6 @@
</child>
<child>
<object class="GtkScale" id="scale_marks">
<property name="can-focus">1</property>
<property name="width-request">200</property>
<property name="draw-value">0</property>
<property name="adjustment">adjustment2</property>
@@ -108,7 +106,6 @@
</child>
<child>
<object class="GtkScale" id="scale_discrete">
<property name="can-focus">1</property>
<property name="width-request">200</property>
<property name="round-digits">0</property>
<property name="draw-value">0</property>
+7 -4
View File
@@ -216,11 +216,18 @@ entry_add_to_context_menu (GtkEntry *entry)
};
GMenuModel *submenu;
GMenuItem *item;
GAction *action;
GVariant *value;
actions = g_simple_action_group_new ();
g_action_map_add_action_entries (G_ACTION_MAP (actions), entries, G_N_ELEMENTS(entries), entry);
gtk_widget_insert_action_group (GTK_WIDGET (entry), "search", G_ACTION_GROUP (actions));
action = g_action_map_lookup_action (G_ACTION_MAP (actions), "search-by");
value = g_variant_ref_sink (g_variant_new_string ("name"));
set_search_by (G_SIMPLE_ACTION (action), value, entry);
g_variant_unref (value);
menu = g_menu_new ();
item = g_menu_item_new (_("C_lear"), "search.clear");
g_menu_item_set_attribute (item, "touch-icon", "s", "edit-clear-symbolic");
@@ -297,10 +304,6 @@ do_search_entry (GtkWidget *do_widget)
gtk_widget_show (cancel_button);
/* Set up the search icon */
GVariant *value = g_variant_ref_sink (g_variant_new_string ("name"));
set_search_by (NULL, value, entry);
g_variant_unref (value);
gtk_entry_set_icon_activatable (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, TRUE);
gtk_entry_set_icon_sensitive (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, TRUE);
+94
View File
@@ -0,0 +1,94 @@
/* Shortcuts
*
* GtkShortcut is the abstraction used by GTK to handle shortcuts from
* keyboard or other input devices.
*
* Shortcut triggers can be used to weave complex sequences of key
* presses into sophisticated mechanisms to activate shortcuts.
*
* This demo code shows creative ways to do that.
*/
#include <gtk/gtk.h>
static GtkWidget *window = NULL;
static gboolean
shortcut_activated (GtkWidget *widget,
GVariant *unused,
gpointer row)
{
g_print ("activated %s\n", gtk_label_get_label (row));
return TRUE;
}
static GtkShortcutTrigger *
create_ctrl_g (void)
{
return gtk_keyval_trigger_new (GDK_KEY_g, GDK_CONTROL_MASK);
}
static GtkShortcutTrigger *
create_x (void)
{
return gtk_keyval_trigger_new (GDK_KEY_x, 0);
}
struct {
const char *description;
GtkShortcutTrigger * (* create_trigger_func) (void);
} shortcuts[] = {
{ "Press Ctrl-G", create_ctrl_g },
{ "Press X", create_x },
};
GtkWidget *
do_shortcut_triggers (GtkWidget *do_widget)
{
guint i;
if (!window)
{
GtkWidget *list;
GtkEventController *controller;
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Shortcuts");
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
list = gtk_list_box_new ();
gtk_widget_set_margin_top (list, 6);
gtk_widget_set_margin_bottom (list, 6);
gtk_widget_set_margin_start (list, 6);
gtk_widget_set_margin_end (list, 6);
gtk_container_add (GTK_CONTAINER (window), list);
for (i = 0; i < G_N_ELEMENTS (shortcuts); i++)
{
GtkShortcut *shortcut;
GtkWidget *row;
row = gtk_label_new (shortcuts[i].description);
gtk_container_add (GTK_CONTAINER (list), row);
controller = gtk_shortcut_controller_new ();
gtk_shortcut_controller_set_scope (GTK_SHORTCUT_CONTROLLER (controller), GTK_SHORTCUT_SCOPE_GLOBAL);
gtk_widget_add_controller (row, controller);
shortcut = gtk_shortcut_new (shortcuts[i].create_trigger_func(),
gtk_callback_action_new (shortcut_activated, row, NULL));
gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), shortcut);
}
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_widget_destroy (window);
return window;
}
+1 -1
View File
@@ -63,7 +63,7 @@ do_sidebar (GtkWidget *do_widget)
if (i == 0)
{
widget = gtk_image_new_from_icon_name ("org.gtk.Demo4");
gtk_style_context_add_class (gtk_widget_get_style_context (widget), "icon-dropshadow");
gtk_widget_add_css_class (widget, "icon-dropshadow");
gtk_image_set_pixel_size (GTK_IMAGE (widget), 256);
}
else
+36 -44
View File
@@ -160,47 +160,13 @@ check_solved (GtkWidget *grid)
}
static gboolean
puzzle_key_pressed (GtkEventControllerKey *controller,
guint keyval,
guint keycode,
GdkModifierType state,
GtkWidget *grid)
puzzle_key_pressed (GtkWidget *grid,
GVariant *args,
gpointer unused)
{
int dx, dy;
dx = 0;
dy = 0;
switch (keyval)
{
case GDK_KEY_KP_Left:
case GDK_KEY_Left:
/* left */
dx = -1;
break;
case GDK_KEY_KP_Up:
case GDK_KEY_Up:
/* up */
dy = -1;
break;
case GDK_KEY_KP_Right:
case GDK_KEY_Right:
/* right */
dx = 1;
break;
case GDK_KEY_KP_Down:
case GDK_KEY_Down:
/* down */
dy = 1;
break;
default:
/* We return FALSE here because we didn't handle the key that was pressed */
return FALSE;
}
g_variant_get (args, "(ii)", &dx, &dy);
if (!move_puzzle (grid, dx, dy))
{
@@ -276,6 +242,23 @@ puzzle_button_pressed (GtkGestureClick *gesture,
}
}
static void
add_move_binding (GtkShortcutController *controller,
guint keyval,
guint kp_keyval,
int dx,
int dy)
{
GtkShortcut *shortcut;
shortcut = gtk_shortcut_new_with_arguments (
gtk_alternative_trigger_new (gtk_keyval_trigger_new (keyval, 0),
gtk_keyval_trigger_new (kp_keyval, 0)),
gtk_callback_action_new (puzzle_key_pressed, NULL, NULL),
"(ii)", dx, dy);
gtk_shortcut_controller_add_shortcut (controller, shortcut);
}
static void
start_puzzle (GdkPaintable *paintable)
{
@@ -298,12 +281,21 @@ start_puzzle (GdkPaintable *paintable)
aspect_ratio = 1.0;
gtk_aspect_frame_set (GTK_ASPECT_FRAME (frame), 0.5, 0.5, aspect_ratio, FALSE);
/* Add a key event controller so people can use the arrow
/* Add shortcuts so people can use the arrow
* keys to move the puzzle */
controller = gtk_event_controller_key_new ();
g_signal_connect (controller, "key-pressed",
G_CALLBACK (puzzle_key_pressed),
grid);
controller = gtk_shortcut_controller_new ();
add_move_binding (GTK_SHORTCUT_CONTROLLER (controller),
GDK_KEY_Left, GDK_KEY_KP_Left,
-1, 0);
add_move_binding (GTK_SHORTCUT_CONTROLLER (controller),
GDK_KEY_Right, GDK_KEY_KP_Right,
1, 0);
add_move_binding (GTK_SHORTCUT_CONTROLLER (controller),
GDK_KEY_Up, GDK_KEY_KP_Up,
0, -1);
add_move_binding (GTK_SHORTCUT_CONTROLLER (controller),
GDK_KEY_Down, GDK_KEY_KP_Down,
0, 1);
gtk_widget_add_controller (GTK_WIDGET (grid), controller);
controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ());
@@ -427,7 +419,7 @@ do_sliding_puzzle (GtkWidget *do_widget)
gtk_widget_set_margin_bottom (tweaks, 10);
choices = gtk_flow_box_new ();
gtk_style_context_add_class (gtk_widget_get_style_context (choices), GTK_STYLE_CLASS_VIEW);
gtk_widget_add_css_class (choices, GTK_STYLE_CLASS_VIEW);
add_choice (choices, puzzle);
add_choice (choices, gtk_nuclear_animation_new ());
media = gtk_media_file_new_for_resource ("/images/gtk-logo.webm");
+1 -3
View File
@@ -16,7 +16,6 @@
</child>
<child>
<object class="GtkStack" id="stack">
<property name="can-focus">1</property>
<property name="transition-type">crossfade</property>
<child>
<object class="GtkStackPage">
@@ -38,7 +37,6 @@
<property name="child">
<object class="GtkCheckButton">
<property name="label" translatable="yes">Page 2</property>
<property name="can-focus">1</property>
<property name="halign">center</property>
<property name="valign">center</property>
</object>
@@ -53,7 +51,7 @@
<object class="GtkSpinner">
<property name="halign">center</property>
<property name="valign">center</property>
<property name="active">1</property>
<property name="spinning">1</property>
</object>
</property>
</object>
+2 -2
View File
@@ -25,7 +25,7 @@ add_tag (GtkButton *button, DemoTaggedEntry *entry)
DemoTaggedEntryTag *tag;
tag = demo_tagged_entry_tag_new ("Blue");
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (tag)), "blue");
gtk_widget_add_css_class (GTK_WIDGET (tag), "blue");
demo_tagged_entry_tag_set_has_close_button (tag, TRUE);
g_signal_connect (tag, "button-clicked", G_CALLBACK (closed_cb), entry);
@@ -98,7 +98,7 @@ do_tagged_entry (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (box2), button);
button = gtk_button_new_with_mnemonic ("_Done");
gtk_style_context_add_class (gtk_widget_get_style_context (button), "suggested-action");
gtk_widget_add_css_class (button, "suggested-action");
g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
-3
View File
@@ -28,21 +28,18 @@
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Hi, I am a button</property>
<property name="can-focus">1</property>
<property name="receives-default">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">And I&apos;m another button</property>
<property name="can-focus">1</property>
<property name="receives-default">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">This is a button party!</property>
<property name="can-focus">1</property>
<property name="receives-default">1</property>
</object>
</child>
-3
View File
@@ -17,21 +17,18 @@
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Hi, I am a button</property>
<property name="can-focus">1</property>
<property name="receives-default">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">And I&apos;m another button</property>
<property name="can-focus">1</property>
<property name="receives-default">1</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">This is a button party!</property>
<property name="can-focus">1</property>
<property name="receives-default">1</property>
</object>
</child>
+7 -7
View File
@@ -13,13 +13,13 @@
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">&lt;Primary&gt;q</property>
<property name="accelerator">&lt;Control&gt;q</property>
<property name="title">Quit</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">&lt;Primary&gt;d</property>
<property name="accelerator">&lt;Control&gt;d</property>
<property name="title">Switch to dark theme</property>
</object>
</child>
@@ -31,7 +31,7 @@
<property name="view">page2</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">&lt;Primary&gt;s</property>
<property name="accelerator">&lt;Control&gt;s</property>
<property name="title">Search</property>
</object>
</child>
@@ -43,7 +43,7 @@
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">&lt;Primary&gt;b</property>
<property name="accelerator">&lt;Control&gt;b</property>
<property name="title">Set background</property>
</object>
</child>
@@ -55,19 +55,19 @@
<property name="view">page3</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">&lt;Primary&gt;o</property>
<property name="accelerator">&lt;Control&gt;o</property>
<property name="title">Open a file</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">&lt;Primary&gt;r</property>
<property name="accelerator">&lt;Control&gt;r</property>
<property name="title">Start recording</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">&lt;Primary&gt;l</property>
<property name="accelerator">&lt;Control&gt;l</property>
<property name="title">Lock or unlock</property>
</object>
</child>
+97 -44
View File
@@ -25,16 +25,83 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
static char *current_theme;
static void
change_dark_state (GSimpleAction *action,
GVariant *state,
gpointer user_data)
{
GtkSettings *settings = gtk_settings_get_default ();
gboolean prefer_dark = g_variant_get_boolean (state);
char *theme;
const char *new_theme = NULL;
g_object_get (G_OBJECT (settings),
"gtk-theme-name", &theme,
NULL);
if (prefer_dark)
{
if (strcmp (theme, "Adwaita") == 0)
new_theme = "Adwaita-dark";
else if (strcmp (theme, "HighContrastInverse") == 0)
new_theme = "HighContrast";
}
else
{
if (strcmp (theme, "Adwaita-dark") == 0)
new_theme = "Adwaita";
else if (strcmp (theme, "HighContrast") == 0)
new_theme = "HighContrastInverse";
}
if (new_theme)
g_object_set (G_OBJECT (settings),
"gtk-theme-name", new_theme,
NULL);
g_simple_action_set_state (action, state);
g_free (theme);
}
static void
change_theme_state (GSimpleAction *action,
GVariant *state,
gpointer user_data)
{
GtkSettings *settings = gtk_settings_get_default ();
const char *s;
const char *theme;
s = g_variant_get_string (state, NULL);
if (strcmp (s, "adwaita") == 0)
{
theme = "Adwaita";
}
else if (strcmp (s, "adwaita-dark") == 0)
{
theme = "Adwaita-dark";
}
else if (strcmp (s, "highcontrast") == 0)
{
theme = "HighContrast";
}
else if (strcmp (s, "highcontrast-inverse") == 0)
{
theme = "HighContrastInverse";
}
else if (strcmp (s, "current") == 0)
{
theme = current_theme;
}
else
return;
g_object_set (G_OBJECT (settings),
"gtk-application-prefer-dark-theme",
g_variant_get_boolean (state),
"gtk-theme-name", theme,
NULL);
g_simple_action_set_state (action, state);
@@ -391,24 +458,17 @@ on_entry_icon_release (GtkEntry *entry,
#define EPSILON (1e-10)
static gboolean
on_scale_button_query_tooltip (GtkWidget *button,
gint x,
gint y,
gboolean keyboard_mode,
GtkTooltip *tooltip,
gpointer user_data)
static void
on_scale_button_value_changed (GtkScaleButton *button,
gdouble value,
gpointer user_data)
{
GtkScaleButton *scale_button = GTK_SCALE_BUTTON (button);
GtkAdjustment *adjustment;
gdouble val;
gchar *str;
AtkImage *image;
image = ATK_IMAGE (gtk_widget_get_accessible (button));
adjustment = gtk_scale_button_get_adjustment (scale_button);
val = gtk_scale_button_get_value (scale_button);
adjustment = gtk_scale_button_get_adjustment (button);
val = gtk_scale_button_get_value (button);
if (val < (gtk_adjustment_get_lower (adjustment) + EPSILON))
{
@@ -427,32 +487,21 @@ on_scale_button_query_tooltip (GtkWidget *button,
str = g_strdup_printf (C_("volume percentage", "%d%%"), percent);
}
gtk_tooltip_set_text (tooltip, str);
atk_image_set_image_description (image, str);
gtk_widget_set_tooltip_text (GTK_WIDGET (button), str);
atk_object_set_description (gtk_widget_get_accessible (GTK_WIDGET (button)), str);
g_free (str);
return TRUE;
}
static void
on_scale_button_value_changed (GtkScaleButton *button,
gdouble value,
gpointer user_data)
{
gtk_widget_trigger_tooltip_query (GTK_WIDGET (button));
}
static void
on_record_button_toggled (GtkToggleButton *button,
gpointer user_data)
{
GtkStyleContext *context;
context = gtk_widget_get_style_context (GTK_WIDGET (button));
if (gtk_toggle_button_get_active (button))
gtk_style_context_remove_class (context, "destructive-action");
gtk_widget_remove_css_class (GTK_WIDGET (button), "destructive-action");
else
gtk_style_context_add_class (context, "destructive-action");
gtk_widget_add_css_class (GTK_WIDGET (button), "destructive-action");
}
static void
@@ -1671,7 +1720,8 @@ activate (GApplication *app)
GtkCssProvider *provider;
GMenuModel *model;
static GActionEntry win_entries[] = {
{ "dark", NULL, NULL, "false", change_theme_state },
{ "dark", NULL, NULL, "false", change_dark_state },
{ "theme", NULL, "s", "'current'", change_theme_state },
{ "transition", NULL, NULL, "false", change_transition_state },
{ "search", activate_search, NULL, NULL, NULL },
{ "delete", activate_delete, NULL, NULL, NULL },
@@ -1686,23 +1736,27 @@ activate (GApplication *app)
const gchar *accelerators[2];
} accels[] = {
{ "app.about", { "F1", NULL } },
{ "app.quit", { "<Primary>q", NULL } },
{ "app.open-in", { "<Primary>n", NULL } },
{ "app.cut", { "<Primary>x", NULL } },
{ "app.copy", { "<Primary>c", NULL } },
{ "app.paste", { "<Primary>v", NULL } },
{ "win.dark", { "<Primary>d", NULL } },
{ "win.search", { "<Primary>s", NULL } },
{ "app.quit", { "<Control>q", NULL } },
{ "app.open-in", { "<Control>n", NULL } },
{ "app.cut", { "<Control>x", NULL } },
{ "app.copy", { "<Control>c", NULL } },
{ "app.paste", { "<Control>v", NULL } },
{ "win.dark", { "<Control>d", NULL } },
{ "win.search", { "<Control>s", NULL } },
{ "win.delete", { "Delete", NULL } },
{ "win.background", { "<Primary>b", NULL } },
{ "win.open", { "<Primary>o", NULL } },
{ "win.record", { "<Primary>r", NULL } },
{ "win.lock", { "<Primary>l", NULL } },
{ "win.background", { "<Control>b", NULL } },
{ "win.open", { "<Control>o", NULL } },
{ "win.record", { "<Control>r", NULL } },
{ "win.lock", { "<Control>l", NULL } },
};
gint i;
GPermission *permission;
GAction *action;
g_object_get (gtk_settings_get_default (),
"gtk-theme-name", &current_theme,
NULL);
g_type_ensure (my_text_view_get_type ());
provider = gtk_css_provider_new ();
@@ -1717,7 +1771,6 @@ activate (GApplication *app)
gtk_builder_cscope_add_callback_symbols (GTK_BUILDER_CSCOPE (scope),
"on_entry_icon_release", (GCallback)on_entry_icon_release,
"on_scale_button_value_changed", (GCallback)on_scale_button_value_changed,
"on_scale_button_query_tooltip", (GCallback)on_scale_button_query_tooltip,
"on_record_button_toggled", (GCallback)on_record_button_toggled,
"on_page_combo_changed", (GCallback)on_page_combo_changed,
"on_range_from_changed", (GCallback)on_range_from_changed,
+30 -48
View File
@@ -6,10 +6,36 @@
<attribute name="label" translatable="yes">Get Busy</attribute>
<attribute name="action">win.busy</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Dark Theme</attribute>
<attribute name="action">win.dark</attribute>
</item>
<submenu>
<attribute name="label" translatable="yes">Style</attribute>
<section>
<item>
<attribute name="label" translatable="yes">Current</attribute>
<attribute name="action">win.theme</attribute>
<attribute name="target">current</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Adwaita</attribute>
<attribute name="action">win.theme</attribute>
<attribute name="target">adwaita</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Adwaita dark</attribute>
<attribute name="action">win.theme</attribute>
<attribute name="target">adwaita-dark</attribute>
</item>
<item>
<attribute name="label" translatable="yes">High contrast</attribute>
<attribute name="action">win.theme</attribute>
<attribute name="target">highcontrast</attribute>
</item>
<item>
<attribute name="label" translatable="yes">High contrast inverse</attribute>
<attribute name="action">win.theme</attribute>
<attribute name="target">highcontrast-inverse</attribute>
</item>
</section>
</submenu>
<item>
<attribute name="label" translatable="yes">Slide Pages</attribute>
<attribute name="action">win.transition</attribute>
@@ -508,7 +534,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
</child>
<child>
<object class="GtkButton" id="button224">
<property name="can-focus">1</property>
<property name="icon-name">window-close-symbolic</property>
</object>
</child>
@@ -599,14 +624,12 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<child>
<object class="GtkCheckButton" id="checkbutton1">
<property name="label" translatable="yes">checkbutton</property>
<property name="can-focus">1</property>
<property name="active">1</property>
</object>
</child>
<child>
<object class="GtkCheckButton" id="checkbutton2">
<property name="label" translatable="yes">checkbutton</property>
<property name="can-focus">1</property>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
@@ -617,7 +640,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<object class="GtkCheckButton" id="checkbutton3">
<property name="label" translatable="yes">checkbutton</property>
<property name="inconsistent">1</property>
<property name="can-focus">1</property>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
@@ -628,7 +650,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<object class="GtkCheckButton" id="checkbutton4">
<property name="label" translatable="yes">checkbutton</property>
<property name="sensitive">0</property>
<property name="can-focus">1</property>
<property name="active">1</property>
<layout>
<property name="left-attach">0</property>
@@ -640,7 +661,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<object class="GtkCheckButton" id="checkbutton5">
<property name="label" translatable="yes">checkbutton</property>
<property name="sensitive">0</property>
<property name="can-focus">1</property>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">4</property>
@@ -652,7 +672,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<property name="label" translatable="yes">checkbutton</property>
<property name="sensitive">0</property>
<property name="inconsistent">1</property>
<property name="can-focus">1</property>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">5</property>
@@ -662,7 +681,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<child>
<object class="GtkRadioButton" id="radiobutton1">
<property name="label" translatable="yes">radiobutton</property>
<property name="can-focus">1</property>
<property name="active">1</property>
<layout>
<property name="left-attach">0</property>
@@ -673,8 +691,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<child>
<object class="GtkRadioButton" id="radiobutton2">
<property name="label" translatable="yes">radiobutton</property>
<property name="can-focus">1</property>
<property name="active">1</property>
<property name="group">radiobutton1</property>
<layout>
<property name="left-attach">1</property>
@@ -686,8 +702,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<object class="GtkRadioButton" id="radiobutton3">
<property name="label" translatable="yes">radiobutton</property>
<property name="inconsistent">1</property>
<property name="can-focus">1</property>
<property name="active">1</property>
<property name="group">radiobutton1</property>
<layout>
<property name="left-attach">1</property>
@@ -699,8 +713,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<object class="GtkRadioButton" id="radiobutton4">
<property name="label" translatable="yes">radiobutton</property>
<property name="sensitive">0</property>
<property name="can-focus">1</property>
<property name="active">1</property>
<layout>
<property name="left-attach">1</property>
<property name="top-attach">3</property>
@@ -711,8 +723,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<object class="GtkRadioButton" id="radiobutton5">
<property name="label" translatable="yes">radiobutton</property>
<property name="sensitive">0</property>
<property name="can-focus">1</property>
<property name="active">1</property>
<property name="group">radiobutton3</property>
<layout>
<property name="left-attach">1</property>
@@ -725,8 +735,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<property name="label" translatable="yes">radiobutton</property>
<property name="sensitive">0</property>
<property name="inconsistent">1</property>
<property name="can-focus">1</property>
<property name="active">1</property>
<property name="group">radiobutton3</property>
<layout>
<property name="left-attach">1</property>
@@ -785,7 +793,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<child>
<object class="GtkToggleButton" id="togglebutton1">
<property name="label" translatable="yes">togglebutton</property>
<property name="can-focus">1</property>
<property name="receives-default">1</property>
</object>
</child>
@@ -793,14 +800,12 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<object class="GtkToggleButton" id="togglebutton2">
<property name="label" translatable="yes">togglebutton</property>
<property name="sensitive">0</property>
<property name="can-focus">1</property>
<property name="receives-default">1</property>
</object>
</child>
<child>
<object class="GtkToggleButton" id="togglebutton3">
<property name="label" translatable="yes">togglebutton</property>
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="active">1</property>
</object>
@@ -809,7 +814,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<object class="GtkToggleButton" id="togglebutton4">
<property name="label" translatable="yes">togglebutton</property>
<property name="sensitive">0</property>
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="active">1</property>
</object>
@@ -841,14 +845,12 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
</child>
<child>
<object class="GtkFontButton" id="fontbutton1">
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="level">family|style|size|features|variations</property>
</object>
</child>
<child>
<object class="GtkColorButton" id="colorbutton1">
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="rgba">#31316867a09f</property>
<property name="use-alpha">1</property>
@@ -860,7 +862,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<child>
<object class="GtkLinkButton" id="linkbutton1">
<property name="label" translatable="yes">link button</property>
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="has-tooltip">1</property>
<property name="relief">none</property>
@@ -939,7 +940,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<property name="homogeneous">1</property>
<child>
<object class="GtkScale" id="scale1">
<property name="can-focus">1</property>
<property name="adjustment">adjustment1</property>
<property name="restrict-to-fill-level">0</property>
<property name="fill-level">75</property>
@@ -949,7 +949,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<child>
<object class="GtkScale" id="scale2">
<property name="sensitive">0</property>
<property name="can-focus">1</property>
<property name="adjustment">adjustment1</property>
<property name="restrict-to-fill-level">0</property>
<property name="fill-level">75</property>
@@ -962,7 +961,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
</child>
<child>
<object class="GtkScale" id="scale5">
<property name="can-focus">1</property>
<property name="draw-value">0</property>
<property name="has-origin">0</property>
<property name="round-digits">0</property>
@@ -1010,7 +1008,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<child>
<object class="GtkScale" id="scale3">
<property name="height-request">100</property>
<property name="can-focus">1</property>
<property name="orientation">vertical</property>
<property name="adjustment">adjustment1</property>
<property name="restrict-to-fill-level">0</property>
@@ -1023,7 +1020,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<object class="GtkScale" id="scale4">
<property name="height-request">100</property>
<property name="sensitive">0</property>
<property name="can-focus">1</property>
<property name="orientation">vertical</property>
<property name="adjustment">adjustment1</property>
<property name="restrict-to-fill-level">0</property>
@@ -1116,13 +1112,11 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="width-request">150</property>
<property name="can-focus">1</property>
<property name="vscrollbar-policy">always</property>
<property name="shadow-type">in</property>
<property name="vexpand">1</property>
<child>
<object class="GtkTreeView" id="treeview1">
<property name="can-focus">1</property>
<property name="model">liststore1</property>
<property name="headers-clickable">0</property>
<property name="search-column">0</property>
@@ -1193,12 +1187,10 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow2">
<property name="can-focus">1</property>
<property name="shadow-type">in</property>
<property name="vexpand">1</property>
<child>
<object class="GtkTextView" id="textview1">
<property name="can-focus">1</property>
<property name="buffer">textbuffer1</property>
<property name="wrap-mode">2</property>
<property name="left-margin">10</property>
@@ -1220,7 +1212,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<property name="homogeneous">1</property>
<child>
<object class="GtkNotebook" id="notebook1">
<property name="can-focus">1</property>
<child>
<object class="GtkNotebookPage">
<property name="child">
@@ -1268,7 +1259,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
</child>
<child>
<object class="GtkNotebook" id="notebook2">
<property name="can-focus">1</property>
<property name="tab-pos">right</property>
<child>
<object class="GtkNotebookPage">
@@ -1318,7 +1308,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
</child>
<child>
<object class="GtkNotebook" id="notebook3">
<property name="can-focus">1</property>
<property name="tab-pos">bottom</property>
<child>
<object class="GtkNotebookPage">
@@ -1368,7 +1357,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
</child>
<child>
<object class="GtkNotebook" id="notebook4">
<property name="can-focus">1</property>
<property name="tab-pos">left</property>
<child>
<object class="GtkNotebookPage">
@@ -1522,7 +1510,6 @@ microphone-sensitivity-medium-symbolic</property>
<property name="valign">center</property>
<property name="value">.5</property>
<property name="halign">center</property>
<signal name="query-tooltip" handler="on_scale_button_query_tooltip" swapped="no"/>
<signal name="value-changed" handler="on_scale_button_value_changed" swapped="no"/>
<layout>
<property name="left-attach">0</property>
@@ -1556,7 +1543,6 @@ microphone-sensitivity-medium-symbolic</property>
<property name="hscrollbar-policy">never</property>
<child>
<object class="GtkTextView" id="tvo">
<property name="can-focus">1</property>
<property name="buffer">textbuffer2</property>
<property name="left-margin">10</property>
<property name="right-margin">10</property>
@@ -1907,7 +1893,6 @@ microphone-sensitivity-medium-symbolic</property>
<child>
<object class="MyTextView" id="text3">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="buffer">textbuffer1</property>
<property name="wrap-mode">2</property>
<property name="left-margin">10</property>
@@ -2008,20 +1993,17 @@ microphone-sensitivity-medium-symbolic</property>
</child>
<child>
<object class="GtkExpander" id="expander1">
<property name="can-focus">1</property>
<property name="expanded">1</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow3">
<property name="can-focus">1</property>
<property name="shadow-type">in</property>
<property name="margin-top">6</property>
<property name="height-request">226</property>
<child>
<object class="GtkIconView" id="iconview1">
<property name="can-focus">1</property>
<property name="selection-mode">multiple</property>
<property name="model">iconsmodel</property>
<child>
+13 -39
View File
@@ -98,7 +98,10 @@ gdk_display_get_monitor_at_surface
gdk_display_get_clipboard
gdk_display_get_primary_clipboard
gdk_display_get_setting
gdk_display_get_keymap
<SUBSECTION>
gdk_display_map_keyval
gdk_display_map_keycode
<SUBSECTION Standard>
GDK_DISPLAY
@@ -212,7 +215,7 @@ gdk_surface_get_height
gdk_surface_set_shadow_width
gdk_surface_get_device_position
GdkModifierType
GdkModifierIntent
GDK_MODIFIER_MASK
<SUBSECTION>
gdk_surface_get_support_multidevice
@@ -337,49 +340,16 @@ gdk_rectangle_get_type
<SECTION>
<TITLE>Keyboard Handling</TITLE>
<FILE>keys</FILE>
GdkKeymap
GdkKeymapKey
gdk_keymap_lookup_key
gdk_keymap_translate_keyboard_state
gdk_keymap_get_entries_for_keyval
gdk_keymap_get_entries_for_keycode
gdk_keymap_get_direction
gdk_keymap_have_bidi_layouts
gdk_keymap_get_caps_lock_state
gdk_keymap_get_num_lock_state
gdk_keymap_get_scroll_lock_state
gdk_keymap_get_modifier_state
gdk_keymap_add_virtual_modifiers
gdk_keymap_map_virtual_modifiers
gdk_keymap_get_modifier_mask
gdk_keymap_get_display
<SUBSECTION>
gdk_keyval_name
gdk_keyval_from_name
<SUBSECTION>
gdk_keyval_convert_case
gdk_keyval_to_upper
gdk_keyval_to_lower
gdk_keyval_is_upper
gdk_keyval_is_lower
<SUBSECTION>
gdk_keyval_to_unicode
gdk_unicode_to_keyval
<SUBSECTION Standard>
GDK_KEYMAP
GDK_IS_KEYMAP
GDK_TYPE_KEYMAP
GDK_KEYMAP_CLASS
GDK_IS_KEYMAP_CLASS
GDK_KEYMAP_GET_CLASS
<SUBSECTION Private>
GdkKeymapClass
gdk_keymap_get_type
</SECTION>
<SECTION>
@@ -541,9 +511,13 @@ gdk_scroll_event_get_deltas
gdk_scroll_event_is_stop
gdk_key_event_get_keyval
gdk_key_event_get_keycode
gdk_key_event_get_scancode
gdk_key_event_get_group
gdk_key_event_get_consumed_modifiers
gdk_key_event_get_layout
gdk_key_event_get_level
gdk_key_event_is_modifier
GdkEventMatch
gdk_key_event_matches
gdk_key_event_get_match
gdk_focus_event_get_in
gdk_touch_event_get_emulating_pointer
gdk_crossing_event_get_mode
@@ -681,11 +655,11 @@ gdk_toplevel_set_transient_for
gdk_toplevel_set_modal
gdk_toplevel_set_icon_list
gdk_toplevel_show_window_menu
gdk_toplevel_set_accept_focus
gdk_toplevel_set_focus_on_map
gdk_toplevel_set_decorated
gdk_toplevel_set_deletable
gdk_toplevel_supports_edge_constraints
gdk_toplevel_inhibit_system_shortcuts
gdk_toplevel_restore_system_shortcuts
<SUBSECTION Standard>
GDK_TYPE_TOPLEVEL
gdk_toplevel_get_type
-1
View File
@@ -17,7 +17,6 @@ gdk_event_get_type
gdk_frame_clock_get_type
gdk_gl_context_get_type
gdk_gl_texture_get_type
gdk_keymap_get_type
gdk_memory_texture_get_type
gdk_monitor_get_type
gdk_paintable_get_type
+10 -3
View File
@@ -336,6 +336,16 @@
<xi:include href="xml/gtkgesturezoom.xml" />
<xi:include href="xml/gtkgesturestylus.xml" />
<xi:include href="xml/gtkpadcontroller.xml" />
<xi:include href="xml/gtkshortcutcontroller.xml" />
</chapter>
<chapter>
<title>Keyboard shortcuts</title>
<xi:include href="xml/gtkaccelgroup.xml" />
<xi:include href="xml/gtkshortcut.xml" />
<xi:include href="xml/gtkshortcuttrigger.xml" />
<xi:include href="xml/gtkshortcutaction.xml" />
<xi:include href="xml/gtkshortcutmanager.xml" />
</chapter>
<chapter>
@@ -352,10 +362,7 @@
<title>GTK Core Reference</title>
<xi:include href="xml/gtkmain.xml" />
<xi:include href="xml/gtkfeatures.xml" />
<xi:include href="xml/gtkaccelgroup.xml" />
<xi:include href="xml/gtkaccelmap.xml" />
<xi:include href="xml/gtksettings.xml" />
<xi:include href="xml/gtkbindings.xml" />
<xi:include href="xml/gtkenums.xml" />
<xi:include href="xml/gtktesting.xml" />
<xi:include href="xml/filesystem.xml" />
+173 -121
View File
@@ -53,26 +53,6 @@ gtk_about_dialog_get_type
<SECTION>
<FILE>gtkaccelgroup</FILE>
<TITLE>Keyboard Accelerators</TITLE>
GtkAccelGroup
GtkAccelGroupClass
gtk_accel_group_new
GtkAccelFlags
gtk_accel_group_connect
gtk_accel_group_connect_by_path
GtkAccelGroupActivate
GtkAccelGroupFindFunc
gtk_accel_group_disconnect
gtk_accel_group_disconnect_key
gtk_accel_group_activate
gtk_accel_group_lock
gtk_accel_group_unlock
gtk_accel_group_get_is_locked
gtk_accel_group_from_accel_closure
gtk_accel_group_get_modifier_mask
gtk_accel_groups_activate
gtk_accel_groups_from_object
gtk_accel_group_find
GtkAccelKey
gtk_accelerator_valid
gtk_accelerator_parse
gtk_accelerator_name
@@ -80,54 +60,7 @@ gtk_accelerator_get_label
gtk_accelerator_parse_with_keycode
gtk_accelerator_name_with_keycode
gtk_accelerator_get_label_with_keycode
gtk_accelerator_set_default_mod_mask
gtk_accelerator_get_default_mod_mask
<SUBSECTION Standard>
GTK_TYPE_ACCEL_GROUP
GTK_ACCEL_GROUP
GTK_IS_ACCEL_GROUP
GTK_ACCEL_GROUP_CLASS
GTK_IS_ACCEL_GROUP_CLASS
GTK_ACCEL_GROUP_GET_CLASS
<SUBSECTION Private>
GTK_ACCEL_GROUP_GET_PRIVATE
GtkAccelGroupPrivate
GtkAccelGroupEntry
gtk_accel_group_query
gtk_accel_group_get_type
</SECTION>
<SECTION>
<FILE>gtkaccelmap</FILE>
<TITLE>Accelerator Maps</TITLE>
GtkAccelMap
GtkAccelMapForeach
gtk_accel_map_add_entry
gtk_accel_map_lookup_entry
gtk_accel_map_change_entry
gtk_accel_map_load
gtk_accel_map_save
gtk_accel_map_foreach
gtk_accel_map_load_fd
gtk_accel_map_save_fd
gtk_accel_map_load_scanner
gtk_accel_map_add_filter
gtk_accel_map_foreach_unfiltered
gtk_accel_map_get
gtk_accel_map_lock_path
gtk_accel_map_unlock_path
<SUBSECTION Standard>
GTK_ACCEL_MAP
GTK_TYPE_ACCEL_MAP
GTK_IS_ACCEL_MAP
GTK_ACCEL_MAP_CLASS
GTK_IS_ACCEL_MAP_CLASS
GTK_ACCEL_MAP_GET_CLASS
GtkAccelMapClass
<SUBSECTION Private>
gtk_accel_map_get_type
</SECTION>
<SECTION>
@@ -135,10 +68,6 @@ gtk_accel_map_get_type
<TITLE>GtkAccelLabel</TITLE>
GtkAccelLabel
gtk_accel_label_new
gtk_accel_label_set_accel_closure
gtk_accel_label_get_accel_closure
gtk_accel_label_get_accel_widget
gtk_accel_label_set_accel_widget
gtk_accel_label_get_accel_width
gtk_accel_label_set_accel
gtk_accel_label_get_accel
@@ -670,6 +599,8 @@ gtk_color_button_new
gtk_color_button_new_with_rgba
gtk_color_button_set_title
gtk_color_button_get_title
gtk_color_button_set_modal
gtk_color_button_get_modal
<SUBSECTION Standard>
GTK_COLOR_BUTTON
GTK_IS_COLOR_BUTTON
@@ -1226,6 +1157,8 @@ gtk_file_chooser_button_get_title
gtk_file_chooser_button_set_title
gtk_file_chooser_button_get_width_chars
gtk_file_chooser_button_set_width_chars
gtk_file_chooser_button_get_modal
gtk_file_chooser_button_set_modal
<SUBSECTION Standard>
GTK_FILE_CHOOSER_BUTTON
@@ -1316,6 +1249,7 @@ GtkFlattenListModel
gtk_flatten_list_model_new
gtk_flatten_list_model_set_model
gtk_flatten_list_model_get_model
gtk_flatten_list_model_get_model_for_item
<SUBSECTION Standard>
GTK_FLATTEN_LIST_MODEL
GTK_IS_FLATTEN_LIST_MODEL
@@ -1339,6 +1273,8 @@ gtk_font_button_set_use_size
gtk_font_button_get_use_size
gtk_font_button_set_title
gtk_font_button_get_title
gtk_font_button_set_modal
gtk_font_button_get_modal
<SUBSECTION Standard>
GTK_FONT_BUTTON
GTK_IS_FONT_BUTTON
@@ -2368,6 +2304,12 @@ GtkSettingsValue
gtk_settings_get_default
gtk_settings_get_for_display
gtk_settings_reset_property
<SUBSECTION>
gtk_theme_get_dark_variant
gtk_theme_get_light_variant
gtk_theme_get_available_themes
<SUBSECTION Standard>
GtkSettingsClass
GTK_IS_SETTINGS
@@ -4034,10 +3976,9 @@ gtk_widget_add_tick_callback
gtk_widget_remove_tick_callback
gtk_widget_size_allocate
gtk_widget_allocate
gtk_widget_add_accelerator
gtk_widget_remove_accelerator
gtk_widget_set_accel_path
gtk_widget_list_accel_closures
gtk_widget_class_add_shortcut
gtk_widget_class_add_binding
gtk_widget_class_add_binding_signal
gtk_widget_can_activate_accel
gtk_widget_activate
gtk_widget_is_focus
@@ -4133,7 +4074,6 @@ gtk_widget_get_support_multidevice
gtk_widget_get_realized
gtk_widget_get_mapped
gtk_widget_device_is_shadowed
gtk_widget_get_modifier_mask
gtk_widget_get_opacity
gtk_widget_set_opacity
gtk_widget_get_overflow
@@ -4253,8 +4193,6 @@ gtk_window_new
gtk_window_set_title
gtk_window_set_resizable
gtk_window_get_resizable
gtk_window_add_accel_group
gtk_window_remove_accel_group
gtk_window_set_modal
gtk_window_set_default_size
gtk_window_set_hide_on_close
@@ -4266,11 +4204,6 @@ gtk_window_is_active
gtk_window_is_maximized
gtk_window_get_toplevels
gtk_window_list_toplevels
gtk_window_add_mnemonic
gtk_window_remove_mnemonic
gtk_window_mnemonic_activate
gtk_window_activate_key
gtk_window_propagate_key_event
gtk_window_get_focus
gtk_window_set_focus
gtk_window_get_default_widget
@@ -4280,20 +4213,13 @@ gtk_window_present_with_time
gtk_window_close
gtk_window_minimize
gtk_window_unminimize
gtk_window_stick
gtk_window_unstick
gtk_window_maximize
gtk_window_unmaximize
gtk_window_fullscreen
gtk_window_fullscreen_on_monitor
gtk_window_unfullscreen
gtk_window_set_keep_above
gtk_window_set_keep_below
gtk_window_set_decorated
gtk_window_set_deletable
gtk_window_set_mnemonic_modifier
gtk_window_set_accept_focus
gtk_window_set_focus_on_map
gtk_window_set_startup_id
gtk_window_get_decorated
gtk_window_get_deletable
@@ -4301,13 +4227,10 @@ gtk_window_get_default_icon_name
gtk_window_get_default_size
gtk_window_get_destroy_with_parent
gtk_window_get_icon_name
gtk_window_get_mnemonic_modifier
gtk_window_get_modal
gtk_window_get_size
gtk_window_get_title
gtk_window_get_transient_for
gtk_window_get_accept_focus
gtk_window_get_focus_on_map
gtk_window_get_group
gtk_window_has_group
gtk_window_resize
@@ -4376,12 +4299,6 @@ gtk_init_check
<SUBSECTION>
GTK_PRIORITY_RESIZE
<SUBSECTION>
gtk_get_current_event
gtk_get_current_event_time
gtk_get_current_event_state
gtk_get_current_event_device
<SUBSECTION Private>
gtk_init_abi_check
gtk_init_check_abi_check
@@ -4526,7 +4443,6 @@ gtk_style_context_get_margin
gtk_style_context_lookup_color
gtk_style_context_remove_provider
gtk_style_context_remove_provider_for_display
gtk_style_context_reset_widgets
gtk_style_context_restore
gtk_style_context_save
gtk_style_context_add_class
@@ -4617,26 +4533,6 @@ gtk_css_provider_error_quark
gtk_css_section_get_type
</SECTION>
<SECTION>
<FILE>gtkbindings</FILE>
<TITLE>Bindings</TITLE>
GtkBindingSet
gtk_binding_set_new
gtk_binding_set_by_class
gtk_binding_set_find
gtk_bindings_activate
gtk_bindings_activate_event
gtk_binding_set_activate
gtk_binding_entry_add_action
gtk_binding_entry_add_action_variant
GtkBindingCallback
gtk_binding_entry_add_callback
gtk_binding_entry_add_signal
gtk_binding_entry_add_signal_from_string
gtk_binding_entry_skip
gtk_binding_entry_remove
</SECTION>
<SECTION>
<FILE>gtkenums</FILE>
<TITLE>Standard Enumerations</TITLE>
@@ -5221,7 +5117,9 @@ gtk_mount_operation_set_parent
gtk_mount_operation_get_parent
gtk_mount_operation_set_display
gtk_mount_operation_get_display
gtk_show_uri_on_window
gtk_show_uri_full
gtk_show_uri_full_finish
gtk_show_uri
<SUBSECTION Standard>
GTK_IS_MOUNT_OPERATION
GTK_IS_MOUNT_OPERATION_CLASS
@@ -5451,6 +5349,8 @@ gtk_app_chooser_button_get_show_dialog_item
gtk_app_chooser_button_set_show_dialog_item
gtk_app_chooser_button_get_heading
gtk_app_chooser_button_set_heading
gtk_app_chooser_button_get_modal
gtk_app_chooser_button_set_modal
<SUBSECTION Standard>
GTK_TYPE_APP_CHOOSER_BUTTON
@@ -5925,6 +5825,12 @@ gtk_event_controller_set_propagation_limit
gtk_event_controller_get_widget
gtk_event_controller_reset
<SUBSECTION>
gtk_event_controller_get_current_event
gtk_event_controller_get_current_event_device
gtk_event_controller_get_current_event_state
gtk_event_controller_get_current_event_time
<SUBSECTION Standard>
GTK_TYPE_EVENT_CONTROLLER
GTK_EVENT_CONTROLLER
@@ -6061,6 +5967,152 @@ GTK_EVENT_CONTROLLER_MOTION_GET_CLASS
gtk_event_controller_motion_get_type
</SECTION>
<SECTION>
<FILE>gtkshortcuttrigger</FILE>
<TITLE>GtkShortcutTrigger</TITLE>
GtkShortcutTrigger
GtkNeverTrigger
gtk_shortcut_trigger_trigger
gtk_shortcut_trigger_hash
gtk_shortcut_trigger_equal
gtk_shortcut_trigger_compare
gtk_shortcut_trigger_to_string
gtk_shortcut_trigger_print
gtk_shortcut_trigger_to_label
gtk_shortcut_trigger_print_label
gtk_shortcut_trigger_parse_string
<SUBSECTION>
GtkKeyvalTrigger
gtk_keyval_trigger_new
gtk_keyval_trigger_get_modifiers
gtk_keyval_trigger_get_keyval
<SUBSECTION>
GtkMnemonicTrigger
gtk_mnemonic_trigger_new
gtk_mnemonic_trigger_get_keyval
<SUBSECTION>
GtkAlternativeTrigger
gtk_alternative_trigger_new
gtk_alternative_trigger_get_first
<SUBSECTION>
GtkNeverTrigger
gtk_never_trigger_get
<SUBSECTION Private>
gtk_shortcut_trigger_get_type
</SECTION>
<SECTION>
<FILE>gtkshortcutaction</FILE>
<TITLE>GtkShortcutAction</TITLE>
GtkShortcutAction
gtk_shortcut_action_to_string
gtk_shortcut_action_print
gtk_shortcut_action_parse_string
gtk_shortcut_action_activate
<SUBSECTION>
GtkNothingAction
gtk_nothing_action_get
<SUBSECTION>
GtkCallbackAction
gtk_callback_action_new
<SUBSECTION>
GtkMnemonicAction
gtk_mnemonic_action_get
<SUBSECTION>
GtkActivateAction
gtk_activate_action_get
<SUBSECTION>
GtkSignalAction
gtk_signal_action_new
gtk_signal_action_get_signal_name
<SUBSECTION>
GtkNamedAction
gtk_named_action_new
gtk_named_action_get_action_name
<SUBSECTION Private>
gtk_shortcut_action_get_type
</SECTION>
<SECTION>
<FILE>gtkshortcut</FILE>
<TITLE>GtkShortcut</TITLE>
GtkShortcut
gtk_shortcut_new
gtk_shortcut_new_with_arguments
gtk_shortcut_get_trigger
gtk_shortcut_set_trigger
gtk_shortcut_get_action
gtk_shortcut_set_action
gtk_shortcut_get_arguments
gtk_shortcut_set_arguments
<SUBSECTION Standard>
GTK_TYPE_SHORTCUT
GTK_SHORTCUT
GTK_SHORTCUT_CLASS
GTK_IS_SHORTCUT
GTK_IS_SHORTCUT_CLASS
GTK_SHORTCUT_GET_CLASS
<SUBSECTION Private>
gtk_shortcut_get_type
</SECTION>
<SECTION>
<FILE>gtkshortcutmanager</FILE>
<TITLE>GtkShortcutManager</TITLE>
GtkShortcutManager
GtkShortcutManagerInterface
</SECTION>
<SECTION>
<FILE>gtkshortcutcontroller</FILE>
<TITLE>GtkShortcutController</TITLE>
GtkShortcutController
gtk_shortcut_controller_new
gtk_shortcut_controller_new_with_model
GtkShortcutScope
GtkShortcutManager
GtkShortcutManagerInterface
gtk_shortcut_controller_set_mnemonics_modifiers
gtk_shortcut_controller_get_mnemonics_modifiers
gtk_shortcut_controller_set_scope
gtk_shortcut_controller_get_scope
gtk_shortcut_controller_add_shortcut
gtk_shortcut_controller_remove_shortcut
<SUBSECTION Standard>
GTK_TYPE_SHORTCUT_CONTROLLER
GTK_SHORTCUT_CONTROLLER
GTK_SHORTCUT_CONTROLLER_CLASS
GTK_IS_SHORTCUT_CONTROLLER
GTK_IS_SHORTCUT_CONTROLLER_CLASS
GTK_SHORTCUT_CONTROLLER_GET_CLASS
GTK_TYPE_SHORTCUT_MANAGER
GTK_SHORTCUT_MANAGER
GTK_SHORTCUT_MANAGER_CLASS
GTK_IS_SHORTCUT_MANAGER
GTK_IS_SHORTCUT_MANAGER_CLASS
GTK_SHORTCUT_MANAGER_GET_CLASS
<SUBSECTION Private>
gtk_shortcut_controller_get_type
gtk_shortcut_manager_get_type
</SECTION>
<SECTION>
<FILE>gtkeventcontrollerkey</FILE>
<TITLE>GtkEventControllerKey</TITLE>
+3 -2
View File
@@ -2,9 +2,7 @@
#include <gtk/gtkunixprint.h>
gtk_about_dialog_get_type
gtk_accel_group_get_type
gtk_accel_label_get_type
gtk_accel_map_get_type
gtk_accessible_get_type
gtk_actionable_get_type
gtk_action_bar_get_type
@@ -165,7 +163,10 @@ gtk_search_entry_get_type
gtk_selection_model_get_type
gtk_separator_get_type
gtk_settings_get_type
gtk_shortcut_get_type
gtk_shortcut_controller_get_type
gtk_shortcut_label_get_type
gtk_shortcut_manager_get_type
gtk_shortcuts_window_get_type
gtk_shortcuts_section_get_type
gtk_shortcuts_group_get_type
+80 -96
View File
@@ -63,25 +63,19 @@
GDK translates these raw windowing system events into #GdkEvents.
Typical input events are:
<simplelist>
<member>#GdkEventButton</member>
<member>#GdkEventMotion</member>
<member>#GdkEventCrossing</member>
<member>#GdkEventKey</member>
<member>#GdkEventFocus</member>
<member>#GdkEventTouch</member>
<member>button clicks</member>
<member>pointer motion</member>
<member>key presses</member>
<member>focus changes</member>
<member>touch events</member>
</simplelist>
These are all represented as #GdkEvents, but you can differentiate
between different events by looking at their type, using
gdk_event_get_event_type().
</para>
<para>
Additionally, GDK/GTK synthesizes other signals to let know whether
grabs (system-wide or in-app) are taking input away:
<simplelist>
<member>#GdkEventGrabBroken</member>
<member>#GtkWidget::grab-notify</member>
</simplelist>
</para>
<para>
When GTK creates a GdkSurface, it connects to the ::event signal
on it, which receives all of these input events. Surfaces have
When GTK creates a GdkSurface, it connects to the #GdkSurface::event
signal on it, which receives all of these input events. Surfaces have
have signals and properties, e.g. to deal with window management
related events.
</para>
@@ -96,14 +90,11 @@
</para>
<orderedlist>
<listitem><para>
Compress enter/leave notify events. If the event passed build an
enter/leave pair together with the next event (peeked from GDK), both
events are thrown away. This is to avoid a backlog of (de-)highlighting
widgets crossed by the pointer.
Find the widget which got the event.
</para></listitem>
<listitem><para>
Find the widget which got the event. If the widget cant be determined
the event is thrown away unless it belongs to a INCR transaction.
Generate crossing (i.e. enter and leave) events when the focus or hover
location change from one widget to another.
</para></listitem>
<listitem><para>
Then the event is pushed onto a stack so you can query the currently
@@ -137,24 +128,6 @@
</para></listitem>
</orderedlist>
<para>
When a GDK backend produces an input event, it is tied to a #GdkDevice and
a #GdkSurface, which in turn represents a windowing system surface in the
backend. If a widget has grabbed the current input device, or all input
devices, the event is propagated to that #GtkWidget. Otherwise, it is
propagated to the the #GtkRoot which owns the #GdkSurface receiving the event.
</para>
<para>
Grabs are implemented for each input device, and globally. A grab for a
specific input device (gtk_device_grab_add()), is sent events in
preference to a global grab (gtk_grab_add()). Input grabs only have effect
within the #GtkWindowGroup containing the #GtkWidget which registered the
events #GdkSurface. If this #GtkWidget is a child of the grab widget, the
event is propagated to the child — this is the basis for propagating
events within modal dialogs.
</para>
<para>
An event is propagated down and up the widget hierarchy in three phases
(see #GtkPropagationPhase) towards a target widget.
@@ -219,71 +192,75 @@
</para>
</refsect2>
<refsect2>
<title>Grabs</title>
<para>
Grabs are a method to claim all input events from a device,
they happen either implicitly on pointer and touch devices,
or explicitly. Implicit grabs happen on user interaction, when
a #GdkEventButtonPress happens, all events from then on, until
after the corresponding #GdkEventButtonRelease, will be reported
to the widget that got the first event. Likewise, on touch events,
every #GdkEventSequence will deliver only events to the widget
that received its %GDK_TOUCH_BEGIN event.
</para>
<para>
Explicit grabs happen programatically (both activation and
deactivation), and can be either system-wide (GDK grabs) or
application-wide (GTK grabs). On the windowing platforms that
support it, GDK grabs will prevent any interaction with any other
application/window/widget than the grabbing one, whereas GTK grabs
will be effective only within the application (across all its
windows), still allowing for interaction with other applications.
</para>
<para>
But one important aspect of grabs is that they may potentially
happen at any point somewhere else, even while the pointer/touch
device is already grabbed. This makes it necessary for widgets to
handle the cancellation of any ongoing interaction. Depending on
whether a GTK or GDK grab is causing this, the widget will
respectively receive a #GtkWidget::grab-notify signal, or a
#GdkEventGrabBroken event.
</para>
<para>
On gestures, these signals are handled automatically, causing the
gesture to cancel all tracked pointer/touch events, and signal
the end of recognition.
</para>
</refsect2>
<refsect2>
<title>Keyboard input</title>
<para>
Every #GtkWindow maintains a single focus location (in
the ::focus-widget property). The focus widget is the
target widget for key events sent to the window. Only
widgets which have ::can-focus set to %TRUE can become
the focus. Typically these are input controls such as
entries or text fields, but e.g. buttons can take the
focus too.
Every #GtkWindow maintains a single focus location (in the
#GtkWindow:focus-widget property). The focus widget is the target
widget for key events sent to the window. Only widgets which have
#GtkWidget:can-focus set to %TRUE can become the focus. Typically
these are input controls such as entries or text fields, but e.g.
buttons can take the focus too.
</para>
<para>
Input widgets can be given the focus by clicking on them,
but focus can also be moved around with certain key
events (this is known as “keyboard navigation”). GTK
reserves the Tab key to move the focus to the next location,
and Shift-Tab to move it back to the previous one. In addition
many containers allow “directional navigation” with the
arrow keys.
Input widgets can be given the focus by clicking on them, but focus
can also be moved around with certain key events (this is known as
“keyboard navigation”). GTK reserves the Tab key to move the focus
to the next location, and Shift-Tab to move it back to the previous
one. In addition many containers allow “directional navigation” with
the arrow keys.
</para>
<!-- mnemonics, accelerators, bindings -->
<para>
Many widgets can be “activated” to trigger and action. E.g., you can
activate a button or switch by clicking on them, but you can also
activate them with the keyboard, by using the Enter or Space keys.
</para>
<para>
Apart from keyboard navigation, activation and directly typing into
entries or text views, GTK widgets can use key events for activating
“shortcuts”. Shortcuts generally act as a quick way to move the focus
around or to activate a widget that does not currently have the focus.
</para>
<para>
GTK has traditionally supported different kinds of shortcuts:
<variablelist>
<varlistentry>
<term>Mnmemonics</term>
<listitem><para>
Mnemonics are usually triggered using Alt as a modifier for a letter.
They are used in places where a label is associated with a control,
and are indicated by underlining the letter in the label. As a special
case, inside menus (i.e. inside #GtkPopoverMenu), mnemonics can be
trigered without the modifier.
</para></listitem>
</varlistentry>
<varlistentry>
<term>Key bindings</term>
<listitem><para>
Key bindings are specific to individual widgets, such as Ctrl-C or
Ctrl-V in an entry copy to or paste from the clipboard. They are only
triggered when the widget has focus.
</para></listitem>
</varlistentry>
<varlistentry>
<term>Accelerators</term>
<listitem><para>
Accelerators are any other shortcuts that can be activated regardless
of where the focus is, and typically trigger global actions, such as
Ctrl-Q to quit an application.
</para></listitem>
</varlistentry>
</variablelist>
</para>
<para>
Under the hood, all shortcuts are represented as instances of #GtkShortcut,
and they are managed by #GtkShortcutController.
</para>
</refsect2>
<refsect2 id="event-controllers-and-gestures">
@@ -330,6 +307,13 @@
</member>
</simplelist>
</para>
<para>
Shortcuts are handled by #GtkShortcutController, which is
a complex event handler that can either activate shortcuts
itself, or propagate them to another controller, depending
on its #GtkShortcutController:scope.
</para>
</refsect2>
<refsect2>
+87 -11
View File
@@ -339,6 +339,15 @@
</para>
</section>
<section>
<title>Stop using gtk_get_current_... APIs</title>
<para>
The function gtk_get_current_event() and its variants have been
replaced by equivalent event controller APIs:
gtk_event_controller_get_current_event(), etc.
</para>
</section>
<section>
<title>Adapt to surface API changes</title>
<para>
@@ -397,8 +406,29 @@
<section>
<title>Adapt to GdkKeymap API changes</title>
<para>
The way to get a keymap has changed slightly. gdk_keymap_get_for_display() has
been renamed to gdk_display_get_keymap().
GdkKeymap no longer exists as an independent object.
</para>
<para>
If you need access to keymap state, it is now exposed as properties
on the #GdkDevice representing the keyboard: #GdkDevice:direction,
#GdkDevice:has-bidi-layouts, #GdkDevice:caps-lock-state,
#GdkDevice:num-lock-state, #GdkDevice:scroll-lock-state and
#GdkDevice:modifier-state.
To obtain the keyboard device, you can use
<literal>gdk_seat_get_keyboard (gdk_display_get_default_seat (display))</literal>.
</para>
<para>
If you need access to translated keys for event handling, #GdkEvent
now includes all of the translated key state, including consumed
modifiers, group and shift level, so there should be no need to
do manually call gdk_keymap_translate_keyboard_state() (which has
been removed).
</para>
<para>
If you need to do forward or backward mapping between key codes
and key values, use gdk_display_map_keycode() and gdk_display_map_keyval(),
which is the replacement for gdk_keymap_get_entries_for_keycode()
and gdk_keymap_get_entries_for_keycode().
</para>
</section>
@@ -417,6 +447,54 @@
</para>
</section>
<section>
<title>Adapt to changes in keyboard modifier handling</title>
<para>
GTK 3 has the idea that use of modifiers may differ between different
platforms, and has a #GdkModifierIntent api to let platforms provide
hint about how modifiers are expected to be used. It also promoted
the use of &lt;Primary&gt; instead of &lt;Control&gt; to specify
accelerators that adapt to platform conventions.
</para>
<para>
In GTK 4, the meaning of modifiers has been fixed, and backends are
expected to map the platform conventions to the existing modifiers.
The expected use of modifiers in GTK 4 is:
<simplelist>
<member>GDK_CONTROL_MASK - Primary accelerators</member>
<member>GDK_ALT_MASK - Mnemonics</member>
<member>GDK_SHIFT_MASK - Extending selections</member>
<member>GDK_CONTROL_MASK - Modifying selections</member>
<member>GDK_CONTROL_MASK|GDK_ALT_MASK - Prevent text input</member>
</simplelist>
</para>
<para>
Consequently, #GdkModifierIntent and related APIs have been removed,
and &lt;Control&gt; is preferred over &lt;Primary&gt; in accelerators.
</para>
<para>
A related change is that GTK 4 no longer supports the use of archaic
X11 'real' modifiers with the names Mod1,..., Mod5, and %GDK_MOD1_MASK
has been renamed to %GDK_ALT_MASK.
</para>
</section>
<section>
<title>Focus handling changes</title>
<para>
The semantics of the #GtkWidget:can-focus property have changed.
In GTK 3, this property only meant that the widget itself would not
accept keyboard input, but its children still might (in the case of
containers). In GTK 4, if :can-focus is %FALSE, the focus cannot enter
the widget or any of its descendents, and the default value has changed
from %FALSE to %TRUE.
</para>
<para>
The recommended way to influence focus behavior of custom widgets
in GTK 4 is to override the focus() and grab_focus() vfuncs.
</para>
</section>
<section>
<title>Stop using GtkEventBox</title>
<para>
@@ -808,15 +886,6 @@
</para>
</section>
<section>
<title>Stop using tabular menus</title>
<para>
Tabular menus were rarely used and complicated the menu code,
so they have been removed. If you need complex layout in menu-like
popups, consider using a #GtkPopover instead.
</para>
</section>
<section>
<title>Stop using gtk_menu_set_display()</title>
<para>
@@ -943,6 +1012,13 @@
can only be constructed from menu models, so the porting effort involves
switching to menu models and actions.
</para>
<para>
Tabular menus were rarely used and complicated the menu code,
so they have not been brought over to #GtkPopoverMenu. If you need
complex layout in menu-like popups, consider directly using a
#GtkPopover instead.
</para>
<para>
Since menus are gone, GtkMenuButton also lost its ability to show menus,
and needs to be used with popovers in GTK 4.
+2 -8
View File
@@ -281,26 +281,20 @@ create_accel_label (void)
{
WidgetInfo *info;
GtkWidget *widget, *button, *box;
GtkAccelGroup *accel_group;
widget = gtk_accel_label_new ("Accel Label");
button = gtk_button_new_with_label ("Quit");
gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (widget), button);
gtk_widget_hide (button);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (box), widget);
gtk_container_add (GTK_CONTAINER (box), button);
gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (widget), button);
accel_group = gtk_accel_group_new();
gtk_accel_label_set_accel (GTK_ACCEL_LABEL (widget), GDK_KEY_Q, GDK_CONTROL_MASK);
info = new_widget_info ("accel-label", box, SMALL);
gtk_widget_add_accelerator (button, "activate", accel_group, GDK_KEY_Q, GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
return info;
}
@@ -1232,7 +1226,7 @@ create_sidebar (void)
stack = gtk_stack_new ();
gtk_widget_set_size_request (stack, 120, 120);
view = gtk_label_new ("Sidebar");
gtk_style_context_add_class (gtk_widget_get_style_context (view), "view");
gtk_widget_add_css_class (view, "view");
gtk_widget_set_halign (view, GTK_ALIGN_FILL);
gtk_widget_set_valign (view, GTK_ALIGN_FILL);
gtk_widget_show (view);
+8 -8
View File
@@ -517,13 +517,13 @@ bloat_pad_startup (GApplication *application)
const gchar *action_and_target;
const gchar *accelerators[2];
} accels[] = {
{ "app.new", { "<Primary>n", NULL } },
{ "app.quit", { "<Primary>q", NULL } },
{ "win.copy", { "<Primary>c", NULL } },
{ "win.paste", { "<Primary>p", NULL } },
{ "win.justify::left", { "<Primary>l", NULL } },
{ "win.justify::center", { "<Primary>m", NULL } },
{ "win.justify::right", { "<Primary>r", NULL } }
{ "app.new", { "<Control>n", NULL } },
{ "app.quit", { "<Control>q", NULL } },
{ "win.copy", { "<Control>c", NULL } },
{ "win.paste", { "<Control>p", NULL } },
{ "win.justify::left", { "<Control>l", NULL } },
{ "win.justify::center", { "<Control>m", NULL } },
{ "win.justify::right", { "<Control>r", NULL } }
};
G_APPLICATION_CLASS (bloat_pad_parent_class)
@@ -592,7 +592,7 @@ bloat_pad_startup (GApplication *application)
g_object_unref (item);
g_object_unref (icon);
const gchar *new_accels[] = { "<Primary>n", "<Primary>t", NULL };
const gchar *new_accels[] = { "<Control>n", "<Control>t", NULL };
gtk_application_set_accels_for_action (GTK_APPLICATION (application), "app.new", new_accels);
dump_accels (GTK_APPLICATION (application));
+1
View File
@@ -7,6 +7,7 @@
#include <glib.h>
#include <glib/gprintf.h>
#include "gdktypes.h"
#include "gdkinternals.h"
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+4 -9
View File
@@ -75,14 +75,10 @@ const GDK_CROSSING_GRAB = 1;
const GDK_CROSSING_UNGRAB = 2;
// GdkModifierType
const GDK_SHIFT_MASK = 1 << 0;
const GDK_SHIFT_MASK = 1 << 0;
const GDK_LOCK_MASK = 1 << 1;
const GDK_CONTROL_MASK = 1 << 2;
const GDK_MOD1_MASK = 1 << 3;
const GDK_MOD2_MASK = 1 << 4;
const GDK_MOD3_MASK = 1 << 5;
const GDK_MOD4_MASK = 1 << 6;
const GDK_MOD5_MASK = 1 << 7;
const GDK_ALT_MASK = 1 << 3;
const GDK_BUTTON1_MASK = 1 << 8;
const GDK_BUTTON2_MASK = 1 << 9;
const GDK_BUTTON3_MASK = 1 << 10;
@@ -91,7 +87,6 @@ const GDK_BUTTON5_MASK = 1 << 12;
const GDK_SUPER_MASK = 1 << 26;
const GDK_HYPER_MASK = 1 << 27;
const GDK_META_MASK = 1 << 28;
const GDK_RELEASE_MASK = 1 << 30;
var useDataUrls = window.location.search.includes("datauri");
@@ -1384,13 +1379,13 @@ function updateKeyboardStatus() {
}
function updateForEvent(ev) {
lastState &= ~(GDK_SHIFT_MASK|GDK_CONTROL_MASK|GDK_MOD1_MASK);
lastState &= ~(GDK_SHIFT_MASK|GDK_CONTROL_MASK|GDK_ALT_MASK);
if (ev.shiftKey)
lastState |= GDK_SHIFT_MASK;
if (ev.ctrlKey)
lastState |= GDK_CONTROL_MASK;
if (ev.altKey)
lastState |= GDK_MOD1_MASK;
lastState |= GDK_ALT_MASK;
lastTimeStamp = ev.timeStamp;
}
+1
View File
@@ -3,6 +3,7 @@
#include <gdk/gdktypes.h>
#include "broadway-protocol.h"
#include "gdkinternals.h"
typedef struct _GdkBroadwayServer GdkBroadwayServer;
typedef struct _GdkBroadwayServerClass GdkBroadwayServerClass;
+9 -5
View File
@@ -266,6 +266,11 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
GINT_TO_POINTER (message->key.surface_id));
if (surface)
{
GdkTranslatedKey translated;
translated.keyval = message->key.key;
translated.consumed = 0;
translated.layout = 0;
translated.level = 0;
event = gdk_event_key_new (message->base.type == BROADWAY_EVENT_KEY_PRESS
? GDK_KEY_PRESS
: GDK_KEY_RELEASE,
@@ -273,12 +278,11 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
gdk_seat_get_keyboard (seat),
gdk_seat_get_keyboard (seat),
message->base.time,
message->key.key,
message->key.state,
message->key.key,
message->key.key,
message->key.key,
0,
FALSE);
FALSE,
&translated,
&translated);
node = _gdk_event_queue_append (display, event);
_gdk_windowing_got_event (display, node, event, message->base.serial);
-15
View File
@@ -187,19 +187,6 @@ gdk_broadway_keymap_translate_keyboard_state (GdkKeymap *keymap,
return TRUE;
}
static void
gdk_broadway_keymap_add_virtual_modifiers (GdkKeymap *keymap,
GdkModifierType *state)
{
}
static gboolean
gdk_broadway_keymap_map_virtual_modifiers (GdkKeymap *keymap,
GdkModifierType *state)
{
return TRUE;
}
static void
gdk_broadway_keymap_class_init (GdkBroadwayKeymapClass *klass)
{
@@ -217,7 +204,5 @@ gdk_broadway_keymap_class_init (GdkBroadwayKeymapClass *klass)
keymap_class->get_entries_for_keycode = gdk_broadway_keymap_get_entries_for_keycode;
keymap_class->lookup_key = gdk_broadway_keymap_lookup_key;
keymap_class->translate_keyboard_state = gdk_broadway_keymap_translate_keyboard_state;
keymap_class->add_virtual_modifiers = gdk_broadway_keymap_add_virtual_modifiers;
keymap_class->map_virtual_modifiers = gdk_broadway_keymap_map_virtual_modifiers;
}
+7
View File
@@ -1499,6 +1499,9 @@ gdk_broadway_toplevel_set_property (GObject *object,
case LAST_PROP + GDK_TOPLEVEL_PROP_DELETABLE:
break;
case LAST_PROP + GDK_TOPLEVEL_PROP_SHORTCUTS_INHIBITED:
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1541,6 +1544,10 @@ gdk_broadway_toplevel_get_property (GObject *object,
case LAST_PROP + GDK_TOPLEVEL_PROP_DELETABLE:
break;
case LAST_PROP + GDK_TOPLEVEL_PROP_SHORTCUTS_INHIBITED:
g_value_set_boolean (value, surface->shortcuts_inhibited);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
+30 -8
View File
@@ -1,21 +1,43 @@
#!/usr/bin/env python3
import os
import argparse
import sys
import filecmp
def replace_if_changed(new, old):
'''
Compare contents and only replace if changed to avoid triggering a rebuild.
'''
try:
changed = not filecmp.cmp(new, old, shallow=False)
except FileNotFoundError:
changed = True
if changed:
os.replace(new, old)
else:
os.remove(new)
parser = argparse.ArgumentParser()
parser.add_argument('--array-name', help='The name of the array variable')
parser.add_argument('--output', metavar='FILE', help='Output file',
type=argparse.FileType('w'),
default=sys.stdout)
parser.add_argument('--output', metavar='STRING', help='Output filename',
default=None)
parser.add_argument('input', metavar='FILE', help='The input file',
type=argparse.FileType('r'))
args = parser.parse_args()
args.output.write('static const char {}[] = {{\n'.format(args.array_name))
for line in args.input:
for ch in line:
args.output.write(' 0x{:02x},\n'.format(ord(ch)))
if args.output is None:
output = sys.stdout
else:
output = args.output + '~'
args.output.write('};')
with open(output, 'w') as f:
f.write('static const char {}[] = {{\n'.format(args.array_name))
for line in args.input:
for ch in line:
f.write(' 0x{:02x},\n'.format(ord(ch)))
f.write('};')
if args.output is not None:
replace_if_changed(output, args.output)
+1 -1
View File
@@ -67,7 +67,7 @@ libgdk_broadway = static_library('gdk-broadway',
broadwayd_syslib = os_win32 ? find_library('ws2_32') : shmlib
executable('gtk4-broadwayd',
clienthtml_h, broadwayjs_h,
clienthtml_h, broadwayjs_h, gdkconfig, gdkenum_h,
'broadwayd.c', 'broadway-server.c', 'broadway-output.c',
include_directories: [confinc, gdkinc, include_directories('.')],
c_args: ['-DGTK_COMPILATION', '-DG_LOG_DOMAIN="Gdk"', ],
-1
View File
@@ -32,7 +32,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDrag, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkDrawContext, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkFrameClock, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkGLContext, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkKeymap, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkMonitor, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkSeat, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkPopupLayout, gdk_popup_layout_unref)
+133
View File
@@ -24,6 +24,7 @@
#include "gdkdisplayprivate.h"
#include "gdkinternals.h"
#include "gdkintl.h"
#include "gdkkeysprivate.h"
/* for the use of round() */
#include "fallback-c89.c"
@@ -101,6 +102,12 @@ enum {
PROP_NUM_TOUCHES,
PROP_AXES,
PROP_TOOL,
PROP_DIRECTION,
PROP_HAS_BIDI_LAYOUTS,
PROP_CAPS_LOCK_STATE,
PROP_NUM_LOCK_STATE,
PROP_SCROLL_LOCK_STATE,
PROP_MODIFIER_STATE,
LAST_PROP
};
@@ -281,6 +288,48 @@ gdk_device_class_init (GdkDeviceClass *klass)
GDK_TYPE_DEVICE_TOOL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
device_props[PROP_DIRECTION] =
g_param_spec_enum ("direction",
P_("Direction"),
P_("The direction of the current layout of the keyboard"),
PANGO_TYPE_DIRECTION, PANGO_DIRECTION_NEUTRAL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
device_props[PROP_HAS_BIDI_LAYOUTS] =
g_param_spec_boolean ("has-bidi-layouts",
P_("Has bidi layouts"),
P_("Whether the keyboard has bidi layouts"),
FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
device_props[PROP_CAPS_LOCK_STATE] =
g_param_spec_boolean ("caps-lock-state",
P_("Caps lock state"),
P_("Whether the keyboard caps lock is on"),
FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
device_props[PROP_NUM_LOCK_STATE] =
g_param_spec_boolean ("num-lock-state",
P_("Num lock state"),
P_("Whether the keyboard num lock is on"),
FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
device_props[PROP_SCROLL_LOCK_STATE] =
g_param_spec_boolean ("scroll-lock-state",
P_("Scroll lock state"),
P_("Whether the keyboard scroll lock is on"),
FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
device_props[PROP_MODIFIER_STATE] =
g_param_spec_flags ("modifier-state",
P_("Modifier state"),
P_("The modifier state of the keyboard"),
GDK_TYPE_MODIFIER_TYPE, 0,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, LAST_PROP, device_props);
/**
@@ -473,6 +522,24 @@ gdk_device_get_property (GObject *object,
case PROP_TOOL:
g_value_set_object (value, device->last_tool);
break;
case PROP_DIRECTION:
g_value_set_enum (value, gdk_device_get_direction (device));
break;
case PROP_HAS_BIDI_LAYOUTS:
g_value_set_boolean (value, gdk_device_has_bidi_layouts (device));
break;
case PROP_CAPS_LOCK_STATE:
g_value_set_boolean (value, gdk_device_get_caps_lock_state (device));
break;
case PROP_NUM_LOCK_STATE:
g_value_set_boolean (value, gdk_device_get_num_lock_state (device));
break;
case PROP_SCROLL_LOCK_STATE:
g_value_set_boolean (value, gdk_device_get_scroll_lock_state (device));
break;
case PROP_MODIFIER_STATE:
g_value_set_flags (value, gdk_device_get_modifier_state (device));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1712,3 +1779,69 @@ gdk_device_get_device_tool (GdkDevice *device)
return device->last_tool;
}
gboolean
gdk_device_get_caps_lock_state (GdkDevice *device)
{
GdkKeymap *keymap = gdk_display_get_keymap (device->display);
if (device->source == GDK_SOURCE_KEYBOARD)
return gdk_keymap_get_caps_lock_state (keymap);
return FALSE;
}
gboolean
gdk_device_get_num_lock_state (GdkDevice *device)
{
GdkKeymap *keymap = gdk_display_get_keymap (device->display);
if (device->source == GDK_SOURCE_KEYBOARD)
return gdk_keymap_get_num_lock_state (keymap);
return FALSE;
}
gboolean
gdk_device_get_scroll_lock_state (GdkDevice *device)
{
GdkKeymap *keymap = gdk_display_get_keymap (device->display);
if (device->source == GDK_SOURCE_KEYBOARD)
return gdk_keymap_get_scroll_lock_state (keymap);
return FALSE;
}
GdkModifierType
gdk_device_get_modifier_state (GdkDevice *device)
{
GdkKeymap *keymap = gdk_display_get_keymap (device->display);
if (device->source == GDK_SOURCE_KEYBOARD)
return gdk_keymap_get_modifier_state (keymap);
return 0;
}
PangoDirection
gdk_device_get_direction (GdkDevice *device)
{
GdkKeymap *keymap = gdk_display_get_keymap (device->display);
if (device->source == GDK_SOURCE_KEYBOARD)
return gdk_keymap_get_direction (keymap);
return PANGO_DIRECTION_NEUTRAL;
}
gboolean
gdk_device_has_bidi_layouts (GdkDevice *device)
{
GdkKeymap *keymap = gdk_display_get_keymap (device->display);
if (device->source == GDK_SOURCE_KEYBOARD)
return gdk_keymap_have_bidi_layouts (keymap);
return FALSE;
}
+18
View File
@@ -203,6 +203,24 @@ guint gdk_device_get_num_touches (GdkDevice *device);
GDK_AVAILABLE_IN_ALL
GdkDeviceTool * gdk_device_get_device_tool (GdkDevice *device);
GDK_AVAILABLE_IN_ALL
gboolean gdk_device_get_caps_lock_state (GdkDevice *device);
GDK_AVAILABLE_IN_ALL
gboolean gdk_device_get_num_lock_state (GdkDevice *device);
GDK_AVAILABLE_IN_ALL
gboolean gdk_device_get_scroll_lock_state (GdkDevice *device);
GDK_AVAILABLE_IN_ALL
GdkModifierType gdk_device_get_modifier_state (GdkDevice *device);
GDK_AVAILABLE_IN_ALL
PangoDirection gdk_device_get_direction (GdkDevice *device);
GDK_AVAILABLE_IN_ALL
gboolean gdk_device_has_bidi_layouts (GdkDevice *device);
G_END_DECLS
#endif /* __GDK_DEVICE_H__ */
+1
View File
@@ -22,6 +22,7 @@
#include "gdkdevicetool.h"
#include "gdkevents.h"
#include "gdkseat.h"
#include "gdkinternals.h"
G_BEGIN_DECLS
+72
View File
@@ -1711,3 +1711,75 @@ gdk_display_set_cursor_theme (GdkDisplay *display,
if (GDK_DISPLAY_GET_CLASS (display)->set_cursor_theme)
GDK_DISPLAY_GET_CLASS (display)->set_cursor_theme (display, name, size);
}
/**
* gdk_display_map_keyval:
* @display: a #GdkDisplay
* @keyval: a keyval, such as %GDK_KEY_a, %GDK_KEY_Up, %GDK_KEY_Return, etc.
* @keys: (out) (array length=n_keys) (transfer full): return location
* for an array of #GdkKeymapKey
* @n_keys: return location for number of elements in returned array
*
* Obtains a list of keycode/group/level combinations that will
* generate @keyval. Groups and levels are two kinds of keyboard mode;
* in general, the level determines whether the top or bottom symbol
* on a key is used, and the group determines whether the left or
* right symbol is used.
*
* On US keyboards, the shift key changes the keyboard level, and there
* are no groups. A group switch key might convert a keyboard between
* Hebrew to English modes, for example.
*
* #GdkEventKey contains a %group field that indicates the active
* keyboard group. The level is computed from the modifier mask.
*
* The returned array should be freed with g_free().
*
* Returns: %TRUE if keys were found and returned
*/
gboolean
gdk_display_map_keyval (GdkDisplay *display,
guint keyval,
GdkKeymapKey **keys,
int *n_keys)
{
return gdk_keymap_get_entries_for_keyval (gdk_display_get_keymap (display),
keyval,
keys,
n_keys);
}
/**
* gdk_display_map_keycode:
* @display: a #GdkDisplay
* @keycode: a keycode
* @keys: (out) (array length=n_entries) (transfer full) (optional): return
* location for array of #GdkKeymapKey, or %NULL
* @keyvals: (out) (array length=n_entries) (transfer full) (optional): return
* location for array of keyvals, or %NULL
* @n_entries: length of @keys and @keyvals
*
* Returns the keyvals bound to @keycode. The Nth #GdkKeymapKey
* in @keys is bound to the Nth keyval in @keyvals.
*
* When a keycode is pressed by the user, the keyval from
* this list of entries is selected by considering the effective
* keyboard group and level.
*
* Free the returned arrays with g_free().
*
* Returns: %TRUE if there were any entries
*/
gboolean
gdk_display_map_keycode (GdkDisplay *display,
guint keycode,
GdkKeymapKey **keys,
guint **keyvals,
int *n_entries)
{
return gdk_keymap_get_entries_for_keycode (gdk_display_get_keymap (display),
keycode,
keys,
keyvals,
n_entries);
}
+11 -1
View File
@@ -116,7 +116,17 @@ GdkMonitor * gdk_display_get_monitor_at_surface (GdkDisplay *display,
GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
GdkKeymap * gdk_display_get_keymap (GdkDisplay *display);
gboolean gdk_display_map_keyval (GdkDisplay *display,
guint keyval,
GdkKeymapKey **keys,
int *n_keys);
GDK_AVAILABLE_IN_ALL
gboolean gdk_display_map_keycode (GdkDisplay *display,
guint keycode,
GdkKeymapKey **keys,
guint **keyvals,
int *n_entries);
GDK_AVAILABLE_IN_ALL
gboolean gdk_display_get_setting (GdkDisplay *display,
+1 -1
View File
@@ -34,7 +34,7 @@ GDK_AVAILABLE_IN_ALL
G_DECLARE_INTERFACE (GdkDragSurface, gdk_drag_surface, GDK, DRAG_SURFACE, GObject)
GDK_AVAILABLE_IN_ALL
gboolean gdk_drag_surface_present (GdkDragSurface *drag_icon,
gboolean gdk_drag_surface_present (GdkDragSurface *drag_surface,
int width,
int height);
+205 -44
View File
@@ -30,6 +30,7 @@
#include "gdkdisplayprivate.h"
#include "gdkdragprivate.h"
#include "gdkdropprivate.h"
#include "gdkkeysprivate.h"
#include "gdk-private.h"
#include <string.h>
@@ -551,10 +552,7 @@ gdk_event_get_axis (GdkEvent *event,
*
* This function returns whether a #GdkEventButton should trigger a
* context menu, according to platform conventions. The right mouse
* button always triggers context menus. Additionally, if
* gdk_keymap_get_modifier_mask() returns a non-0 mask for
* %GDK_MODIFIER_INTENT_CONTEXT_MENU, then the left mouse button will
* also trigger a context menu if this modifier is pressed.
* button always triggers context menus.
*
* This function should always be used instead of simply checking for
* event->button == %GDK_BUTTON_SECONDARY.
@@ -569,25 +567,12 @@ gdk_event_triggers_context_menu (GdkEvent *event)
if (event->any.type == GDK_BUTTON_PRESS)
{
GdkEventButton *bevent = (GdkEventButton *) event;
GdkDisplay *display;
GdkModifierType modifier;
g_return_val_if_fail (GDK_IS_SURFACE (bevent->any.surface), FALSE);
if (bevent->button == GDK_BUTTON_SECONDARY &&
! (bevent->state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK)))
return TRUE;
display = gdk_surface_get_display (bevent->any.surface);
modifier = gdk_keymap_get_modifier_mask (gdk_display_get_keymap (display),
GDK_MODIFIER_INTENT_CONTEXT_MENU);
if (modifier != 0 &&
bevent->button == GDK_BUTTON_PRIMARY &&
! (bevent->state & (GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) &&
(bevent->state & modifier))
return TRUE;
}
return FALSE;
@@ -931,17 +916,16 @@ gdk_event_proximity_new (GdkEventType type,
}
GdkEvent *
gdk_event_key_new (GdkEventType type,
GdkSurface *surface,
GdkDevice *device,
GdkDevice *source_device,
guint32 time,
GdkModifierType state,
guint keyval,
guint16 keycode,
guint16 scancode,
guint8 group,
gboolean is_modifier)
gdk_event_key_new (GdkEventType type,
GdkSurface *surface,
GdkDevice *device,
GdkDevice *source_device,
guint32 time,
guint keycode,
GdkModifierType state,
gboolean is_modifier,
GdkTranslatedKey *translated,
GdkTranslatedKey *no_lock)
{
GdkEventKey *event;
@@ -956,12 +940,11 @@ gdk_event_key_new (GdkEventType type,
event->any.surface = g_object_ref (surface);
event->any.device = g_object_ref (device);
event->any.source_device = g_object_ref (source_device);
event->keycode = keycode;
event->state = state;
event->keyval = keyval;
event->hardware_keycode = keycode;
event->key_scancode = scancode;
event->group = group;
event->any.key_is_modifier = is_modifier;
event->translated[0] = *translated;
event->translated[1] = *no_lock;
return (GdkEvent *)event;
}
@@ -1669,7 +1652,7 @@ gdk_key_event_get_keyval (GdkEvent *event)
g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
event->any.type == GDK_KEY_RELEASE, 0);
return event->key.keyval;
return event->key.translated[0].keyval;
}
/**
@@ -1686,41 +1669,58 @@ gdk_key_event_get_keycode (GdkEvent *event)
g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
event->any.type == GDK_KEY_RELEASE, 0);
return event->key.hardware_keycode;
return event->key.keycode;
}
/**
* gdk_key_event_get_scancode:
* gdk_key_event_get_level:
* @event: a key event
*
* Extracts the scancode from a key event.
* Extracts the shift level from a key event.
*
* Returns: the scancode of @event
* Returns: the shift level of @event
*/
guint
gdk_key_event_get_scancode (GdkEvent *event)
gdk_key_event_get_level (GdkEvent *event)
{
g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
event->any.type == GDK_KEY_RELEASE, 0);
return event->key.key_scancode;
return event->key.translated[0].level;
}
/**
* gdk_key_event_get_group:
* gdk_key_event_get_layout:
* @event: a key event
*
* Extracts the group from a key event.
* Extracts the layout from a key event.
*
* Returns: the group of @event
* Returns: the layout of @event
*/
guint
gdk_key_event_get_group (GdkEvent *event)
gdk_key_event_get_layout (GdkEvent *event)
{
g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
event->any.type == GDK_KEY_RELEASE, 0);
return event->key.group;
return event->key.translated[0].layout;
}
/**
* gdk_key_event_get_consumed_modifiers:
* @event: a key event
*
* Extracts the consumed modifiers from a key event.
*
* Returns: the consumed modifiers or @event
*/
GdkModifierType
gdk_key_event_get_consumed_modifiers (GdkEvent *event)
{
g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
event->any.type == GDK_KEY_RELEASE, 0);
return event->key.translated[0].consumed;
}
/**
@@ -2110,3 +2110,164 @@ gdk_grab_broken_event_get_grab_surface (GdkEvent *event)
return event->grab_broken.grab_surface;
}
/**
* gdk_key_event_matches:
* @event: a key #GdkEvent
* @keyval: the keyval to match
* @modifiers: the modifiers to match
*
* Matches a key event against a keyboard shortcut that is specified
* as a keyval and modifiers. Partial matches are possible where the
* combination matches if the currently active group is ignored.
*
* Note that we ignore Caps Lock for matching.
*
* Returns: a GdkKeyMatch value describing whether @event matches
*/
GdkKeyMatch
gdk_key_event_matches (GdkEvent *event,
guint keyval,
GdkModifierType modifiers)
{
guint keycode;
GdkModifierType state;
GdkModifierType mask;
guint ev_keyval;
int layout;
int level;
GdkModifierType consumed_modifiers;
GdkModifierType shift_group_mask;
gboolean group_mod_is_accel_mod = FALSE;
g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
event->any.type == GDK_KEY_RELEASE, GDK_KEY_MATCH_NONE);
keycode = event->key.keycode;
state = event->key.state & ~GDK_LOCK_MASK;
ev_keyval = event->key.translated[1].keyval;
layout = event->key.translated[1].layout;
level = event->key.translated[1].level;
consumed_modifiers = event->key.translated[1].consumed;
mask = GDK_CONTROL_MASK|GDK_SHIFT_MASK|GDK_ALT_MASK|
GDK_SUPER_MASK|GDK_HYPER_MASK|GDK_META_MASK;
/* if the group-toggling modifier is part of the default accel mod
* mask, and it is active, disable it for matching
*
* FIXME: get shift group mask from backends
*/
shift_group_mask = 0;
if (mask & shift_group_mask)
group_mod_is_accel_mod = TRUE;
if ((modifiers & ~consumed_modifiers & mask) == (state & ~consumed_modifiers & mask))
{
/* modifier match */
GdkKeymapKey *keys;
int n_keys;
int i;
guint key;
/* Shift gets consumed and applied for the event,
* so apply it to our keyval to match
*/
key = keyval;
if (modifiers & GDK_SHIFT_MASK)
{
if (key == GDK_KEY_Tab)
key = GDK_KEY_ISO_Left_Tab;
else
key = gdk_keyval_to_upper (key);
}
if (ev_keyval == key && /* exact match */
(!group_mod_is_accel_mod ||
(state & shift_group_mask) == (modifiers & shift_group_mask)))
{
return GDK_KEY_MATCH_EXACT;
}
gdk_display_map_keyval (gdk_event_get_display (event), keyval, &keys, &n_keys);
for (i = 0; i < n_keys; i++)
{
if (keys[i].keycode == keycode &&
keys[i].level == level &&
/* Only match for group if it's an accel mod */
(!group_mod_is_accel_mod || keys[i].group == layout))
{
/* partial match */
g_free (keys);
return GDK_KEY_MATCH_PARTIAL;
}
}
g_free (keys);
}
return GDK_KEY_MATCH_NONE;
}
/**
* gdk_key_event_get_match:
* @event: a key #GdkEvent
* @keyval: (out): return location for a keyval
* @modifiers: (out): return location for modifiers
*
* Gets a keyval and modifier combination that will cause
* gdk_event_match() to successfully match the given event.
*
* Returns: %TRUE on success
*/
gboolean
gdk_key_event_get_match (GdkEvent *event,
guint *keyval,
GdkModifierType *modifiers)
{
GdkModifierType mask;
guint key;
guint accel_key;
GdkModifierType accel_mods;
GdkModifierType consumed_modifiers;
g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
event->any.type == GDK_KEY_RELEASE, FALSE);
mask = GDK_CONTROL_MASK|GDK_SHIFT_MASK|GDK_ALT_MASK|
GDK_SUPER_MASK|GDK_HYPER_MASK|GDK_META_MASK;
accel_key = event->key.translated[1].keyval;
accel_mods = event->key.state;
consumed_modifiers = event->key.translated[1].consumed;
if (accel_key == GDK_KEY_Sys_Req &&
(accel_mods & GDK_ALT_MASK) != 0)
{
/* HACK: we don't want to use SysRq as a keybinding (but we do
* want Alt+Print), so we avoid translation from Alt+Print to SysRq
*/
*keyval = GDK_KEY_Print;
*modifiers = accel_mods & mask;
return TRUE;
}
key = gdk_keyval_to_lower (accel_key);
if (key == GDK_KEY_ISO_Left_Tab)
key = GDK_KEY_Tab;
accel_mods &= mask & ~consumed_modifiers;
if (accel_key != key)
accel_mods |= GDK_SHIFT_MASK;
*keyval = key;
*modifiers = accel_mods;
return TRUE;
}
+30 -2
View File
@@ -363,9 +363,11 @@ guint gdk_key_event_get_keyval (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
guint gdk_key_event_get_keycode (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
guint gdk_key_event_get_scancode (GdkEvent *event);
GdkModifierType gdk_key_event_get_consumed_modifiers (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
guint gdk_key_event_get_group (GdkEvent *event);
guint gdk_key_event_get_layout (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
guint gdk_key_event_get_level (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
gboolean gdk_key_event_is_modifier (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
@@ -428,6 +430,32 @@ gboolean gdk_events_get_center (GdkEvent *event1,
double *x,
double *y);
/**
* GdkKeyMatch:
* @GDK_KEY_MATCH_NONE: The key event does not match
* @GDK_KEY_MATCH_PARTIAL: The key event matches if keyboard state
* (specifically, the currently active group) is ignored
* @GDK_KEY_MATCH_EXACT: The key event matches
*
* The possible return values from gdk_key_event_matches()
* describe how well an event matches a given keyval and modifiers.
*/
typedef enum {
GDK_KEY_MATCH_NONE,
GDK_KEY_MATCH_PARTIAL,
GDK_KEY_MATCH_EXACT
} GdkKeyMatch;
GDK_AVAILABLE_IN_ALL
GdkKeyMatch gdk_key_event_matches (GdkEvent *event,
guint keyval,
GdkModifierType modifiers);
GDK_AVAILABLE_IN_ALL
gboolean gdk_key_event_get_match (GdkEvent *event,
guint *keyval,
GdkModifierType *modifiers);
G_END_DECLS
#endif /* __GDK_EVENTS_H__ */
+22 -22
View File
@@ -223,6 +223,13 @@ struct _GdkEventScroll
GdkDeviceTool *tool;
};
typedef struct {
guint keyval;
GdkModifierType consumed;
guint layout;
guint level;
} GdkTranslatedKey;
/*
* GdkEventKey:
* @type: the type of the event (%GDK_KEY_PRESS or %GDK_KEY_RELEASE).
@@ -232,13 +239,9 @@ struct _GdkEventScroll
* @state: (type GdkModifierType): a bit-mask representing the state of
* the modifier keys (e.g. Control, Shift and Alt) and the pointer
* buttons. See #GdkModifierType.
* @keyval: the key that was pressed or released. See the
* `gdk/gdkkeysyms.h` header file for a
* complete list of GDK key codes.
* @hardware_keycode: the raw code of the key that was pressed or released.
* @group: the keyboard group.
* @is_modifier: a flag that indicates if @hardware_keycode is mapped to a
* modifier
* @keycode: the raw code of the key that was pressed or released.
* @translated: the result of translating @keycode. First with the full
* @state, then while ignoring Caps Lock.
*
* Describes a key press or key release event.
*/
@@ -246,10 +249,8 @@ struct _GdkEventKey
{
GdkEventAny any;
GdkModifierType state;
guint keyval;
guint16 hardware_keycode;
guint16 key_scancode;
guint8 group;
guint32 keycode;
GdkTranslatedKey translated[2];
};
/*
@@ -594,17 +595,16 @@ GdkEvent * gdk_event_proximity_new (GdkEventType type,
GdkDeviceTool *tool,
guint32 time);
GdkEvent * gdk_event_key_new (GdkEventType type,
GdkSurface *surface,
GdkDevice *device,
GdkDevice *source_device,
guint32 time,
GdkModifierType state,
guint keyval,
guint16 keycode,
guint16 scancode,
guint8 group,
gboolean is_modifier);
GdkEvent * gdk_event_key_new (GdkEventType type,
GdkSurface *surface,
GdkDevice *device,
GdkDevice *source_device,
guint32 time,
guint keycode,
GdkModifierType modifiers,
gboolean is_modifier,
GdkTranslatedKey *translated,
GdkTranslatedKey *no_lock);
GdkEvent * gdk_event_focus_new (GdkSurface *surface,
GdkDevice *device,
+43
View File
@@ -33,6 +33,7 @@
#include "gdksurfaceprivate.h"
#include "gdkenumtypes.h"
#include "gdkdragprivate.h"
#include "gdkkeysprivate.h"
G_BEGIN_DECLS
@@ -181,6 +182,8 @@ void gdk_surface_get_unscaled_size (GdkSurface *surface,
int *unscaled_width,
int *unscaled_height);
gboolean gdk_surface_handle_event (GdkEvent *event);
GdkSeat * gdk_surface_get_seat_from_event (GdkSurface *surface,
GdkEvent *event);
/*****************************************
* Interfaces provided by windowing code *
@@ -222,6 +225,45 @@ void gdk_synthesize_surface_state (GdkSurface *surface,
GdkSurfaceState unset_flags,
GdkSurfaceState set_flags);
/**
* GdkGrabStatus:
* @GDK_GRAB_SUCCESS: the resource was successfully grabbed.
* @GDK_GRAB_ALREADY_GRABBED: the resource is actively grabbed by another client.
* @GDK_GRAB_INVALID_TIME: the resource was grabbed more recently than the
* specified time.
* @GDK_GRAB_NOT_VIEWABLE: the grab surface or the @confine_to surface 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() to indicate success or the reason for the
* failure of the grab attempt.
*/
typedef enum
{
GDK_GRAB_SUCCESS = 0,
GDK_GRAB_ALREADY_GRABBED = 1,
GDK_GRAB_INVALID_TIME = 2,
GDK_GRAB_NOT_VIEWABLE = 3,
GDK_GRAB_FROZEN = 4,
GDK_GRAB_FAILED = 5
} GdkGrabStatus;
/**
* GdkGrabOwnership:
* @GDK_OWNERSHIP_NONE: All other devices events are allowed.
* @GDK_OWNERSHIP_SURFACE: Other devices events are blocked for the grab surface.
* @GDK_OWNERSHIP_APPLICATION: Other devices events are blocked for the whole application.
*
* Defines how device grabs interact with other devices.
*/
typedef enum
{
GDK_OWNERSHIP_NONE,
GDK_OWNERSHIP_SURFACE,
GDK_OWNERSHIP_APPLICATION
} GdkGrabOwnership;
GdkGrabStatus gdk_device_grab (GdkDevice *device,
GdkSurface *surface,
GdkGrabOwnership grab_ownership,
@@ -281,6 +323,7 @@ void gdk_seat_ungrab (GdkSeat *seat);
GdkSurface * gdk_surface_new_temp (GdkDisplay *display,
const GdkRectangle *position);
GdkKeymap * gdk_display_get_keymap (GdkDisplay *display);
G_END_DECLS
+83 -153
View File
@@ -36,8 +36,9 @@
* @Title: Key Values
*
* Key values are the codes which are sent whenever a key is pressed or released.
* They appear in the #GdkEventKey.keyval field of the #GdkEventKey structure.
* The complete list of key values can be found in the `gdk/gdkkeysyms.h` header file.
* They are included in the data contained in a key press or release #GdkEvent.
* The complete list of key values can be found in the `gdk/gdkkeysyms.h` header
* file.
*
* Key values are regularly updated from the upstream X.org X11 implementation,
* so new values are added regularly. They will be prefixed with GDK_KEY_ rather
@@ -56,43 +57,87 @@
*
* # Groups # {#key-group-explanation}
*
* One #GdkKeymap object exists for each user display. To obtain keymaps for
* a display, use gdk_display_get_keymap(). A keymap is a mapping from
* #GdkKeymapKey to key values. You can think of a #GdkKeymapKey as a
* representation of a symbol printed on a physical keyboard key. That is, it
* contains three pieces of information. First, it contains the hardware keycode;
* this is an identifying number for a physical key. Second, it contains the
* level of the key. The level indicates which symbol on the
* key will be used, in a vertical direction. So on a standard US keyboard, the key
* with the number 1 on it also has the exclamation point (!) character on
* it. The level indicates whether to use the 1 or the ! symbol. The letter
* keys are considered to have a lowercase letter at level 0, and an uppercase
* letter at level 1, though only the uppercase letter is printed. Third, the
* #GdkKeymapKey contains a group; groups are not used on standard US keyboards,
* but are used in many other countries. On a keyboard with groups, there can be 3
* or 4 symbols printed on a single key. The group indicates movement in a
* horizontal direction. Usually groups are used for two different languages. In
* group 0, a key might have two English characters, and in group 1 it might have
* two Hebrew characters. The Hebrew characters will be printed on the key next to
* the English characters.
* At the lowest level, physical keys on the keyboard are represented by
* numeric keycodes, and GDK knows how to translate these keycodes into
* key values according to the configured keyboard layout and the current
* state of the keyboard. In the GDK api, the mapping from keycodes to key
* values is available via gdk_display_map_keycode(), and the reverse mapping
* is available via gdk_display_map_keyval(). The results of these functions
* are returned in #GdkKeymapKey structs.
*
* In order to use a keymap to interpret a key event, its necessary to first
* convert the keyboard state into an effective group and level. This is done via a
* set of rules that varies widely according to type of keyboard and user
* configuration. The function gdk_keymap_translate_keyboard_state() accepts a
* keyboard state -- consisting of hardware keycode pressed, active modifiers, and
* active group -- applies the appropriate rules, and returns the group/level to be
* used to index the keymap, along with the modifiers which did not affect the
* group and level. i.e. it returns unconsumed modifiers. The keyboard group may
* differ from the effective group used for keymap lookups because some keys don't
* have multiple groups - e.g. the Enter key is always in group 0 regardless of
* keyboard state.
* You can think of a #GdkKeymapKey as a representation of a symbol printed on
* a physical keyboard key. That is, it contains three pieces of information.
* First, it contains the hardware keycode; this is an identifying number for
* a physical key. Second, it contains the level of the key. The level indicates
* which symbol on the key will be used, in a vertical direction. So on a standard
* US keyboard, the key with the number 1 on it also has the exclamation point
* (!) character on it. The level indicates whether to use the 1 or the !
* symbol. The letter keys are considered to have a lowercase letter at level 0,
* and an uppercase letter at level 1, though normally only the uppercase letter
* is printed on the key. Third, the #GdkKeymapKey contains a group; groups are
* not used on standard US keyboards, but are used in many other countries. On a
* keyboard with groups, there can be 3 or 4 symbols printed on a single key.
* The group indicates movement in a horizontal direction. Usually groups are
* used for two different languages. In group 0, a key might have two English
* characters, and in group 1 it might have two Hebrew characters. The Hebrew
* characters will be printed on the key next to the English characters.
*
* Note that gdk_keymap_translate_keyboard_state() also returns the keyval, i.e. it
* goes ahead and performs the keymap lookup in addition to telling you which
* effective group/level values were used for the lookup. #GdkEventKey already
* contains this keyval, however, so you dont normally need to call
* gdk_keymap_translate_keyboard_state() just to get the keyval.
* When GDK creates a key event in order to deliver a key press or release,
* it first converts the current keyboard state into an effective group and
* level. This is done via a set of rules that varies widely according to
* type of keyboard and user configuration. The input to this translation
* consists of the hardware keycode pressed, the active modifiers, and the
* active group. It then applies the appropriate rules, and returns the
* group/level to be used to index the keymap, along with the modifiers
* which did not affect the group and level. i.e. it returns unconsumed
* modifiers. The keyboard group may differ from the effective group used
* for lookups because some keys don't have multiple groups - e.g. the Enter
* key is always in group 0 regardless of keyboard state.
*
* The results of the translation, including the keyval, are all included
* in the key event and can be obtained via #GdkEvent getters.
*
* # Consumed modifiers
*
* The @consumed_modifiers in a key event are modifiers that should be masked
* out from @state when comparing this key press to a hot key. For instance,
* on a US keyboard, the `plus` symbol is shifted, so when comparing a key
* press to a `<Control>plus` accelerator `<Shift>` should be masked out.
*
* |[<!-- language="C" -->
* // We want to ignore irrelevant modifiers like ScrollLock
* #define ALL_ACCELS_MASK (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_ALT_MASK)
* state = gdk_event_get_modifier_state (event);
* gdk_keymap_translate_keyboard_state (keymap,
* gdk_key_event_get_keycode (event),
* state,
* gdk_key_event_get_group (event),
* &keyval, NULL, NULL, &consumed);
* if (keyval == GDK_PLUS &&
* (state & ~consumed & ALL_ACCELS_MASK) == GDK_CONTROL_MASK)
* // Control was pressed
* ]|
*
* An older interpretation @consumed_modifiers was that it contained
* all modifiers that might affect the translation of the key;
* this allowed accelerators to be stored with irrelevant consumed
* modifiers, by doing:
* |[<!-- language="C" -->
* // XXX Dont do this XXX
* if (keyval == accel_keyval &&
* (state & ~consumed & ALL_ACCELS_MASK) == (accel_mods & ~consumed))
* // Accelerator was pressed
* ]|
*
* However, this did not work if multi-modifier combinations were
* used in the keymap, since, for instance, `<Control>` would be
* masked out even if only `<Control><Alt>` was used in the keymap.
* To support this usage as well as well as possible, all single
* modifier combinations that could affect the key for any combination
* of modifiers will be returned in @consumed_modifiers; multi-modifier
* combinations are returned only when actually found in @state. When
* you store accelerators, you should always store them with consumed
* modifiers removed. Store `<Control>plus`, not `<Control><Shift>plus`.
*/
enum {
@@ -111,9 +156,6 @@ enum {
static GParamSpec *props[LAST_PROP] = { NULL, };
static guint signals[LAST_SIGNAL] = { 0 };
static GdkModifierType gdk_keymap_real_get_modifier_mask (GdkKeymap *keymap,
GdkModifierIntent intent);
G_DEFINE_TYPE (GdkKeymap, gdk_keymap, G_TYPE_OBJECT)
static void
@@ -161,8 +203,6 @@ gdk_keymap_class_init (GdkKeymapClass *klass)
object_class->get_property = gdk_keymap_get_property;
object_class->set_property = gdk_keymap_set_property;
klass->get_modifier_mask = gdk_keymap_real_get_modifier_mask;
props[PROP_DISPLAY] =
g_param_spec_object ("display",
"Display",
@@ -558,7 +598,7 @@ gdk_keymap_lookup_key (GdkKeymap *keymap,
*
* |[<!-- language="C" -->
* // We want to ignore irrelevant modifiers like ScrollLock
* #define ALL_ACCELS_MASK (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK)
* #define ALL_ACCELS_MASK (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_ALT_MASK)
* state = gdk_event_get_modifier_state (event);
* gdk_keymap_translate_keyboard_state (keymap,
* gdk_key_event_get_keycode (event),
@@ -615,116 +655,6 @@ gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
consumed_modifiers);
}
/**
* gdk_keymap_add_virtual_modifiers:
* @keymap: a #GdkKeymap
* @state: (inout): pointer to the modifier mask to change
*
* Maps the non-virtual modifiers (i.e Mod2, Mod3, ...) which are set
* in @state to the virtual modifiers (i.e. Super, Hyper and Meta) and
* set the corresponding bits in @state.
*
* GDK already does this before delivering key events, but for
* compatibility reasons, it only sets the first virtual modifier
* it finds, whereas this function sets all matching virtual modifiers.
*
* This function is useful when matching key events against
* accelerators.
*/
void
gdk_keymap_add_virtual_modifiers (GdkKeymap *keymap,
GdkModifierType *state)
{
g_return_if_fail (GDK_IS_KEYMAP (keymap));
GDK_KEYMAP_GET_CLASS (keymap)->add_virtual_modifiers (keymap, state);
}
/**
* gdk_keymap_map_virtual_modifiers:
* @keymap: a #GdkKeymap
* @state: (inout): pointer to the modifier state to map
*
* Maps the virtual modifiers (i.e. Super, Hyper and Meta) which
* are set in @state to their non-virtual counterparts (i.e. Mod2,
* Mod3,...) and set the corresponding bits in @state.
*
* This function is useful when matching key events against
* accelerators.
*
* Returns: %FALSE if two virtual modifiers were mapped to the
* same non-virtual modifier. Note that %FALSE is also returned
* if a virtual modifier is mapped to a non-virtual modifier that
* was already set in @state.
*/
gboolean
gdk_keymap_map_virtual_modifiers (GdkKeymap *keymap,
GdkModifierType *state)
{
g_return_val_if_fail (GDK_IS_KEYMAP (keymap), FALSE);
return GDK_KEYMAP_GET_CLASS(keymap)->map_virtual_modifiers (keymap, state);
}
static GdkModifierType
gdk_keymap_real_get_modifier_mask (GdkKeymap *keymap,
GdkModifierIntent intent)
{
switch (intent)
{
case GDK_MODIFIER_INTENT_PRIMARY_ACCELERATOR:
return GDK_CONTROL_MASK;
case GDK_MODIFIER_INTENT_CONTEXT_MENU:
return 0;
case GDK_MODIFIER_INTENT_EXTEND_SELECTION:
return GDK_SHIFT_MASK;
case GDK_MODIFIER_INTENT_MODIFY_SELECTION:
return GDK_CONTROL_MASK;
case GDK_MODIFIER_INTENT_NO_TEXT_INPUT:
return GDK_MOD1_MASK | GDK_CONTROL_MASK;
case GDK_MODIFIER_INTENT_SHIFT_GROUP:
return 0;
case GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK:
return (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK |
GDK_SUPER_MASK | GDK_HYPER_MASK | GDK_META_MASK);
default:
g_return_val_if_reached (0);
}
}
/**
* gdk_keymap_get_modifier_mask:
* @keymap: a #GdkKeymap
* @intent: the use case for the modifier mask
*
* Returns the modifier mask the @keymaps windowing system backend
* uses for a particular purpose.
*
* Note that this function always returns real hardware modifiers, not
* virtual ones (e.g. it will return #GDK_MOD1_MASK rather than
* #GDK_META_MASK if the backend maps MOD1 to META), so there are use
* cases where the return value of this function has to be transformed
* by gdk_keymap_add_virtual_modifiers() in order to contain the
* expected result.
*
* Returns: the modifier mask used for @intent.
**/
GdkModifierType
gdk_keymap_get_modifier_mask (GdkKeymap *keymap,
GdkModifierIntent intent)
{
g_return_val_if_fail (GDK_IS_KEYMAP (keymap), 0);
return GDK_KEYMAP_GET_CLASS (keymap)->get_modifier_mask (keymap, intent);
}
#include "gdkkeynames.c"
/**
-98
View File
@@ -34,104 +34,6 @@
G_BEGIN_DECLS
typedef struct _GdkKeymapKey GdkKeymapKey;
/**
* GdkKeymapKey:
* @keycode: the hardware keycode. This is an identifying number for a
* physical key.
* @group: indicates movement in a horizontal direction. Usually groups are used
* for two different languages. In group 0, a key might have two English
* characters, and in group 1 it might have two Hebrew characters. The Hebrew
* characters will be printed on the key next to the English characters.
* @level: indicates which symbol on the key will be used, in a vertical direction.
* So on a standard US keyboard, the key with the number 1 on it also has the
* exclamation point ("!") character on it. The level indicates whether to use
* the 1 or the ! symbol. The letter keys are considered to have a lowercase
* letter at level 0, and an uppercase letter at level 1, though only the
* uppercase letter is printed.
*
* A #GdkKeymapKey is a hardware key that can be mapped to a keyval.
*/
struct _GdkKeymapKey
{
guint keycode;
gint group;
gint level;
};
#define GDK_TYPE_KEYMAP (gdk_keymap_get_type ())
#define GDK_KEYMAP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_KEYMAP, GdkKeymap))
#define GDK_IS_KEYMAP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_KEYMAP))
/**
* GdkKeymap:
*
* A #GdkKeymap defines the translation from keyboard state
* (including a hardware key, a modifier mask, and active keyboard group)
* to a keyval. This translation has two phases. The first phase is
* to determine the effective keyboard group and level for the keyboard
* state; the second phase is to look up the keycode/group/level triplet
* in the keymap and see what keyval it corresponds to.
*/
GDK_AVAILABLE_IN_ALL
GType gdk_keymap_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GdkDisplay * gdk_keymap_get_display (GdkKeymap *keymap);
GDK_AVAILABLE_IN_ALL
guint gdk_keymap_lookup_key (GdkKeymap *keymap,
const GdkKeymapKey *key);
GDK_AVAILABLE_IN_ALL
gboolean gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
guint hardware_keycode,
GdkModifierType state,
gint group,
guint *keyval,
gint *effective_group,
gint *level,
GdkModifierType *consumed_modifiers);
GDK_AVAILABLE_IN_ALL
gboolean gdk_keymap_get_entries_for_keyval (GdkKeymap *keymap,
guint keyval,
GdkKeymapKey **keys,
gint *n_keys);
GDK_AVAILABLE_IN_ALL
gboolean gdk_keymap_get_entries_for_keycode (GdkKeymap *keymap,
guint hardware_keycode,
GdkKeymapKey **keys,
guint **keyvals,
gint *n_entries);
GDK_AVAILABLE_IN_ALL
PangoDirection gdk_keymap_get_direction (GdkKeymap *keymap);
GDK_AVAILABLE_IN_ALL
gboolean gdk_keymap_have_bidi_layouts (GdkKeymap *keymap);
GDK_AVAILABLE_IN_ALL
gboolean gdk_keymap_get_caps_lock_state (GdkKeymap *keymap);
GDK_AVAILABLE_IN_ALL
gboolean gdk_keymap_get_num_lock_state (GdkKeymap *keymap);
GDK_AVAILABLE_IN_ALL
gboolean gdk_keymap_get_scroll_lock_state (GdkKeymap *keymap);
GDK_AVAILABLE_IN_ALL
guint gdk_keymap_get_modifier_state (GdkKeymap *keymap);
GDK_AVAILABLE_IN_ALL
void gdk_keymap_add_virtual_modifiers (GdkKeymap *keymap,
GdkModifierType *state);
GDK_AVAILABLE_IN_ALL
gboolean gdk_keymap_map_virtual_modifiers (GdkKeymap *keymap,
GdkModifierType *state);
GDK_AVAILABLE_IN_ALL
GdkModifierType gdk_keymap_get_modifier_mask (GdkKeymap *keymap,
GdkModifierIntent intent);
/* Key values
*/
GDK_AVAILABLE_IN_ALL
const char *gdk_keyval_name (guint keyval) G_GNUC_CONST;
+35 -6
View File
@@ -22,10 +22,14 @@
G_BEGIN_DECLS
#define GDK_TYPE_KEYMAP (gdk_keymap_get_type ())
#define GDK_KEYMAP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_KEYMAP, GdkKeymap))
#define GDK_IS_KEYMAP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_KEYMAP))
#define GDK_KEYMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_KEYMAP, GdkKeymapClass))
#define GDK_IS_KEYMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_KEYMAP))
#define GDK_KEYMAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_KEYMAP, GdkKeymapClass))
typedef struct _GdkKeymap GdkKeymap;
typedef struct _GdkKeymapClass GdkKeymapClass;
struct _GdkKeymapClass
@@ -56,12 +60,6 @@ struct _GdkKeymapClass
gint *effective_group,
gint *level,
GdkModifierType *consumed_modifiers);
void (* add_virtual_modifiers) (GdkKeymap *keymap,
GdkModifierType *state);
gboolean (* map_virtual_modifiers) (GdkKeymap *keymap,
GdkModifierType *state);
GdkModifierType (*get_modifier_mask) (GdkKeymap *keymap,
GdkModifierIntent intent);
guint (* get_modifier_state) (GdkKeymap *keymap);
@@ -77,6 +75,37 @@ struct _GdkKeymap
GdkDisplay *display;
};
GType gdk_keymap_get_type (void) G_GNUC_CONST;
GdkDisplay * gdk_keymap_get_display (GdkKeymap *keymap);
guint gdk_keymap_lookup_key (GdkKeymap *keymap,
const GdkKeymapKey *key);
gboolean gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
guint hardware_keycode,
GdkModifierType state,
gint group,
guint *keyval,
gint *effective_group,
gint *level,
GdkModifierType *consumed_modifiers);
gboolean gdk_keymap_get_entries_for_keyval (GdkKeymap *keymap,
guint keyval,
GdkKeymapKey **keys,
gint *n_keys);
gboolean gdk_keymap_get_entries_for_keycode (GdkKeymap *keymap,
guint hardware_keycode,
GdkKeymapKey **keys,
guint **keyvals,
gint *n_entries);
PangoDirection gdk_keymap_get_direction (GdkKeymap *keymap);
gboolean gdk_keymap_have_bidi_layouts (GdkKeymap *keymap);
gboolean gdk_keymap_get_caps_lock_state (GdkKeymap *keymap);
gboolean gdk_keymap_get_num_lock_state (GdkKeymap *keymap);
gboolean gdk_keymap_get_scroll_lock_state (GdkKeymap *keymap);
guint gdk_keymap_get_modifier_state (GdkKeymap *keymap);
G_END_DECLS
#endif
+34 -14
View File
@@ -2815,17 +2815,18 @@ rewrite_event_for_toplevel (GdkEvent *event)
gdk_event_get_source_device (event),
gdk_focus_event_get_in (event));
else
return gdk_event_key_new (gdk_event_get_event_type (event),
surface,
gdk_event_get_device (event),
gdk_event_get_source_device (event),
gdk_event_get_time (event),
gdk_event_get_modifier_state (event),
gdk_key_event_get_keyval (event),
gdk_key_event_get_keycode (event),
gdk_key_event_get_scancode (event),
gdk_key_event_get_group (event),
gdk_key_event_is_modifier (event));
{
return gdk_event_key_new (gdk_event_get_event_type (event),
surface,
gdk_event_get_device (event),
gdk_event_get_source_device (event),
gdk_event_get_time (event),
gdk_key_event_get_keycode (event),
gdk_event_get_modifier_state (event),
gdk_key_event_is_modifier (event),
&event->key.translated[0],
&event->key.translated[1]);
}
}
static void
@@ -2874,13 +2875,13 @@ add_event_mark (GdkEvent *event,
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
{
message = g_strdup_printf ("%s {keyval=%u, state=0x%x, hardware_keycode=%u key_scancode=%u group=%u is_modifier=%u}",
message = g_strdup_printf ("%s {keyval=%u, state=0x%x, keycode=%u layout=%u level=%u is_modifier=%u}",
kind,
gdk_key_event_get_keyval (event),
gdk_event_get_modifier_state (event),
gdk_key_event_get_keycode (event),
gdk_key_event_get_scancode (event),
gdk_key_event_get_group (event),
gdk_key_event_get_layout (event),
gdk_key_event_get_level (event),
gdk_key_event_is_modifier (event));
break;
}
@@ -3015,3 +3016,22 @@ gdk_surface_translate_coordinates (GdkSurface *from,
return TRUE;
}
GdkSeat *
gdk_surface_get_seat_from_event (GdkSurface *surface,
GdkEvent *event)
{
if (event)
{
GdkDevice *device = gdk_event_get_device (event);
GdkSeat *seat = NULL;
device = gdk_event_get_device (event);
if (device)
seat = gdk_device_get_seat (device);
if (seat)
return seat;
}
return gdk_display_get_default_seat (surface->display);
}
+3
View File
@@ -102,6 +102,9 @@ struct _GdkSurface
GdkDrawContext *paint_context;
cairo_region_t *opaque_region;
guint shortcuts_inhibited : 1;
GdkSeat *current_shortcuts_inhibited_seat;
};
struct _GdkSurfaceClass
+73
View File
@@ -73,6 +73,17 @@ gdk_toplevel_default_supports_edge_constraints (GdkToplevel *toplevel)
return FALSE;
}
static void
gdk_toplevel_default_inhibit_system_shortcuts (GdkToplevel *toplevel,
GdkEvent *event)
{
}
static void
gdk_toplevel_default_restore_system_shortcuts (GdkToplevel *toplevel)
{
}
static void
gdk_toplevel_default_init (GdkToplevelInterface *iface)
{
@@ -82,6 +93,8 @@ gdk_toplevel_default_init (GdkToplevelInterface *iface)
iface->focus = gdk_toplevel_default_focus;
iface->show_window_menu = gdk_toplevel_default_show_window_menu;
iface->supports_edge_constraints = gdk_toplevel_default_supports_edge_constraints;
iface->inhibit_system_shortcuts = gdk_toplevel_default_inhibit_system_shortcuts;
iface->restore_system_shortcuts = gdk_toplevel_default_restore_system_shortcuts;
g_object_interface_install_property (iface,
g_param_spec_flags ("state",
@@ -137,6 +150,12 @@ gdk_toplevel_default_init (GdkToplevelInterface *iface)
GDK_TYPE_FULLSCREEN_MODE,
GDK_FULLSCREEN_ON_CURRENT_MONITOR,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
g_object_interface_install_property (iface,
g_param_spec_boolean ("shortcuts-inhibited",
"Shortcuts inhibited",
"Whether keyboard shortcuts are inhibited",
FALSE,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY));
}
guint
@@ -152,6 +171,7 @@ gdk_toplevel_install_properties (GObjectClass *object_class,
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_DECORATED, "decorated");
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_DELETABLE, "deletable");
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_FULLSCREEN_MODE, "fullscreen-mode");
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_SHORTCUTS_INHIBITED, "shortcuts-inhibited");
return GDK_TOPLEVEL_NUM_PROPERTIES;
}
@@ -439,3 +459,56 @@ gdk_toplevel_supports_edge_constraints (GdkToplevel *toplevel)
return GDK_TOPLEVEL_GET_IFACE (toplevel)->supports_edge_constraints (toplevel);
}
/**
* gdk_toplevel_inhibit_system_shortcuts:
* @toplevel: the #GdkToplevel requesting system keyboard shortcuts
* @event: (nullable): the #GdkEvent that is triggering the inhibit
* request, or %NULL if none is available.
*
* Requests that the @toplevel inhibit the system shortcuts, asking the
* desktop environment/windowing system to let all keyboard events reach
* the surface, as long as it is focused, instead of triggering system
* actions.
*
* If granted, the rerouting remains active until the default shortcuts
* processing is restored with gdk_toplevel_restore_system_shortcuts(),
* or the request is revoked by the desktop enviroment, windowing system
* or the user.
*
* A typical use case for this API is remote desktop or virtual machine
* viewers which need to inhibit the default system keyboard shortcuts
* so that the remote session or virtual host gets those instead of the
* local environment.
*
* The windowing system or desktop environment may ask the user to grant
* or deny the request or even choose to ignore the request entirely.
*
* The caller can be notified whenever the request is granted or revoked
* by listening to the GdkToplevel::shortcuts-inhibited property.
*
*/
void
gdk_toplevel_inhibit_system_shortcuts (GdkToplevel *toplevel,
GdkEvent *event)
{
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
GDK_TOPLEVEL_GET_IFACE (toplevel)->inhibit_system_shortcuts (toplevel,
event);
}
/**
* gdk_toplevel_restore_system_shortcuts:
* @toplevel: a #GdkToplevel
*
* Restore default system keyboard shortcuts which were previously
* requested to be inhibited by gdk_toplevel_inhibit_system_shortcuts().
*/
void
gdk_toplevel_restore_system_shortcuts (GdkToplevel *toplevel)
{
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
GDK_TOPLEVEL_GET_IFACE (toplevel)->restore_system_shortcuts (toplevel);
}
+9
View File
@@ -24,6 +24,7 @@
#error "Only <gdk/gdk.h> can be included directly."
#endif
#include <gdk/gdkseat.h>
#include <gdk/gdksurface.h>
#include <gdk/gdktoplevellayout.h>
@@ -87,6 +88,14 @@ void gdk_toplevel_set_deletable (GdkToplevel *toplevel,
GDK_AVAILABLE_IN_ALL
gboolean gdk_toplevel_supports_edge_constraints (GdkToplevel *toplevel);
GDK_AVAILABLE_IN_ALL
void gdk_toplevel_inhibit_system_shortcuts (GdkToplevel *toplevel,
GdkEvent *event);
GDK_AVAILABLE_IN_ALL
void gdk_toplevel_restore_system_shortcuts (GdkToplevel *toplevel);
G_END_DECLS
#endif /* __GDK_TOPLEVEL_H__ */
+1 -1
View File
@@ -293,7 +293,7 @@ gdk_toplevel_layout_get_fullscreen (GdkToplevelLayout *layout)
* Returns the monitor that the layout is fullscreening
* the surface on.
*
* Returns: (nullable): the monitor on which @layout fullscreens
* Returns: (nullable) (transfer none): the monitor on which @layout fullscreens
*/
GdkMonitor *
gdk_toplevel_layout_get_fullscreen_monitor (GdkToplevelLayout *layout)
+4
View File
@@ -21,6 +21,9 @@ struct _GdkToplevelInterface
gboolean (* show_window_menu) (GdkToplevel *toplevel,
GdkEvent *event);
gboolean (* supports_edge_constraints) (GdkToplevel *toplevel);
void (* inhibit_system_shortcuts) (GdkToplevel *toplevel,
GdkEvent *event);
void (* restore_system_shortcuts) (GdkToplevel *toplevel);
};
typedef enum
@@ -34,6 +37,7 @@ typedef enum
GDK_TOPLEVEL_PROP_DECORATED,
GDK_TOPLEVEL_PROP_DELETABLE,
GDK_TOPLEVEL_PROP_FULLSCREEN_MODE,
GDK_TOPLEVEL_PROP_SHORTCUTS_INHIBITED,
GDK_TOPLEVEL_NUM_PROPERTIES
} GdkToplevelProperties;
+100 -147
View File
@@ -122,7 +122,6 @@ typedef struct _GdkClipboard GdkClipboard;
typedef struct _GdkDisplayManager GdkDisplayManager;
typedef struct _GdkDisplay GdkDisplay;
typedef struct _GdkSurface GdkSurface;
typedef struct _GdkKeymap GdkKeymap;
typedef struct _GdkAppLaunchContext GdkAppLaunchContext;
typedef struct _GdkSeat GdkSeat;
typedef struct _GdkSnapshot GdkSnapshot;
@@ -199,188 +198,54 @@ typedef enum
* @GDK_LOCK_MASK: a Lock key (depending on the modifier mapping of the
* X server this may either be CapsLock or ShiftLock).
* @GDK_CONTROL_MASK: the Control key.
* @GDK_MOD1_MASK: the fourth modifier key (it depends on the modifier
* @GDK_ALT_MASK: the fourth modifier key (it depends on the modifier
* mapping of the X server which key is interpreted as this modifier, but
* normally it is the Alt key).
* @GDK_MOD2_MASK: the fifth modifier key (it depends on the modifier
* mapping of the X server which key is interpreted as this modifier).
* @GDK_MOD3_MASK: the sixth modifier key (it depends on the modifier
* mapping of the X server which key is interpreted as this modifier).
* @GDK_MOD4_MASK: the seventh modifier key (it depends on the modifier
* mapping of the X server which key is interpreted as this modifier).
* @GDK_MOD5_MASK: the eighth modifier key (it depends on the modifier
* mapping of the X server which key is interpreted as this modifier).
* @GDK_BUTTON1_MASK: the first mouse button.
* @GDK_BUTTON2_MASK: the second mouse button.
* @GDK_BUTTON3_MASK: the third mouse button.
* @GDK_BUTTON4_MASK: the fourth mouse button.
* @GDK_BUTTON5_MASK: the fifth mouse button.
* @GDK_MODIFIER_RESERVED_13_MASK: A reserved bit flag; do not use in your own code
* @GDK_MODIFIER_RESERVED_14_MASK: A reserved bit flag; do not use in your own code
* @GDK_MODIFIER_RESERVED_15_MASK: A reserved bit flag; do not use in your own code
* @GDK_MODIFIER_RESERVED_16_MASK: A reserved bit flag; do not use in your own code
* @GDK_MODIFIER_RESERVED_17_MASK: A reserved bit flag; do not use in your own code
* @GDK_MODIFIER_RESERVED_18_MASK: A reserved bit flag; do not use in your own code
* @GDK_MODIFIER_RESERVED_19_MASK: A reserved bit flag; do not use in your own code
* @GDK_MODIFIER_RESERVED_20_MASK: A reserved bit flag; do not use in your own code
* @GDK_MODIFIER_RESERVED_21_MASK: A reserved bit flag; do not use in your own code
* @GDK_MODIFIER_RESERVED_22_MASK: A reserved bit flag; do not use in your own code
* @GDK_MODIFIER_RESERVED_23_MASK: A reserved bit flag; do not use in your own code
* @GDK_MODIFIER_RESERVED_24_MASK: A reserved bit flag; do not use in your own code
* @GDK_MODIFIER_RESERVED_25_MASK: A reserved bit flag; do not use in your own code
* @GDK_SUPER_MASK: the Super modifier
* @GDK_HYPER_MASK: the Hyper modifier
* @GDK_META_MASK: the Meta modifier
* @GDK_MODIFIER_RESERVED_29_MASK: A reserved bit flag; do not use in your own code
* @GDK_RELEASE_MASK: not used in GDK itself. GTK uses it to differentiate
* between (keyval, modifiers) pairs from key press and release events.
* @GDK_MODIFIER_MASK: a mask covering all modifier types.
*
* A set of bit-flags to indicate the state of modifier keys and mouse buttons
* in various event types. Typical modifier keys are Shift, Control, Meta,
* Super, Hyper, Alt, Compose, Apple, CapsLock or ShiftLock.
*
* Like the X Window System, GDK supports 8 modifier keys and 5 mouse buttons.
*
* GDK recognizes which of the Meta, Super or Hyper keys are mapped
* to Mod2 - Mod5, and indicates this by setting %GDK_SUPER_MASK,
* %GDK_HYPER_MASK or %GDK_META_MASK in the state field of key events.
*
* Note that GDK may add internal values to events which include
* reserved values such as %GDK_MODIFIER_RESERVED_13_MASK. Your code
* should preserve and ignore them. You can use %GDK_MODIFIER_MASK to
* remove all reserved values.
*
* Also note that the GDK X backend interprets button press events for button
* 4-7 as scroll events, so %GDK_BUTTON4_MASK and %GDK_BUTTON5_MASK will never
* be set.
* Note that GDK may add internal values to events which include values outside
* of this enumeration. Your code should preserve and ignore them. You can use
* %GDK_MODIFIER_MASK to remove all private values.
*/
typedef enum
{
GDK_SHIFT_MASK = 1 << 0,
GDK_LOCK_MASK = 1 << 1,
GDK_CONTROL_MASK = 1 << 2,
GDK_MOD1_MASK = 1 << 3,
GDK_MOD2_MASK = 1 << 4,
GDK_MOD3_MASK = 1 << 5,
GDK_MOD4_MASK = 1 << 6,
GDK_MOD5_MASK = 1 << 7,
GDK_ALT_MASK = 1 << 3,
GDK_BUTTON1_MASK = 1 << 8,
GDK_BUTTON2_MASK = 1 << 9,
GDK_BUTTON3_MASK = 1 << 10,
GDK_BUTTON4_MASK = 1 << 11,
GDK_BUTTON5_MASK = 1 << 12,
GDK_MODIFIER_RESERVED_13_MASK = 1 << 13,
GDK_MODIFIER_RESERVED_14_MASK = 1 << 14,
GDK_MODIFIER_RESERVED_15_MASK = 1 << 15,
GDK_MODIFIER_RESERVED_16_MASK = 1 << 16,
GDK_MODIFIER_RESERVED_17_MASK = 1 << 17,
GDK_MODIFIER_RESERVED_18_MASK = 1 << 18,
GDK_MODIFIER_RESERVED_19_MASK = 1 << 19,
GDK_MODIFIER_RESERVED_20_MASK = 1 << 20,
GDK_MODIFIER_RESERVED_21_MASK = 1 << 21,
GDK_MODIFIER_RESERVED_22_MASK = 1 << 22,
GDK_MODIFIER_RESERVED_23_MASK = 1 << 23,
GDK_MODIFIER_RESERVED_24_MASK = 1 << 24,
GDK_MODIFIER_RESERVED_25_MASK = 1 << 25,
/* The next few modifiers are used by XKB, so we skip to the end.
* Bits 15 - 25 are currently unused. Bit 29 is used internally.
*/
GDK_SUPER_MASK = 1 << 26,
GDK_HYPER_MASK = 1 << 27,
GDK_META_MASK = 1 << 28,
GDK_MODIFIER_RESERVED_29_MASK = 1 << 29,
GDK_RELEASE_MASK = 1 << 30,
/* Combination of GDK_SHIFT_MASK..GDK_BUTTON5_MASK + GDK_SUPER_MASK
+ GDK_HYPER_MASK + GDK_META_MASK + GDK_RELEASE_MASK */
GDK_MODIFIER_MASK = 0x5c001fff
} GdkModifierType;
/**
* GdkModifierIntent:
* @GDK_MODIFIER_INTENT_PRIMARY_ACCELERATOR: the primary modifier used to invoke
* menu accelerators.
* @GDK_MODIFIER_INTENT_CONTEXT_MENU: the modifier used to invoke context menus.
* Note that mouse button 3 always triggers context menus. When this modifier
* is not 0, it additionally triggers context menus when used with mouse button 1.
* @GDK_MODIFIER_INTENT_EXTEND_SELECTION: the modifier used to extend selections
* using `modifier`-click or `modifier`-cursor-key
* @GDK_MODIFIER_INTENT_MODIFY_SELECTION: the modifier used to modify selections,
* which in most cases means toggling the clicked item into or out of the selection.
* @GDK_MODIFIER_INTENT_NO_TEXT_INPUT: when any of these modifiers is pressed, the
* key event cannot produce a symbol directly. This is meant to be used for
* input methods, and for use cases like typeahead search.
* @GDK_MODIFIER_INTENT_SHIFT_GROUP: the modifier that switches between keyboard
* groups (AltGr on X11/Windows and Option/Alt on OS X).
* @GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK: The set of modifier masks accepted
* as modifiers in accelerators. Needed because Command is mapped to MOD2 on
* OSX, which is widely used, but on X11 MOD2 is NumLock and using that for a
* mod key is problematic at best.
* Ref: https://bugzilla.gnome.org/show_bug.cgi?id=736125.
*
* This enum is used with gdk_keymap_get_modifier_mask()
* in order to determine what modifiers the
* currently used windowing system backend uses for particular
* purposes. For example, on X11/Windows, the Control key is used for
* invoking menu shortcuts (accelerators), whereas on Apple computers
* its the Command key (which correspond to %GDK_CONTROL_MASK and
* %GDK_MOD2_MASK, respectively).
**/
typedef enum
{
GDK_MODIFIER_INTENT_PRIMARY_ACCELERATOR,
GDK_MODIFIER_INTENT_CONTEXT_MENU,
GDK_MODIFIER_INTENT_EXTEND_SELECTION,
GDK_MODIFIER_INTENT_MODIFY_SELECTION,
GDK_MODIFIER_INTENT_NO_TEXT_INPUT,
GDK_MODIFIER_INTENT_SHIFT_GROUP,
GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK,
} GdkModifierIntent;
/**
* GdkGrabStatus:
* @GDK_GRAB_SUCCESS: the resource was successfully grabbed.
* @GDK_GRAB_ALREADY_GRABBED: the resource is actively grabbed by another client.
* @GDK_GRAB_INVALID_TIME: the resource was grabbed more recently than the
* specified time.
* @GDK_GRAB_NOT_VIEWABLE: the grab surface or the @confine_to surface 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
* GDK_MODIFIER_MASK:
*
* Returned by gdk_device_grab() to indicate success or the reason for the
* failure of the grab attempt.
* A mask covering all entries in #GdkModifierType.
*/
typedef enum
{
GDK_GRAB_SUCCESS = 0,
GDK_GRAB_ALREADY_GRABBED = 1,
GDK_GRAB_INVALID_TIME = 2,
GDK_GRAB_NOT_VIEWABLE = 3,
GDK_GRAB_FROZEN = 4,
GDK_GRAB_FAILED = 5
} GdkGrabStatus;
/**
* GdkGrabOwnership:
* @GDK_OWNERSHIP_NONE: All other devices events are allowed.
* @GDK_OWNERSHIP_SURFACE: Other devices events are blocked for the grab surface.
* @GDK_OWNERSHIP_APPLICATION: Other devices events are blocked for the whole application.
*
* Defines how device grabs interact with other devices.
*/
typedef enum
{
GDK_OWNERSHIP_NONE,
GDK_OWNERSHIP_SURFACE,
GDK_OWNERSHIP_APPLICATION
} GdkGrabOwnership;
#define GDK_MODIFIER_MASK (GDK_SHIFT_MASK|GDK_LOCK_MASK|GDK_CONTROL_MASK| \
GDK_ALT_MASK|GDK_SUPER_MASK|GDK_HYPER_MASK|GDK_META_MASK| \
GDK_BUTTON1_MASK|GDK_BUTTON2_MASK|GDK_BUTTON3_MASK| \
GDK_BUTTON4_MASK|GDK_BUTTON5_MASK)
/**
* GdkEventMask:
@@ -624,6 +489,94 @@ typedef enum
*/
#define GDK_ACTION_ALL (GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK)
/*
* GDK_DECLARE_INTERNAL_TYPE:
* @ModuleObjName: The name of the new type, in camel case (like GtkWidget)
* @module_obj_name: The name of the new type in lowercase, with words
* separated by '_' (like 'gtk_widget')
* @MODULE: The name of the module, in all caps (like 'GTK')
* @OBJ_NAME: The bare name of the type, in all caps (like 'WIDGET')
* @ParentName: the name of the parent type, in camel case (like GtkWidget)
*
* A convenience macro for emitting the usual declarations in the
* header file for a type which is intended to be subclassed only
* by internal consumers.
*
* This macro differs from %G_DECLARE_DERIVABLE_TYPE and %G_DECLARE_FINAL_TYPE
* by declaring a type that is only derivable internally. Internal users can
* derive this type, assuming they have access to the instance and class
* structures; external users will not be able to subclass this type.
*/
#define GDK_DECLARE_INTERNAL_TYPE(ModuleObjName, module_obj_name, MODULE, OBJ_NAME, ParentName) \
GType module_obj_name##_get_type (void); \
G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
typedef struct _##ModuleObjName ModuleObjName; \
typedef struct _##ModuleObjName##Class ModuleObjName##Class; \
\
_GLIB_DEFINE_AUTOPTR_CHAINUP (ModuleObjName, ParentName) \
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ModuleObjName##Class, g_type_class_unref) \
\
G_GNUC_UNUSED static inline ModuleObjName * MODULE##_##OBJ_NAME (gpointer ptr) { \
return G_TYPE_CHECK_INSTANCE_CAST (ptr, module_obj_name##_get_type (), ModuleObjName); } \
G_GNUC_UNUSED static inline ModuleObjName##Class * MODULE##_##OBJ_NAME##_CLASS (gpointer ptr) { \
return G_TYPE_CHECK_CLASS_CAST (ptr, module_obj_name##_get_type (), ModuleObjName##Class); } \
G_GNUC_UNUSED static inline gboolean MODULE##_IS_##OBJ_NAME (gpointer ptr) { \
return G_TYPE_CHECK_INSTANCE_TYPE (ptr, module_obj_name##_get_type ()); } \
G_GNUC_UNUSED static inline gboolean MODULE##_IS_##OBJ_NAME##_CLASS (gpointer ptr) { \
return G_TYPE_CHECK_CLASS_TYPE (ptr, module_obj_name##_get_type ()); } \
G_GNUC_UNUSED static inline ModuleObjName##Class * MODULE##_##OBJ_NAME##_GET_CLASS (gpointer ptr) { \
return G_TYPE_INSTANCE_GET_CLASS (ptr, module_obj_name##_get_type (), ModuleObjName##Class); } \
G_GNUC_END_IGNORE_DEPRECATIONS
typedef struct _GdkKeymapKey GdkKeymapKey;
/**
* GdkKeymapKey:
* @keycode: the hardware keycode. This is an identifying number for a
* physical key.
* @group: indicates movement in a horizontal direction. Usually groups are used
* for two different languages. In group 0, a key might have two English
* characters, and in group 1 it might have two Hebrew characters. The Hebrew
* characters will be printed on the key next to the English characters.
* @level: indicates which symbol on the key will be used, in a vertical direction.
* So on a standard US keyboard, the key with the number 1 on it also has the
* exclamation point ("!") character on it. The level indicates whether to use
* the 1 or the ! symbol. The letter keys are considered to have a lowercase
* letter at level 0, and an uppercase letter at level 1, though only the
* uppercase letter is printed.
*
* A #GdkKeymapKey is a hardware key that can be mapped to a keyval.
*/
struct _GdkKeymapKey
{
guint keycode;
gint group;
gint level;
};
G_END_DECLS
/*< private >
* GDK_EXTERN_VAR:
*
* A macro to annotate extern variables so that they show up properly in
* Windows DLLs.
*/
#ifndef GDK_EXTERN_VAR
# ifdef G_PLATFORM_WIN32
# ifdef GTK_COMPILATION
# ifdef DLL_EXPORT
# define GDK_EXTERN_VAR __declspec(dllexport)
# else /* !DLL_EXPORT */
# define GDK_EXTERN_VAR extern
# endif /* !DLL_EXPORT */
# else /* !GTK_COMPILATION */
# define GDK_EXTERN_VAR extern __declspec(dllimport)
# endif /* !GTK_COMPILATION */
# else /* !G_PLATFORM_WIN32 */
# define GDK_EXTERN_VAR _GDK_EXTERN
# endif /* !G_PLATFORM_WIN32 */
#endif /* GDK_EXTERN_VAR */
#endif /* __GDK_TYPES_H__ */
+18 -3
View File
@@ -5,6 +5,20 @@
# Usage: gen-gdk-gresources-xml SRCDIR_GDK [OUTPUT-FILE]
import os, sys
import filecmp
def replace_if_changed(new, old):
'''
Compare contents and only replace if changed to avoid triggering a rebuild.
'''
try:
changed = not filecmp.cmp(new, old, shallow=False)
except FileNotFoundError:
changed = True
if changed:
os.replace(new, old)
else:
os.remove(new)
srcdir = sys.argv[1]
@@ -26,8 +40,9 @@ xml += '''
if len(sys.argv) > 2:
outfile = sys.argv[2]
f = open(outfile, 'w')
f.write(xml)
f.close()
tmpfile = outfile + '~'
with open(tmpfile, 'w') as f:
f.write(xml)
replace_if_changed(tmpfile, outfile)
else:
print(xml)
+3 -3
View File
@@ -288,7 +288,7 @@ get_keyboard_modifiers_from_ns_flags (NSUInteger nsflags)
if (nsflags & NSControlKeyMask)
modifiers |= GDK_CONTROL_MASK;
if (nsflags & NSAlternateKeyMask)
modifiers |= GDK_MOD1_MASK;
modifiers |= GDK_ALT_MASK;
if (nsflags & NSCommandKeyMask)
modifiers |= GDK_MOD2_MASK;
@@ -1162,7 +1162,7 @@ fill_key_event (GdkSurface *window,
break;
case GDK_KEY_Alt_R:
case GDK_KEY_Alt_L:
mask = GDK_MOD1_MASK;
mask = GDK_ALT_MASK;
break;
case GDK_KEY_Control_R:
case GDK_KEY_Control_L:
@@ -1280,7 +1280,7 @@ _gdk_quartz_events_get_current_keyboard_modifiers (void)
if (carbon_modifiers & controlKey)
modifiers |= GDK_CONTROL_MASK;
if (carbon_modifiers & optionKey)
modifiers |= GDK_MOD1_MASK;
modifiers |= GDK_ALT_MASK;
if (carbon_modifiers & cmdKey)
modifiers |= GDK_MOD2_MASK;
-35
View File
@@ -735,40 +735,6 @@ gdk_quartz_keymap_map_virtual_modifiers (GdkKeymap *keymap,
return TRUE;
}
static GdkModifierType
gdk_quartz_keymap_get_modifier_mask (GdkKeymap *keymap,
GdkModifierIntent intent)
{
switch (intent)
{
case GDK_MODIFIER_INTENT_PRIMARY_ACCELERATOR:
return GDK_MOD2_MASK;
case GDK_MODIFIER_INTENT_CONTEXT_MENU:
return GDK_CONTROL_MASK;
case GDK_MODIFIER_INTENT_EXTEND_SELECTION:
return GDK_SHIFT_MASK;
case GDK_MODIFIER_INTENT_MODIFY_SELECTION:
return GDK_MOD2_MASK;
case GDK_MODIFIER_INTENT_NO_TEXT_INPUT:
return GDK_MOD2_MASK | GDK_CONTROL_MASK;
case GDK_MODIFIER_INTENT_SHIFT_GROUP:
return GDK_MOD1_MASK;
case GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK:
return (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK |
GDK_MOD2_MASK | GDK_SUPER_MASK | GDK_HYPER_MASK |
GDK_META_MASK);
default:
g_return_val_if_reached (0);
}
}
/* What sort of key event is this? Returns one of
* GDK_KEY_PRESS, GDK_KEY_RELEASE, GDK_NOTHING (should be ignored)
*/
@@ -881,5 +847,4 @@ gdk_quartz_keymap_class_init (GdkQuartzKeymapClass *klass)
keymap_class->translate_keyboard_state = gdk_quartz_keymap_translate_keyboard_state;
keymap_class->add_virtual_modifiers = gdk_quartz_keymap_add_virtual_modifiers;
keymap_class->map_virtual_modifiers = gdk_quartz_keymap_map_virtual_modifiers;
keymap_class->get_modifier_mask = gdk_quartz_keymap_get_modifier_mask;
}
+113 -12
View File
@@ -30,6 +30,7 @@
#include "gdkseat-wayland.h"
#include "gdkwayland.h"
#include "gdkkeysyms.h"
#include "gdkkeysprivate.h"
#include "gdkcursorprivate.h"
#include "gdkdeviceprivate.h"
#include "gdkdevicepadprivate.h"
@@ -1856,16 +1857,38 @@ keyboard_handle_keymap (void *data,
{
GdkWaylandSeat *seat = data;
PangoDirection direction;
gboolean bidi;
gboolean caps_lock;
gboolean num_lock;
gboolean scroll_lock;
GdkModifierType modifiers;
direction = gdk_keymap_get_direction (seat->keymap);
bidi = gdk_keymap_have_bidi_layouts (seat->keymap);
caps_lock = gdk_keymap_get_caps_lock_state (seat->keymap);
num_lock = gdk_keymap_get_num_lock_state (seat->keymap);
scroll_lock = gdk_keymap_get_scroll_lock_state (seat->keymap);
modifiers = gdk_keymap_get_modifier_state (seat->keymap);
_gdk_wayland_keymap_update_from_fd (seat->keymap, format, fd, size);
g_signal_emit_by_name (seat->keymap, "keys-changed");
g_signal_emit_by_name (seat->keymap, "state-changed");
if (direction != gdk_keymap_get_direction (seat->keymap))
g_signal_emit_by_name (seat->keymap, "direction-changed");
if (direction != gdk_keymap_get_direction (seat->keymap))
g_object_notify (G_OBJECT (seat->master_keyboard), "direction");
if (bidi != gdk_keymap_have_bidi_layouts (seat->keymap))
g_object_notify (G_OBJECT (seat->master_keyboard), "has-bidi-layouts");
if (caps_lock != gdk_keymap_get_caps_lock_state (seat->keymap))
g_object_notify (G_OBJECT (seat->master_keyboard), "caps-lock-state");
if (num_lock != gdk_keymap_get_num_lock_state (seat->keymap))
g_object_notify (G_OBJECT (seat->master_keyboard), "num-lock-state");
if (scroll_lock != gdk_keymap_get_scroll_lock_state (seat->keymap))
g_object_notify (G_OBJECT (seat->master_keyboard), "scroll-lock-state");
if (modifiers != gdk_keymap_get_modifier_state (seat->keymap))
g_object_notify (G_OBJECT (seat->master_keyboard), "modifier-state");
}
static void
@@ -1934,6 +1957,7 @@ keyboard_handle_leave (void *data,
g_object_unref (seat->keyboard_focus);
seat->keyboard_focus = NULL;
seat->repeat_key = 0;
seat->key_modifiers = 0;
GDK_SEAT_NOTE (seat, EVENTS,
g_message ("focus out, seat %p surface %p",
@@ -1997,9 +2021,13 @@ deliver_key_event (GdkWaylandSeat *seat,
struct xkb_state *xkb_state;
struct xkb_keymap *xkb_keymap;
GdkKeymap *keymap;
xkb_keysym_t sym;
guint delay, interval, timeout;
gint64 begin_time, now;
xkb_mod_mask_t consumed;
GdkTranslatedKey translated;
GdkTranslatedKey no_lock;
xkb_mod_mask_t modifiers;
xkb_mod_index_t caps_lock;
begin_time = g_get_monotonic_time ();
@@ -2009,36 +2037,69 @@ deliver_key_event (GdkWaylandSeat *seat,
xkb_state = _gdk_wayland_keymap_get_xkb_state (keymap);
xkb_keymap = _gdk_wayland_keymap_get_xkb_keymap (keymap);
sym = xkb_state_key_get_one_sym (xkb_state, key);
if (sym == XKB_KEY_NoSymbol)
translated.keyval = xkb_state_key_get_one_sym (xkb_state, key);
modifiers = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_EFFECTIVE);
consumed = modifiers & ~xkb_state_mod_mask_remove_consumed (xkb_state, key, modifiers);
translated.consumed = gdk_wayland_keymap_get_gdk_modifiers (keymap, consumed);
translated.layout = xkb_state_key_get_layout (xkb_state, key);
translated.level = xkb_state_key_get_level (xkb_state, key, translated.layout);
if (translated.keyval == XKB_KEY_NoSymbol)
return;
seat->pointer_info.time = time_;
seat->key_modifiers = gdk_keymap_get_modifier_state (keymap);
modifiers = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_EFFECTIVE);
caps_lock = xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_CAPS);
if (modifiers & (1 << caps_lock))
{
struct xkb_state *tmp_state = xkb_state_new (xkb_keymap);
xkb_layout_index_t layout;
modifiers &= ~(1 << caps_lock);
layout = xkb_state_serialize_layout (xkb_state, XKB_STATE_LAYOUT_EFFECTIVE);
xkb_state_update_mask (tmp_state, modifiers, 0, 0, layout, 0, 0);
no_lock.keyval = xkb_state_key_get_one_sym (tmp_state, key);
consumed = modifiers & ~xkb_state_mod_mask_remove_consumed (tmp_state, key, modifiers);
no_lock.consumed = gdk_wayland_keymap_get_gdk_modifiers (keymap, consumed);
no_lock.layout = xkb_state_key_get_layout (tmp_state, key);
no_lock.level = xkb_state_key_get_level (tmp_state, key, no_lock.layout);
xkb_state_unref (tmp_state);
}
else
{
no_lock = translated;
}
event = gdk_event_key_new (state ? GDK_KEY_PRESS : GDK_KEY_RELEASE,
seat->keyboard_focus,
seat->master_keyboard,
seat->keyboard,
time_,
key,
device_get_modifiers (seat->master_pointer),
sym,
key,
key,
0,
_gdk_wayland_keymap_key_is_modifier (keymap, key));
_gdk_wayland_keymap_key_is_modifier (keymap, key),
&translated,
&no_lock);
_gdk_wayland_display_deliver_event (seat->display, event);
GDK_SEAT_NOTE (seat, EVENTS,
g_message ("keyboard %s event%s, surface %p, code %d, sym %d, "
"mods 0x%x",
"mods 0x%x, consumed 0x%x, layout %d level %d",
(state ? "press" : "release"),
(from_key_repeat ? " (repeat)" : ""),
gdk_event_get_surface (event),
gdk_key_event_get_keycode (event),
gdk_key_event_get_keyval (event),
gdk_event_get_modifier_state (event)));
gdk_event_get_modifier_state (event),
gdk_key_event_get_consumed_modifiers (event),
gdk_key_event_get_layout (event),
gdk_key_event_get_level (event)));
if (!xkb_keymap_key_repeats (xkb_keymap, key))
return;
@@ -2154,11 +2215,38 @@ keyboard_handle_modifiers (void *data,
GdkKeymap *keymap;
struct xkb_state *xkb_state;
PangoDirection direction;
gboolean bidi;
gboolean caps_lock;
gboolean num_lock;
gboolean scroll_lock;
GdkModifierType modifiers;
keymap = seat->keymap;
direction = gdk_keymap_get_direction (keymap);
xkb_state = _gdk_wayland_keymap_get_xkb_state (keymap);
direction = gdk_keymap_get_direction (seat->keymap);
bidi = gdk_keymap_have_bidi_layouts (seat->keymap);
caps_lock = gdk_keymap_get_caps_lock_state (seat->keymap);
num_lock = gdk_keymap_get_num_lock_state (seat->keymap);
scroll_lock = gdk_keymap_get_scroll_lock_state (seat->keymap);
modifiers = gdk_keymap_get_modifier_state (seat->keymap);
/* Note: the docs for xkb_state_update mask state that all parameters
* must be passed, or we may end up with an 'incoherent' state. But the
* Wayland modifiers event only includes a single group field, so we
* can't pass depressed/latched/locked groups.
*
* We assume that the compositor is sending us the 'effective' group
* (the protocol is not clear on that point), and pass it as the depressed
* group - we are basically pretending that the user holds down a key for
* this group at all times.
*
* This means that our xkb_state would answer a few questions differently
* from the compositors xkb_state - e.g. if you asked it about the latched
* group. But nobody is asking it those questions, so it does not really
* matter. We hope.
*/
xkb_state_update_mask (xkb_state, mods_depressed, mods_latched, mods_locked, group, 0, 0);
seat->key_modifiers = gdk_keymap_get_modifier_state (keymap);
@@ -2166,6 +2254,19 @@ keyboard_handle_modifiers (void *data,
g_signal_emit_by_name (keymap, "state-changed");
if (direction != gdk_keymap_get_direction (keymap))
g_signal_emit_by_name (keymap, "direction-changed");
if (direction != gdk_keymap_get_direction (seat->keymap))
g_object_notify (G_OBJECT (seat->master_keyboard), "direction");
if (bidi != gdk_keymap_have_bidi_layouts (seat->keymap))
g_object_notify (G_OBJECT (seat->master_keyboard), "has-bidi-layouts");
if (caps_lock != gdk_keymap_get_caps_lock_state (seat->keymap))
g_object_notify (G_OBJECT (seat->master_keyboard), "caps-lock-state");
if (num_lock != gdk_keymap_get_num_lock_state (seat->keymap))
g_object_notify (G_OBJECT (seat->master_keyboard), "num-lock-state");
if (scroll_lock != gdk_keymap_get_scroll_lock_state (seat->keymap))
g_object_notify (G_OBJECT (seat->master_keyboard), "scroll-lock-state");
if (modifiers != gdk_keymap_get_modifier_state (seat->keymap))
g_object_notify (G_OBJECT (seat->master_keyboard), "modifier-state");
}
static void
+3 -1
View File
@@ -431,6 +431,7 @@ gdk_registry_handle_global (void *data,
else if (strcmp (interface, "xdg_wm_base") == 0)
{
display_wayland->xdg_wm_base_id = id;
display_wayland->xdg_wm_base_version = version;
}
else if (strcmp (interface, "zxdg_shell_v6") == 0)
{
@@ -659,7 +660,8 @@ _gdk_wayland_display_open (const gchar *display_name)
display_wayland->xdg_wm_base =
wl_registry_bind (display_wayland->wl_registry,
display_wayland->xdg_wm_base_id,
&xdg_wm_base_interface, 1);
&xdg_wm_base_interface,
MIN (display_wayland->xdg_wm_base_version, 3));
xdg_wm_base_add_listener (display_wayland->xdg_wm_base,
&xdg_wm_base_listener,
display_wayland);
+1
View File
@@ -86,6 +86,7 @@ struct _GdkWaylandDisplay
guint32 serial;
uint32_t xdg_wm_base_id;
int xdg_wm_base_version;
uint32_t zxdg_shell_v6_id;
GdkWaylandShellVariant shell_variant;
+12 -83
View File
@@ -258,16 +258,8 @@ get_xkb_modifiers (struct xkb_keymap *xkb_keymap,
mods |= 1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_CAPS);
if (state & GDK_CONTROL_MASK)
mods |= 1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_CTRL);
if (state & GDK_MOD1_MASK)
if (state & GDK_ALT_MASK)
mods |= 1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_ALT);
if (state & GDK_MOD2_MASK)
mods |= 1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_NUM);
if (state & GDK_MOD3_MASK)
mods |= 1 << xkb_keymap_mod_get_index (xkb_keymap, "Mod3");
if (state & GDK_MOD4_MASK)
mods |= 1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_LOGO);
if (state & GDK_MOD5_MASK)
mods |= 1 << xkb_keymap_mod_get_index (xkb_keymap, "Mod5");
if (state & GDK_SUPER_MASK)
mods |= 1 << xkb_keymap_mod_get_index (xkb_keymap, "Super");
if (state & GDK_HYPER_MASK)
@@ -291,15 +283,7 @@ get_gdk_modifiers (struct xkb_keymap *xkb_keymap,
if (mods & (1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_CTRL)))
state |= GDK_CONTROL_MASK;
if (mods & (1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_ALT)))
state |= GDK_MOD1_MASK;
if (mods & (1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_NUM)))
state |= GDK_MOD2_MASK;
if (mods & (1 << xkb_keymap_mod_get_index (xkb_keymap, "Mod3")))
state |= GDK_MOD3_MASK;
if (mods & (1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_LOGO)))
state |= GDK_MOD4_MASK;
if (mods & (1 << xkb_keymap_mod_get_index (xkb_keymap, "Mod5")))
state |= GDK_MOD5_MASK;
state |= GDK_ALT_MASK;
if (mods & (1 << xkb_keymap_mod_get_index (xkb_keymap, "Super")))
state |= GDK_SUPER_MASK;
if (mods & (1 << xkb_keymap_mod_get_index (xkb_keymap, "Hyper")))
@@ -310,12 +294,21 @@ get_gdk_modifiers (struct xkb_keymap *xkb_keymap,
* rely on that behavior.
*/
if (mods & (1 << xkb_keymap_mod_get_index (xkb_keymap, "Meta")) &&
(state & GDK_MOD1_MASK) == 0)
(state & GDK_ALT_MASK) == 0)
state |= GDK_META_MASK;
return state;
}
GdkModifierType
gdk_wayland_keymap_get_gdk_modifiers (GdkKeymap *keymap,
guint32 mods)
{
struct xkb_keymap *xkb_keymap = GDK_WAYLAND_KEYMAP (keymap)->xkb_keymap;
return get_gdk_modifiers (xkb_keymap, mods);
}
static gboolean
gdk_wayland_keymap_translate_keyboard_state (GdkKeymap *keymap,
guint hardware_keycode,
@@ -376,68 +369,6 @@ gdk_wayland_keymap_get_modifier_state (GdkKeymap *keymap)
return get_gdk_modifiers (xkb_keymap, mods);
}
static void
gdk_wayland_keymap_add_virtual_modifiers (GdkKeymap *keymap,
GdkModifierType *state)
{
struct xkb_keymap *xkb_keymap;
struct xkb_state *xkb_state;
xkb_mod_index_t idx;
uint32_t mods, real;
struct { const char *name; GdkModifierType mask; } vmods[] = {
{ "Super", GDK_SUPER_MASK },
{ "Hyper", GDK_HYPER_MASK },
{ "Meta", GDK_META_MASK },
{ NULL, 0 }
};
int i;
xkb_keymap = GDK_WAYLAND_KEYMAP (keymap)->xkb_keymap;
mods = get_xkb_modifiers (xkb_keymap, *state);
xkb_state = xkb_state_new (xkb_keymap);
for (i = 0; vmods[i].name; i++)
{
idx = xkb_keymap_mod_get_index (xkb_keymap, vmods[i].name);
if (idx == XKB_MOD_INVALID)
continue;
xkb_state_update_mask (xkb_state, 1 << idx, 0, 0, 0, 0, 0);
real = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_EFFECTIVE);
real &= 0xf0; /* ignore mapping to Lock, Shift, Control, Mod1 */
if (mods & real)
*state |= vmods[i].mask;
xkb_state_update_mask (xkb_state, 0, 0, 0, 0, 0, 0);
}
xkb_state_unref (xkb_state);
}
static gboolean
gdk_wayland_keymap_map_virtual_modifiers (GdkKeymap *keymap,
GdkModifierType *state)
{
struct xkb_keymap *xkb_keymap;
struct xkb_state *xkb_state;
uint32_t mods, mapped;
gboolean ret = TRUE;
xkb_keymap = GDK_WAYLAND_KEYMAP (keymap)->xkb_keymap;
mods = get_xkb_modifiers (xkb_keymap, *state);
xkb_state = xkb_state_new (xkb_keymap);
xkb_state_update_mask (xkb_state, mods & ~0xff, 0, 0, 0, 0, 0);
mapped = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_EFFECTIVE);
if ((mapped & mods & 0xff) != 0)
ret = FALSE;
*state |= get_gdk_modifiers (xkb_keymap, mapped);
xkb_state_unref (xkb_state);
return ret;
}
static void
_gdk_wayland_keymap_class_init (GdkWaylandKeymapClass *klass)
{
@@ -456,8 +387,6 @@ _gdk_wayland_keymap_class_init (GdkWaylandKeymapClass *klass)
keymap_class->lookup_key = gdk_wayland_keymap_lookup_key;
keymap_class->translate_keyboard_state = gdk_wayland_keymap_translate_keyboard_state;
keymap_class->get_modifier_state = gdk_wayland_keymap_get_modifier_state;
keymap_class->add_virtual_modifiers = gdk_wayland_keymap_add_virtual_modifiers;
keymap_class->map_virtual_modifiers = gdk_wayland_keymap_map_virtual_modifiers;
}
static void
+2
View File
@@ -201,5 +201,7 @@ void gdk_wayland_surface_update_scale (GdkSurface *surface);
GdkSurface * create_dnd_surface (GdkDisplay *display);
GdkModifierType gdk_wayland_keymap_get_gdk_modifiers (GdkKeymap *keymap,
guint32 mods);
#endif /* __GDK_PRIVATE_WAYLAND_H__ */
+306 -107
View File
@@ -59,6 +59,7 @@ static guint signals[LAST_SIGNAL];
typedef enum _PopupState
{
POPUP_STATE_IDLE,
POPUP_STATE_WAITING_FOR_REPOSITIONED,
POPUP_STATE_WAITING_FOR_CONFIGURE,
POPUP_STATE_WAITING_FOR_FRAME,
} PopupState;
@@ -94,6 +95,9 @@ struct _GdkWaylandSurface
EGLSurface egl_surface;
EGLSurface dummy_egl_surface;
uint32_t reposition_token;
uint32_t received_reposition_token;
PopupState popup_state;
unsigned int initial_configure_received : 1;
@@ -103,8 +107,6 @@ struct _GdkWaylandSurface
unsigned int awaiting_frame_frozen : 1;
unsigned int is_drag_surface : 1;
GdkSurfaceTypeHint hint;
GdkSurface *transient_for;
GdkSurface *popup_parent;
int pending_buffer_offset_x;
int pending_buffer_offset_y;
@@ -167,12 +169,18 @@ struct _GdkWaylandSurface
int y;
int width;
int height;
uint32_t repositioned_token;
gboolean has_repositioned_token;
} popup;
gboolean is_initial_configure;
uint32_t serial;
gboolean is_dirty;
} pending;
uint32_t last_configure_serial;
int state_freeze_count;
struct {
@@ -190,6 +198,76 @@ struct _GdkWaylandSurfaceClass
GdkSurfaceClass parent_class;
};
G_DEFINE_TYPE (GdkWaylandSurface, gdk_wayland_surface, GDK_TYPE_SURFACE)
typedef struct _GdkWaylandToplevel GdkWaylandToplevel;
struct _GdkWaylandToplevel
{
GdkWaylandSurface parent_instance;
GdkWaylandToplevel *transient_for;
};
typedef struct
{
GdkWaylandSurfaceClass parent_class;
} GdkWaylandToplevelClass;
static void gdk_wayland_toplevel_iface_init (GdkToplevelInterface *iface);
GType gdk_wayland_toplevel_get_type (void) G_GNUC_CONST;
#define GDK_IS_WAYLAND_TOPLEVEL(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_TOPLEVEL))
#define GDK_WAYLAND_TOPLEVEL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_TOPLEVEL, GdkWaylandToplevel))
#define GDK_TYPE_WAYLAND_TOPLEVEL (gdk_wayland_toplevel_get_type ())
G_DEFINE_TYPE_WITH_CODE (GdkWaylandToplevel, gdk_wayland_toplevel, GDK_TYPE_WAYLAND_SURFACE,
G_IMPLEMENT_INTERFACE (GDK_TYPE_TOPLEVEL,
gdk_wayland_toplevel_iface_init))
typedef struct
{
GdkWaylandSurface parent_instance;
} GdkWaylandPopup;
typedef struct
{
GdkWaylandSurfaceClass parent_class;
} GdkWaylandPopupClass;
static void gdk_wayland_popup_iface_init (GdkPopupInterface *iface);
GType gdk_wayland_popup_get_type (void) G_GNUC_CONST;
#define GDK_IS_WAYLAND_POPUP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_POPUP))
#define GDK_WAYLAND_POPUP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WAYLAND_POPUP, GdkWaylandPopup))
#define GDK_TYPE_WAYLAND_POPUP (gdk_wayland_popup_get_type ())
G_DEFINE_TYPE_WITH_CODE (GdkWaylandPopup, gdk_wayland_popup, GDK_TYPE_WAYLAND_SURFACE,
G_IMPLEMENT_INTERFACE (GDK_TYPE_POPUP,
gdk_wayland_popup_iface_init))
typedef struct
{
GdkWaylandSurface parent_instance;
} GdkWaylandDragSurface;
typedef struct
{
GdkWaylandSurfaceClass parent_class;
} GdkWaylandDragSurfaceClass;
static void gdk_wayland_drag_surface_iface_init (GdkDragSurfaceInterface *iface);
GType gdk_wayland_drag_surface_get_type (void) G_GNUC_CONST;
#define GDK_IS_WAYLAND_DRAG_SURFACE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WAYLAND_DRAG_SURFACE))
#define GDK_TYPE_WAYLAND_DRAG_SURFACE (gdk_wayland_drag_surface_get_type ())
G_DEFINE_TYPE_WITH_CODE (GdkWaylandDragSurface, gdk_wayland_drag_surface, GDK_TYPE_WAYLAND_SURFACE,
G_IMPLEMENT_INTERFACE (GDK_TYPE_DRAG_SURFACE,
gdk_wayland_drag_surface_iface_init))
static void gdk_wayland_surface_maybe_resize (GdkSurface *surface,
int width,
int height,
@@ -221,16 +299,6 @@ static void update_popup_layout_state (GdkSurface *surface,
static gboolean gdk_wayland_surface_is_exported (GdkSurface *surface);
G_DEFINE_TYPE (GdkWaylandSurface, gdk_wayland_surface, GDK_TYPE_SURFACE)
GType gdk_wayland_toplevel_get_type (void) G_GNUC_CONST;
GType gdk_wayland_popup_get_type (void) G_GNUC_CONST;
GType gdk_wayland_drag_surface_get_type (void) G_GNUC_CONST;
#define GDK_TYPE_WAYLAND_TOPLEVEL (gdk_wayland_toplevel_get_type ())
#define GDK_TYPE_WAYLAND_POPUP (gdk_wayland_popup_get_type ())
#define GDK_TYPE_WAYLAND_DRAG_SURFACE (gdk_wayland_drag_surface_get_type ())
static void
gdk_wayland_surface_init (GdkWaylandSurface *impl)
{
@@ -438,6 +506,7 @@ frame_callback (void *data,
switch (impl->popup_state)
{
case POPUP_STATE_IDLE:
case POPUP_STATE_WAITING_FOR_REPOSITIONED:
case POPUP_STATE_WAITING_FOR_CONFIGURE:
break;
case POPUP_STATE_WAITING_FOR_FRAME:
@@ -632,6 +701,9 @@ _gdk_wayland_display_create_surface (GdkDisplay *display,
"display", display,
"frame-clock", frame_clock,
NULL);
display_wayland->toplevels = g_list_prepend (display_wayland->toplevels,
surface);
g_warn_if_fail (!parent);
break;
case GDK_SURFACE_POPUP:
surface = g_object_new (GDK_TYPE_WAYLAND_POPUP,
@@ -678,10 +750,6 @@ _gdk_wayland_display_create_surface (GdkDisplay *display,
gdk_wayland_surface_set_title (surface, get_default_title ());
if (parent == NULL)
display_wayland->toplevels = g_list_prepend (display_wayland->toplevels, surface);
impl->transient_for = parent;
gdk_wayland_surface_create_surface (surface);
@@ -772,8 +840,6 @@ gdk_wayland_surface_dispose (GObject *object)
impl = GDK_WAYLAND_SURFACE (surface);
g_clear_object (&impl->popup_parent);
if (impl->event_queue)
{
GdkWaylandDisplay *display_wayland =
@@ -903,6 +969,7 @@ gdk_wayland_surface_sync_parent (GdkSurface *surface,
GdkSurface *parent)
{
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
GdkWaylandToplevel *toplevel = GDK_WAYLAND_TOPLEVEL (impl);
GdkWaylandDisplay *display_wayland =
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
GdkWaylandSurface *impl_parent = NULL;
@@ -913,8 +980,8 @@ gdk_wayland_surface_sync_parent (GdkSurface *surface,
if (!is_realized_toplevel (surface))
return;
if (impl->transient_for)
impl_parent = GDK_WAYLAND_SURFACE (impl->transient_for);
if (toplevel->transient_for)
impl_parent = GDK_WAYLAND_SURFACE (toplevel->transient_for);
else if (parent)
impl_parent = GDK_WAYLAND_SURFACE (parent);
@@ -1282,8 +1349,17 @@ gdk_wayland_surface_configure_popup (GdkSurface *surface)
impl->pending.serial);
}
if (impl->pending.popup.has_repositioned_token)
impl->received_reposition_token = impl->pending.popup.repositioned_token;
switch (impl->popup_state)
{
case POPUP_STATE_WAITING_FOR_REPOSITIONED:
if (impl->received_reposition_token != impl->reposition_token)
return;
else
gdk_surface_thaw_updates (surface);
G_GNUC_FALLTHROUGH;
case POPUP_STATE_WAITING_FOR_CONFIGURE:
impl->popup_state = POPUP_STATE_WAITING_FOR_FRAME;
break;
@@ -1306,6 +1382,10 @@ gdk_wayland_surface_configure_popup (GdkSurface *surface)
width, height,
impl->popup.layout);
if (!impl->pending.popup.has_repositioned_token &&
!impl->pending.is_initial_configure)
g_signal_emit_by_name (surface, "popup-layout-changed");
gdk_surface_invalidate_rect (surface, NULL);
}
@@ -1318,6 +1398,7 @@ gdk_wayland_surface_configure (GdkSurface *surface)
{
gdk_surface_thaw_updates (surface);
impl->initial_configure_received = TRUE;
impl->pending.is_initial_configure = TRUE;
}
if (is_realized_popup (surface))
@@ -1327,6 +1408,8 @@ gdk_wayland_surface_configure (GdkSurface *surface)
else
g_warn_if_reached ();
impl->last_configure_serial = impl->pending.serial;
memset (&impl->pending, 0, sizeof (impl->pending));
}
@@ -1663,9 +1746,31 @@ xdg_popup_done (void *data,
gdk_surface_hide (surface);
}
static void
xdg_popup_repositioned (void *data,
struct xdg_popup *xdg_popup,
uint32_t token)
{
GdkSurface *surface = GDK_SURFACE (data);
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
GDK_DISPLAY_NOTE (gdk_surface_get_display (surface), EVENTS,
g_message ("repositioned %p", surface));
if (impl->popup_state != POPUP_STATE_WAITING_FOR_REPOSITIONED)
{
g_warning ("Unexpected xdg_popup.repositioned event, probably buggy compositor");
return;
}
impl->pending.popup.repositioned_token = token;
impl->pending.popup.has_repositioned_token = TRUE;
}
static const struct xdg_popup_listener xdg_popup_listener = {
xdg_popup_configure,
xdg_popup_done,
xdg_popup_repositioned,
};
static void
@@ -2052,7 +2157,8 @@ static gpointer
create_dynamic_positioner (GdkSurface *surface,
int width,
int height,
GdkPopupLayout *layout)
GdkPopupLayout *layout,
gboolean ack_parent_configure)
{
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
GdkSurface *parent = surface->parent;
@@ -2129,6 +2235,30 @@ create_dynamic_positioner (GdkSurface *surface,
xdg_positioner_set_constraint_adjustment (positioner,
constraint_adjustment);
if (xdg_positioner_get_version (positioner) >=
XDG_POSITIONER_SET_REACTIVE_SINCE_VERSION)
xdg_positioner_set_reactive (positioner);
if (ack_parent_configure &&
xdg_positioner_get_version (positioner) >=
XDG_POSITIONER_SET_PARENT_CONFIGURE_SINCE_VERSION)
{
GdkWaylandSurface *parent_impl = GDK_WAYLAND_SURFACE (parent);
int parent_width;
int parent_height;
parent_width = parent->width - (parent_impl->margin_left +
parent_impl->margin_right);
parent_height = parent->height - (parent_impl->margin_top +
parent_impl->margin_bottom);
xdg_positioner_set_parent_size (positioner,
parent_width,
parent_height);
xdg_positioner_set_parent_configure (positioner,
parent_impl->last_configure_serial);
}
return positioner;
}
case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
@@ -2233,7 +2363,7 @@ gdk_wayland_surface_create_xdg_popup (GdkSurface *surface,
gdk_surface_freeze_updates (surface);
positioner = create_dynamic_positioner (surface, width, height, layout);
positioner = create_dynamic_positioner (surface, width, height, layout, FALSE);
switch (display->shell_variant)
{
@@ -2307,7 +2437,6 @@ gdk_wayland_surface_create_xdg_popup (GdkSurface *surface,
freeze_popup_toplevel_state (surface);
}
g_set_object (&impl->popup_parent, parent);
display->current_popups = g_list_append (display->current_popups, surface);
if (grab_input_seat)
{
@@ -2396,9 +2525,8 @@ unmap_popups_for_surface (GdkSurface *surface)
for (l = display_wayland->current_popups; l; l = l->next)
{
GdkSurface *popup = l->data;
GdkWaylandSurface *popup_impl = GDK_WAYLAND_SURFACE (popup);
if (popup_impl->popup_parent == surface)
if (popup->parent == surface)
{
g_warning ("Tried to unmap the parent of a popup");
gdk_surface_hide (popup);
@@ -2501,6 +2629,9 @@ gdk_wayland_surface_hide_surface (GdkSurface *surface)
{
switch (impl->popup_state)
{
case POPUP_STATE_WAITING_FOR_REPOSITIONED:
gdk_surface_thaw_updates (surface);
G_GNUC_FALLTHROUGH;
case POPUP_STATE_WAITING_FOR_CONFIGURE:
case POPUP_STATE_WAITING_FOR_FRAME:
thaw_popup_toplevel_state (surface);
@@ -2602,6 +2733,7 @@ do_queue_relayout (GdkSurface *surface,
GdkPopupLayout *layout)
{
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
struct xdg_positioner *positioner;
g_assert (is_realized_popup (surface));
g_assert (impl->popup_state == POPUP_STATE_IDLE ||
@@ -2612,7 +2744,41 @@ do_queue_relayout (GdkSurface *surface,
impl->popup.unconstrained_width = width;
impl->popup.unconstrained_height = height;
queue_relayout_fallback (surface, layout);
if (!impl->display_server.xdg_popup ||
xdg_popup_get_version (impl->display_server.xdg_popup) <
XDG_POPUP_REPOSITION_SINCE_VERSION)
{
g_warning_once ("Compositor doesn't support moving popups, "
"relying on remapping");
queue_relayout_fallback (surface, layout);
return;
}
positioner = create_dynamic_positioner (surface,
width, height, layout,
TRUE);
xdg_popup_reposition (impl->display_server.xdg_popup,
positioner,
++impl->reposition_token);
xdg_positioner_destroy (positioner);
gdk_surface_freeze_updates (surface);
switch (impl->popup_state)
{
case POPUP_STATE_IDLE:
freeze_popup_toplevel_state (surface);
break;
case POPUP_STATE_WAITING_FOR_FRAME:
break;
case POPUP_STATE_WAITING_FOR_CONFIGURE:
case POPUP_STATE_WAITING_FOR_REPOSITIONED:
default:
g_assert_not_reached ();
}
impl->popup_state = POPUP_STATE_WAITING_FOR_REPOSITIONED;
}
static gboolean
@@ -2623,6 +2789,9 @@ is_relayout_finished (GdkSurface *surface)
if (!impl->initial_configure_received)
return FALSE;
if (impl->reposition_token != impl->received_reposition_token)
return FALSE;
return TRUE;
}
@@ -2707,6 +2876,7 @@ reposition_popup (GdkSurface *surface,
case POPUP_STATE_WAITING_FOR_FRAME:
do_queue_relayout (surface, width, height, layout);
break;
case POPUP_STATE_WAITING_FOR_REPOSITIONED:
case POPUP_STATE_WAITING_FOR_CONFIGURE:
g_warn_if_reached ();
break;
@@ -3172,44 +3342,46 @@ gdk_wayland_surface_set_startup_id (GdkSurface *surface,
}
static gboolean
check_transient_for_loop (GdkSurface *surface,
GdkSurface *parent)
check_transient_for_loop (GdkWaylandToplevel *toplevel,
GdkWaylandToplevel *parent)
{
while (parent)
{
GdkWaylandSurface *impl;
if (!GDK_IS_WAYLAND_SURFACE (parent))
return FALSE;
impl = GDK_WAYLAND_SURFACE (parent);
if (impl->transient_for == surface)
if (parent->transient_for == toplevel)
return TRUE;
parent = impl->transient_for;
parent = parent->transient_for;
}
return FALSE;
}
static void
gdk_wayland_surface_set_transient_for (GdkSurface *surface,
GdkSurface *parent)
gdk_wayland_toplevel_set_transient_for (GdkWaylandToplevel *toplevel,
GdkSurface *parent)
{
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
g_return_if_fail (!parent || GDK_IS_WAYLAND_TOPLEVEL (parent));
g_return_if_fail (!parent ||
gdk_surface_get_display (GDK_SURFACE (toplevel)) == gdk_surface_get_display (parent));
g_assert (parent == NULL ||
gdk_surface_get_display (surface) == gdk_surface_get_display (parent));
if (check_transient_for_loop (surface, parent))
if (parent)
{
g_warning ("Setting %p transient for %p would create a loop", surface, parent);
return;
GdkWaylandToplevel *parent_toplevel = GDK_WAYLAND_TOPLEVEL (parent);
if (check_transient_for_loop (toplevel, parent_toplevel))
{
g_warning ("Setting %p transient for %p would create a loop",
toplevel, parent);
return;
}
}
unset_transient_for_exported (surface);
unset_transient_for_exported (GDK_SURFACE (toplevel));
impl->transient_for = parent;
if (parent)
toplevel->transient_for = GDK_WAYLAND_TOPLEVEL (parent);
else
toplevel->transient_for = NULL;
gdk_wayland_surface_sync_parent (surface, NULL);
gdk_wayland_surface_sync_parent (GDK_SURFACE (toplevel), NULL);
}
static void
@@ -4097,7 +4269,7 @@ gdk_wayland_surface_set_transient_for_exported (GdkSurface *surface,
return FALSE;
}
gdk_wayland_surface_set_transient_for (surface, NULL);
gdk_wayland_toplevel_set_transient_for (GDK_WAYLAND_TOPLEVEL (impl), NULL);
impl->imported_transient_for =
zxdg_importer_v1_import (display_wayland->xdg_importer, parent_handle_str);
@@ -4112,9 +4284,9 @@ gdk_wayland_surface_set_transient_for_exported (GdkSurface *surface,
static struct zwp_keyboard_shortcuts_inhibitor_v1 *
gdk_wayland_surface_get_inhibitor (GdkWaylandSurface *impl,
struct wl_seat *seat)
GdkSeat *gdk_seat)
{
return g_hash_table_lookup (impl->shortcuts_inhibitors, seat);
return g_hash_table_lookup (impl->shortcuts_inhibitors, gdk_seat);
}
void
@@ -4130,14 +4302,14 @@ gdk_wayland_surface_inhibit_shortcuts (GdkSurface *surface,
if (display->keyboard_shortcuts_inhibit == NULL)
return;
if (gdk_wayland_surface_get_inhibitor (impl, seat))
return; /* Already inhibitted */
if (gdk_wayland_surface_get_inhibitor (impl, gdk_seat))
return; /* Already inhibited */
inhibitor =
zwp_keyboard_shortcuts_inhibit_manager_v1_inhibit_shortcuts (
display->keyboard_shortcuts_inhibit, wl_surface, seat);
g_hash_table_insert (impl->shortcuts_inhibitors, seat, inhibitor);
g_hash_table_insert (impl->shortcuts_inhibitors, gdk_seat, inhibitor);
}
void
@@ -4145,15 +4317,14 @@ gdk_wayland_surface_restore_shortcuts (GdkSurface *surface,
GdkSeat *gdk_seat)
{
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
struct wl_seat *seat = gdk_wayland_seat_get_wl_seat (gdk_seat);
struct zwp_keyboard_shortcuts_inhibitor_v1 *inhibitor;
inhibitor = gdk_wayland_surface_get_inhibitor (impl, seat);
inhibitor = gdk_wayland_surface_get_inhibitor (impl, gdk_seat);
if (inhibitor == NULL)
return; /* Not inhibitted */
zwp_keyboard_shortcuts_inhibitor_v1_destroy (inhibitor);
g_hash_table_remove (impl->shortcuts_inhibitors, seat);
g_hash_table_remove (impl->shortcuts_inhibitors, gdk_seat);
}
GdkSurface *
@@ -4170,22 +4341,6 @@ create_dnd_surface (GdkDisplay *display)
#define LAST_PROP 1
typedef struct
{
GdkWaylandSurface parent_instance;
} GdkWaylandPopup;
typedef struct
{
GdkWaylandSurfaceClass parent_class;
} GdkWaylandPopupClass;
static void gdk_wayland_popup_iface_init (GdkPopupInterface *iface);
G_DEFINE_TYPE_WITH_CODE (GdkWaylandPopup, gdk_wayland_popup, GDK_TYPE_WAYLAND_SURFACE,
G_IMPLEMENT_INTERFACE (GDK_TYPE_POPUP,
gdk_wayland_popup_iface_init))
static void
gdk_wayland_popup_init (GdkWaylandPopup *popup)
{
@@ -4295,22 +4450,6 @@ gdk_wayland_popup_iface_init (GdkPopupInterface *iface)
iface->get_position_y = gdk_wayland_popup_get_position_y;
}
typedef struct
{
GdkWaylandSurface parent_instance;
} GdkWaylandToplevel;
typedef struct
{
GdkWaylandSurfaceClass parent_class;
} GdkWaylandToplevelClass;
static void gdk_wayland_toplevel_iface_init (GdkToplevelInterface *iface);
G_DEFINE_TYPE_WITH_CODE (GdkWaylandToplevel, gdk_wayland_toplevel, GDK_TYPE_WAYLAND_SURFACE,
G_IMPLEMENT_INTERFACE (GDK_TYPE_TOPLEVEL,
gdk_wayland_toplevel_iface_init))
static void
gdk_wayland_toplevel_init (GdkWaylandToplevel *toplevel)
{
@@ -4323,6 +4462,7 @@ gdk_wayland_toplevel_set_property (GObject *object,
GParamSpec *pspec)
{
GdkSurface *surface = GDK_SURFACE (object);
GdkWaylandToplevel *toplevel = GDK_WAYLAND_TOPLEVEL (surface);
switch (prop_id)
{
@@ -4337,7 +4477,8 @@ gdk_wayland_toplevel_set_property (GObject *object,
break;
case LAST_PROP + GDK_TOPLEVEL_PROP_TRANSIENT_FOR:
gdk_wayland_surface_set_transient_for (surface, g_value_get_object (value));
gdk_wayland_toplevel_set_transient_for (toplevel,
g_value_get_object (value));
g_object_notify_by_pspec (G_OBJECT (surface), pspec);
break;
@@ -4360,6 +4501,9 @@ gdk_wayland_toplevel_set_property (GObject *object,
g_object_notify_by_pspec (G_OBJECT (surface), pspec);
break;
case LAST_PROP + GDK_TOPLEVEL_PROP_SHORTCUTS_INHIBITED:
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -4374,6 +4518,7 @@ gdk_wayland_toplevel_get_property (GObject *object,
{
GdkSurface *surface = GDK_SURFACE (object);
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
GdkWaylandToplevel *toplevel = GDK_WAYLAND_TOPLEVEL (surface);
switch (prop_id)
{
@@ -4390,7 +4535,7 @@ gdk_wayland_toplevel_get_property (GObject *object,
break;
case LAST_PROP + GDK_TOPLEVEL_PROP_TRANSIENT_FOR:
g_value_set_object (value, impl->transient_for);
g_value_set_object (value, toplevel->transient_for);
break;
case LAST_PROP + GDK_TOPLEVEL_PROP_MODAL:
@@ -4411,6 +4556,10 @@ gdk_wayland_toplevel_get_property (GObject *object,
g_value_set_enum (value, surface->fullscreen_mode);
break;
case LAST_PROP + GDK_TOPLEVEL_PROP_SHORTCUTS_INHIBITED:
g_value_set_boolean (value, surface->shortcuts_inhibited);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -4534,6 +4683,70 @@ gdk_wayland_toplevel_supports_edge_constraints (GdkToplevel *toplevel)
return gdk_wayland_surface_supports_edge_constraints (GDK_SURFACE (toplevel));
}
static void
inhibitor_active (void *data,
struct zwp_keyboard_shortcuts_inhibitor_v1 *inhibitor)
{
GdkToplevel *toplevel = GDK_TOPLEVEL (data);
GdkSurface *surface = GDK_SURFACE (toplevel);
surface->shortcuts_inhibited = TRUE;
g_object_notify (G_OBJECT (toplevel), "shortcuts-inhibited");
}
static void
inhibitor_inactive (void *data,
struct zwp_keyboard_shortcuts_inhibitor_v1 *inhibitor)
{
GdkToplevel *toplevel = GDK_TOPLEVEL (data);
GdkSurface *surface = GDK_SURFACE (toplevel);
surface->shortcuts_inhibited = FALSE;
g_object_notify (G_OBJECT (toplevel), "shortcuts-inhibited");
}
static const struct zwp_keyboard_shortcuts_inhibitor_v1_listener
zwp_keyboard_shortcuts_inhibitor_listener = {
inhibitor_active,
inhibitor_inactive,
};
static void
gdk_wayland_toplevel_inhibit_system_shortcuts (GdkToplevel *toplevel,
GdkEvent *event)
{
struct zwp_keyboard_shortcuts_inhibitor_v1 *inhibitor;
GdkSurface *surface = GDK_SURFACE (toplevel);
GdkWaylandSurface *impl= GDK_WAYLAND_SURFACE (surface);
GdkSeat *gdk_seat;
if (surface->shortcuts_inhibited)
return;
gdk_seat = gdk_surface_get_seat_from_event (surface, event);
gdk_wayland_surface_inhibit_shortcuts (surface, gdk_seat);
inhibitor = gdk_wayland_surface_get_inhibitor (impl, gdk_seat);
if (!inhibitor)
return;
surface->current_shortcuts_inhibited_seat = gdk_seat;
zwp_keyboard_shortcuts_inhibitor_v1_add_listener
(inhibitor, &zwp_keyboard_shortcuts_inhibitor_listener, toplevel);
}
static void
gdk_wayland_toplevel_restore_system_shortcuts (GdkToplevel *toplevel)
{
GdkSurface *surface = GDK_SURFACE (toplevel);
gdk_wayland_surface_restore_shortcuts (surface,
surface->current_shortcuts_inhibited_seat);
surface->current_shortcuts_inhibited_seat = NULL;
surface->shortcuts_inhibited = FALSE;
g_object_notify (G_OBJECT (toplevel), "shortcuts-inhibited");
}
static void
gdk_wayland_toplevel_iface_init (GdkToplevelInterface *iface)
{
@@ -4543,24 +4756,10 @@ gdk_wayland_toplevel_iface_init (GdkToplevelInterface *iface)
iface->focus = gdk_wayland_toplevel_focus;
iface->show_window_menu = gdk_wayland_toplevel_show_window_menu;
iface->supports_edge_constraints = gdk_wayland_toplevel_supports_edge_constraints;
iface->inhibit_system_shortcuts = gdk_wayland_toplevel_inhibit_system_shortcuts;
iface->restore_system_shortcuts = gdk_wayland_toplevel_restore_system_shortcuts;
}
typedef struct
{
GdkWaylandSurface parent_instance;
} GdkWaylandDragSurface;
typedef struct
{
GdkWaylandSurfaceClass parent_class;
} GdkWaylandDragSurfaceClass;
static void gdk_wayland_drag_surface_iface_init (GdkDragSurfaceInterface *iface);
G_DEFINE_TYPE_WITH_CODE (GdkWaylandDragSurface, gdk_wayland_drag_surface, GDK_TYPE_WAYLAND_SURFACE,
G_IMPLEMENT_INTERFACE (GDK_TYPE_DRAG_SURFACE,
gdk_wayland_drag_surface_iface_init))
static void
gdk_wayland_drag_surface_init (GdkWaylandDragSurface *surface)
{
+3 -7
View File
@@ -37,10 +37,6 @@ gdk_wayland_deps = [
wlegldep,
]
# wayland protocols
proto_dir = dependency('wayland-protocols').get_pkgconfig_variable('pkgdatadir')
assert(proto_dir != '', 'Could not get pkgdatadir from wayland-protocols.pc')
wayland_scanner = find_program('wayland-scanner')
# Format:
@@ -68,14 +64,14 @@ foreach p: proto_sources
if proto_stability == 'stable'
output_base = proto_name
input = join_paths(proto_dir, '@0@/@1@/@2@.xml'.format(proto_stability, proto_name, output_base))
input = files(join_paths(wlproto_dir, '@0@/@1@/@2@.xml'.format(proto_stability, proto_name, output_base)))
elif proto_stability == 'private'
output_base = proto_name
input = 'protocol/@0@.xml'.format(proto_name)
input = files('protocol/@0@.xml'.format(proto_name))
else
proto_version = p.get(2)
output_base = '@0@-@1@-@2@'.format(proto_name, proto_stability, proto_version)
input = join_paths(proto_dir, '@0@/@1@/@2@.xml'.format(proto_stability, proto_name, output_base))
input = files(join_paths(wlproto_dir, '@0@/@1@/@2@.xml'.format(proto_stability, proto_name, output_base)))
endif
gdk_wayland_gen_headers += custom_target('@0@ client header'.format(output_base),
+1 -1
View File
@@ -79,7 +79,7 @@ get_current_mask (void)
if (kbd[VK_CONTROL] & 0x80)
mask |= GDK_CONTROL_MASK;
if (kbd[VK_MENU] & 0x80)
mask |= GDK_MOD1_MASK;
mask |= GDK_ALT_MASK;
if (kbd[VK_LBUTTON] & 0x80)
mask |= GDK_BUTTON1_MASK;
if (kbd[VK_MBUTTON] & 0x80)
+1 -1
View File
@@ -54,7 +54,7 @@ get_current_mask (void)
if (kbd[VK_CONTROL] & 0x80)
mask |= GDK_CONTROL_MASK;
if (kbd[VK_MENU] & 0x80)
mask |= GDK_MOD1_MASK;
mask |= GDK_ALT_MASK;
if (kbd[VK_LBUTTON] & 0x80)
mask |= GDK_BUTTON1_MASK;
if (kbd[VK_MBUTTON] & 0x80)
+1 -1
View File
@@ -844,7 +844,7 @@ get_modifier_key_state (void)
if (GetKeyState (VK_SHIFT) < 0)
state |= GDK_SHIFT_MASK;
if (GetKeyState (VK_MENU) < 0)
state |= GDK_MOD1_MASK;
state |= GDK_ALT_MASK;
if (GetKeyState (VK_CAPITAL) & 0x1)
state |= GDK_LOCK_MASK;
+5 -5
View File
@@ -1869,7 +1869,7 @@ manufacture_keystate_from_GMT (GdkModifierType state)
{
DWORD key_state = 0;
if (state & GDK_MOD1_MASK)
if (state & GDK_ALT_MASK)
key_state |= MK_ALT;
if (state & GDK_CONTROL_MASK)
key_state |= MK_CONTROL;
@@ -2415,22 +2415,22 @@ gdk_dnd_handle_key_event (GdkDrag *drag,
case GDK_KEY_Up:
case GDK_KEY_KP_Up:
dy = (state & GDK_MOD1_MASK) ? -BIG_STEP : -SMALL_STEP;
dy = (state & GDK_ALT_MASK) ? -BIG_STEP : -SMALL_STEP;
break;
case GDK_KEY_Down:
case GDK_KEY_KP_Down:
dy = (state & GDK_MOD1_MASK) ? BIG_STEP : SMALL_STEP;
dy = (state & GDK_ALT_MASK) ? BIG_STEP : SMALL_STEP;
break;
case GDK_KEY_Left:
case GDK_KEY_KP_Left:
dx = (state & GDK_MOD1_MASK) ? -BIG_STEP : -SMALL_STEP;
dx = (state & GDK_ALT_MASK) ? -BIG_STEP : -SMALL_STEP;
break;
case GDK_KEY_Right:
case GDK_KEY_KP_Right:
dx = (state & GDK_MOD1_MASK) ? BIG_STEP : SMALL_STEP;
dx = (state & GDK_ALT_MASK) ? BIG_STEP : SMALL_STEP;
break;
}
}
+35 -28
View File
@@ -72,6 +72,8 @@
#include <imm.h>
#define GDK_MOD2_MASK (1 << 4)
#ifndef XBUTTON1
#define XBUTTON1 1
#define XBUTTON2 2
@@ -662,14 +664,14 @@ build_key_event_state (BYTE *key_state)
if (key_state[VK_RCONTROL] & 0x80)
state |= GDK_CONTROL_MASK;
if (key_state[VK_LMENU] & 0x80)
state |= GDK_MOD1_MASK;
state |= GDK_ALT_MASK;
}
else
{
if (key_state[VK_CONTROL] & 0x80)
state |= GDK_CONTROL_MASK;
if (key_state[VK_MENU] & 0x80)
state |= GDK_MOD1_MASK;
state |= GDK_ALT_MASK;
}
return state;
@@ -724,7 +726,7 @@ build_pointer_event_state (MSG *msg)
state |= GDK_SHIFT_MASK;
if (GetKeyState (VK_MENU) < 0)
state |= GDK_MOD1_MASK;
state |= GDK_ALT_MASK;
if (GetKeyState (VK_CAPITAL) & 0x1)
state |= GDK_LOCK_MASK;
@@ -741,11 +743,8 @@ print_event_state (guint state)
CASE (SHIFT);
CASE (LOCK);
CASE (CONTROL);
CASE (MOD1);
CASE (ALT);
CASE (MOD2);
CASE (MOD3);
CASE (MOD4);
CASE (MOD5);
CASE (BUTTON1);
CASE (BUTTON2);
CASE (BUTTON3);
@@ -810,7 +809,7 @@ _gdk_win32_print_event (GdkEvent *event)
kvname = gdk_keyval_name (gdk_key_event_get_keyval (event));
g_print ("%#.02x group:%d %s",
gdk_key_event_get_keycode (event),
gdk_key_event_get_group (event),
gdk_key_event_get_layout (event),
(kvname ? kvname : "??"));
print_event_state (gdk_event_get_modifier_state (event));
break;
@@ -2051,12 +2050,12 @@ gdk_event_translate (MSG *msg,
GdkModifierType state;
guint keyval;
guint16 keycode;
guint16 scancode;
guint8 group;
gboolean is_modifier;
double delta_x, delta_y;
GdkScrollDirection direction;
GdkTranslatedKey translated;
display = gdk_display_get_default ();
win32_display = GDK_WIN32_DISPLAY (display);
@@ -2130,17 +2129,20 @@ gdk_event_translate (MSG *msg,
gdk_display_setting_changed (display, "gtk-im-module");
/* Generate a dummy key event to "nudge" IMContext */
translated.keyval = GDK_KEY_VoidSymbol;
translated.consumed = 0;
translated.layout = 0;
translated.level = 0;
event = gdk_event_key_new (GDK_KEY_PRESS,
window,
device_manager_win32->core_keyboard,
device_manager_win32->system_keyboard,
_gdk_win32_get_next_tick (msg->time),
0,
GDK_KEY_VoidSymbol,
0,
0,
0,
FALSE);
FALSE,
&translated,
&translated);
_gdk_win32_append_event (event);
break;
@@ -2226,7 +2228,6 @@ gdk_event_translate (MSG *msg,
keyval = GDK_KEY_VoidSymbol;
keycode = msg->wParam;
scancode = msg->lParam >> 16;
if (HIWORD (msg->lParam) & KF_EXTENDED)
{
@@ -2326,10 +2327,15 @@ gdk_event_translate (MSG *msg,
both_shift_pressed[0] = both_shift_pressed[1] = 0;
}
/* Reset MOD1_MASK if it is the Alt key itself */
/* Reset ALT_MASK if it is the Alt key itself */
if (msg->wParam == VK_MENU)
state &= ~GDK_MOD1_MASK;
state &= ~GDK_ALT_MASK;
/* FIXME do proper translation */
translated.keyval = keyval;
translated.consumed = 0;
translated.layout = group;
translated.level = 0;
event = gdk_event_key_new ((msg->message == WM_KEYDOWN || msg->message == WM_SYSKEYDOWN)
? GDK_KEY_PRESS
: GDK_KEY_RELEASE,
@@ -2338,11 +2344,10 @@ gdk_event_translate (MSG *msg,
device_manager_win32->system_keyboard,
_gdk_win32_get_next_tick (msg->time),
state,
keyval,
keycode,
scancode,
group,
is_modifier);
is_modifier,
&translated,
&translated);
_gdk_win32_append_event (event);
@@ -2404,17 +2409,20 @@ gdk_event_translate (MSG *msg,
for (i = 0; i < ccount; i++)
{
/* Build a key press event */
translated.keyval = gdk_unicode_to_keyval (wbuf[i]);
translated.consumed = 0;
translated.layout = get_active_group ();
translated.level = 0;
event = gdk_event_key_new (GDK_KEY_PRESS,
window,
device_manager_win32->core_keyboard,
device_manager_win32->system_keyboard,
_gdk_win32_get_next_tick (msg->time),
build_key_event_state (key_state),
gdk_unicode_to_keyval (wbuf[i]),
0,
0,
get_active_group (),
FALSE);
FALSE,
&translated,
&translated);
_gdk_win32_append_event (event);
@@ -2425,11 +2433,10 @@ gdk_event_translate (MSG *msg,
device_manager_win32->system_keyboard,
_gdk_win32_get_next_tick (msg->time),
build_key_event_state (key_state),
gdk_unicode_to_keyval (wbuf[i]),
0,
0,
get_active_group (),
FALSE);
FALSE,
&translated,
&translated);
_gdk_win32_append_event (event);
}
+2 -16
View File
@@ -38,6 +38,8 @@
#include "gdkkeysprivate.h"
#include "gdkwin32keys.h"
#define GDK_MOD2_MASK (1 << 4)
enum _GdkWin32KeyLevelState
{
GDK_WIN32_LEVEL_NONE = 0,
@@ -1671,20 +1673,6 @@ gdk_win32_keymap_translate_keyboard_state (GdkKeymap *gdk_keymap,
return tmp_keyval != GDK_KEY_VoidSymbol;
}
static void
gdk_win32_keymap_add_virtual_modifiers (GdkKeymap *keymap,
GdkModifierType *state)
{
}
static gboolean
gdk_win32_keymap_map_virtual_modifiers (GdkKeymap *keymap,
GdkModifierType *state)
{
/* FIXME: Is this the right thing to do? */
return TRUE;
}
static void
gdk_win32_keymap_class_init (GdkWin32KeymapClass *klass)
{
@@ -1702,6 +1690,4 @@ gdk_win32_keymap_class_init (GdkWin32KeymapClass *klass)
keymap_class->get_entries_for_keycode = gdk_win32_keymap_get_entries_for_keycode;
keymap_class->lookup_key = gdk_win32_keymap_lookup_key;
keymap_class->translate_keyboard_state = gdk_win32_keymap_translate_keyboard_state;
keymap_class->add_virtual_modifiers = gdk_win32_keymap_add_virtual_modifiers;
keymap_class->map_virtual_modifiers = gdk_win32_keymap_map_virtual_modifiers;
}
+2 -2
View File
@@ -288,10 +288,10 @@ extern UINT _gdk_input_codepage;
extern guint _gdk_keymap_serial;
/* The singleton clipdrop object pointer */
GdkWin32Clipdrop *_win32_clipdrop;
extern GdkWin32Clipdrop *_win32_clipdrop;
/* Used to identify the main thread */
GThread *_win32_main_thread;
extern GThread *_win32_main_thread;
void _gdk_win32_dnd_do_dragdrop (void);
+7
View File
@@ -4907,6 +4907,9 @@ gdk_win32_toplevel_set_property (GObject *object,
g_object_notify_by_pspec (G_OBJECT (surface), pspec);
break;
case LAST_PROP + GDK_TOPLEVEL_PROP_SHORTCUTS_INHIBITED:
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -4953,6 +4956,10 @@ gdk_win32_toplevel_get_property (GObject *object,
g_value_set_enum (value, surface->fullscreen_mode);
break;
case LAST_PROP + GDK_TOPLEVEL_PROP_SHORTCUTS_INHIBITED:
g_value_set_boolean (value, surface->shortcuts_inhibited);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;

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