Compare commits

...

133 Commits

Author SHA1 Message Date
Robert Ancell
08b276a6d4 Update to GDK 3.12 API 2014-06-17 14:06:54 +12:00
Robert Ancell
e6289f6169 Fix some transient window issues 2014-06-17 13:49:01 +12:00
Robert Ancell
bf6743712d Add some more debugging info 2014-06-17 13:48:58 +12:00
Robert Ancell
7ce746b9a5 Don't create surfaces for input only windows 2014-06-17 13:48:56 +12:00
Robert Ancell
ddd9718cde Don't crash on unknown properties 2014-06-17 13:48:53 +12:00
Robert Ancell
0c69298c1c Move debugging into a separate file 2014-06-17 13:48:51 +12:00
Robert Ancell
1104088cbf Regenerate surface on resize 2014-06-17 13:48:48 +12:00
Robert Ancell
ce50fc001a Make GdkMirWindowImpl private again 2014-06-17 13:48:45 +12:00
Robert Ancell
2e8f42da85 Unref window when pointer object is finalized 2014-06-17 13:48:42 +12:00
Robert Ancell
73864a350b Draw transient windows onto their parents 2014-06-17 13:48:37 +12:00
Robert Ancell
f3f5b6bd02 Whoops, I forgot the magic 8 2014-06-17 13:46:31 +12:00
Robert Ancell
0835964a3d Provide gtk-error-bell setting 2014-06-17 13:46:29 +12:00
Ryan Lortie
3b2cd941e3 mir: more gtksettings... 2014-06-17 13:46:26 +12:00
Ryan Lortie
e8d7fa2d32 mir: handle resize events
...including the possibility that we don't receive the buffer size that
we request.
2014-06-17 13:46:24 +12:00
Ryan Lortie
a514240b72 build: add mir .pc files to distclean 2014-06-17 13:46:21 +12:00
Ryan Lortie
5ae4249f37 mir: one more gtksetting... 2014-06-17 13:46:18 +12:00
Ryan Lortie
6e2230b270 mir: set core pointer on GdkDisplay 2014-06-17 13:46:16 +12:00
Ryan Lortie
8eafde7353 mir: one more gtksetting... 2014-06-17 13:46:09 +12:00
Ryan Lortie
582231fe18 mir: allow windows to become focused
Send focus change events to toplevels in response to getting the event
from mir.

Now that the window is focused, cursor blink works, so wire up those
GtkSettings as well.
2014-06-17 13:46:07 +12:00
Ryan Lortie
4073e6b3f5 mir: fill in some more GtkSettings
...and add an assert for those we don't handle.
2014-06-17 13:46:04 +12:00
Robert Ancell
2ffc1945ad Correct spelling of Ambiance theme (still doesn't work though) 2014-06-17 13:46:01 +12:00
Ryan Lortie
d3566a9370 mir: we must leak the window ref for now
By the time we get the call to ensure_no_surface() the window is already
being disposed and the qdata is gone.  Our attempt to free the copy of
the ref owned by Mir by looking it up again from our qdata will fail.
2014-06-17 13:45:59 +12:00
Robert Ancell
f7fb50be8d Set KeyEvent string field 2014-06-17 13:45:57 +12:00
Ryan Lortie
f0bc0d955d mir: do proper event dispatching
We had a race where destroying a window while an event is being
dispatched to it could result in a crash.  We can't just hold a ref on
the window because the object is externally visible and we could end up
running a binding's toggle ref handler in the mir thread.

Add a proper source type with a queue and try to do this properly by
dispatching the event back to the main thread before we check if the
window still exists (through use of a weak ref).

This commit also moves all of the event translation code out of
gdkmirwindowimpl.c (which is getting a bit big...).
2014-06-17 13:45:54 +12:00
Robert Ancell
86623e1514 Counter suspicious hover-exit events 2014-06-17 13:45:52 +12:00
Robert Ancell
e40795cbff Generate crossing events 2014-06-17 13:45:50 +12:00
Robert Ancell
2c6694dbd7 Let GDK decide if it wants events, ignore the event mask 2014-06-17 13:45:47 +12:00
Robert Ancell
09f81372c0 Remove debugging 2014-06-17 13:45:45 +12:00
Robert Ancell
bc1328f7ae Correctly hide windows 2014-06-17 13:45:42 +12:00
Robert Ancell
610b1bd561 Handle Mir events on the main thread 2014-06-17 13:45:38 +12:00
Robert Ancell
bfa2bedda0 Finalize MirWindowImpl values 2014-06-17 13:45:35 +12:00
Robert Ancell
ee65b232d8 Implement gdk_mir_window_impl_get_device_state 2014-06-17 13:45:33 +12:00
Robert Ancell
b73b191e08 Get menus working (sort of) 2014-06-17 13:45:30 +12:00
Robert Ancell
40207471d5 Fix return windows in gdk_mir_pointer_query_state 2014-06-17 13:45:28 +12:00
Robert Ancell
3e4167f06e Use event queue (sort of) correctly 2014-06-17 13:45:25 +12:00
Robert Ancell
0022c25ab6 Disable debugging message 2014-06-17 13:45:23 +12:00
Robert Ancell
bd0e083ef2 Disable debugging message 2014-06-17 13:45:20 +12:00
Robert Ancell
5cea3ab1f3 Flesh out keymap 2014-06-17 13:45:17 +12:00
Robert Ancell
674672dd66 Emit events 2014-06-17 13:45:15 +12:00
Robert Ancell
7b9afbd5a0 Don't set send_event, make public function private 2014-06-17 13:45:12 +12:00
Robert Ancell
da9db83702 Link associated devices 2014-06-17 13:45:09 +12:00
Robert Ancell
469dad556a Make separate keyboard and pointer device classes 2014-06-17 13:45:06 +12:00
Robert Ancell
5628a398ab Set initial window event mask, don't set event variables we don't need 2014-06-17 13:44:53 +12:00
Robert Ancell
eaff88f0ec Set more event fields 2014-06-17 13:44:50 +12:00
Ryan Lortie
4e829c244e mir: create devices from _constructed
The "display" property is not yet set at time of _init.
2014-06-17 13:44:46 +12:00
Robert Ancell
99310900bf Stub Mir module 2014-06-17 13:44:38 +12:00
Ryan Lortie
ec68c85c52 Revert "GtkMenuTracker: fix signal handler argument list"
This reverts commit f15f13a0fb.

This fix applied on master but it makes no sense here (where we have an
actual signal rather than just a property notify).
2014-06-10 11:04:18 -04:00
Joanmarie Diggs
c9e110870e GtkEntryAccessible: Emit signal after insertion
The signal needs to be emitted after the text insertion as at-spi gets
the text to compute the inserted text due to the AtkText::insert-text
signal not containing it.
Also adjust position to reflect changes to the offsets.

https://bugzilla.gnome.org/show_bug.cgi?id=731429
2014-06-10 01:14:29 +02:00
Chun-wei Fan
d2c8f0a84b MSVC 2010+ Projects: Update "Installation" Process
Currently, due to the way that Visual Studio 2010+ projects are handled,
the "install" project does not re-build upon changes to the sources, as it
does not believe that its dependencies have changed, although the changed
sources are automatically recompiled.  This means that if a part or more
of the solution does not build, or if the sources need some other fixes
or enhancements, the up-to-date build is not copied automatically, which
can be misleading.

Improve on the situation by forcing the "install" project to trigger its
rebuild, so that the updated binaries can be copied.  This does trigger an
MSBuild warning, but having that warning is way better than not having an
up-to-date build, especially during testing and development.
2014-06-09 12:11:24 +08:00
Carlos Garnacho
d6c1a6280d combobox: Fix reentrancy in gtk_combo_box_popdown()
If called when already popped down, warnings would be issued due
to priv->grab_pointer being unexpectedly NULL, this would happen
in regular operation when selecting items in appears-as-list mode.

So both add a NULL check for priv->grab_pointer, and bail out early
if the popup window is already hidden.
2014-06-05 21:18:22 +02:00
Ryan Lortie
f15f13a0fb GtkMenuTracker: fix signal handler argument list
The signal handler for the visibility of menu items changing had the
wrong signature, resulting in the GParamSpec from the notify signal
being treated as a boolean (which was always true).  This resulted in
items being added over and over and never being removed.

Fix that...
2014-06-05 08:30:16 -04:00
Yuri Myasoedov
dc9d8e9202 Updated Russian translation 2014-05-19 21:42:45 +04:00
GunChleoc
350e76ae48 Updated Scottish Gaelic translation 2014-05-19 08:56:00 +00:00
Chun-wei Fan
d917bdc836 gdkselection-win32.c: Declare Variables At Top Of Block
...so that builds on Visual C++ can be fixed.
2014-05-16 12:23:52 +08:00
Owen W. Taylor
84f6eefec8 GtkPopover: inherit actions from the relative_to widget
Make the relative_to widget the parent for a GtkPopover's
GtkActionGroup. This, for example, makes the menu model of a
GtkMenuButton find action groups attached to the button.

https://bugzilla.gnome.org/show_bug.cgi?id=729915
2014-05-12 16:44:12 -04:00
Matthias Clasen
d80ef2f827 Bump version 2014-05-12 11:20:26 -04:00
Matthias Clasen
234fec14f3 3.12.2 2014-05-12 08:53:17 -04:00
Matthias Clasen
c6c2408a8d GtkIconFactory: Remove outdated information from the docs
The stock browser was removed from gtk3-demo.
2014-05-12 07:54:24 -04:00
Matthias Clasen
67b2f0c9b4 Bloatpad: port to new accel api 2014-05-12 07:41:50 -04:00
Matthias Clasen
e8cccbb55c a11y: Avoid a warning
The listbox row accessible code was giving warnings when
parent is NULL, at destruction time.
2014-05-12 07:41:33 -04:00
Benjamin Otte
492b732872 applicationwindow: Properly unmap the menubar widget 2014-05-12 07:41:03 -04:00
Matthias Clasen
392c9a46ad GtkApplication: Clarify docs a bit
Explicitly mention how gtk_application_set_accels_for_action can
be used to remove all accelerators for an action.

https://bugzilla.gnome.org/show_bug.cgi?id=729451
2014-05-12 07:40:44 -04:00
Matthias Clasen
58a740b29a GtkSearchBar: fix the template
There was a mismatch between GtkSearchBar being derived from GtkBin
and the template claiming the parent to be GtkBox.
2014-05-12 07:39:04 -04:00
Matthias Clasen
a1a6ef613e Raleigh: fix a typo 2014-05-12 07:37:34 -04:00
Matthias Clasen
123b424fb7 Add Adwaita to the list of default icon themes
Hardcode the fallback to Adwaita. I'm leaving gnome in here for
now, since we're in the middle of the transition. It will be
removed before 3.14.
2014-05-12 07:36:42 -04:00
Antoine Jacoutot
d3c096e0cc broadway backend: allow building on OpenBSD
On OpenBSD shm_open(3) is part of libc and there is not librt, so add an
according check.
Check if we have posix_fallocate before using it.

https://bugzilla.gnome.org/show_bug.cgi?id=728272
2014-05-12 07:30:22 -04:00
Matthias Clasen
da55db257c example: Update screenshots 2014-05-12 07:30:09 -04:00
Matthias Clasen
27387a0944 example: Use popover for gears menu 2014-05-12 07:30:03 -04:00
Matthias Clasen
274a8d3774 example: Make gears button square
Another application of image-button.
2014-05-12 07:29:55 -04:00
Matthias Clasen
ce1938651a example: Make search button square
The image-button style class takes care of it.
2014-05-12 07:29:49 -04:00
Matthias Clasen
063aa29f4b example: Modernize the prefs dialog
We should show the current best practice for this kind of
dialog, and use a headerbar with a window close button.
2014-05-12 07:29:42 -04:00
Matthias Clasen
c80892c3f2 example: Port to gtk_application_set_accels_for_action
Instead of hardcoding an accelerator in the ui file, use
gtk_application_set_accels_for_action.
2014-05-12 07:29:33 -04:00
Matthias Clasen
2a0167f82c example: Fix indentation 2014-05-12 07:29:24 -04:00
Matthias Clasen
9d44ec92e5 example: Fix up margins
This makes the code match what we show in the screenshots. This
broke when headerbars were changed to allow titles to extend into
the margin.
2014-05-12 07:27:15 -04:00
Matthias Clasen
1cb15abce9 example: Don't set a nonexisting property
The GtkHeaderBar::show-fallback-app-menu property does not exist,
and isn't needed anyway.
2014-05-12 07:27:08 -04:00
Marcus Karlsson
eb67f0208b GtkColorChooserWidget: Redraw swatches when selection changes
When selecting a swatch in a GtkColorChooserWidget the previously
selected swatch and the currently selected swatch are not redrawn. This
can leave the old swatch still marked with a checkbox even though a new
swatch has been selected.

Redraw the swatches after changing the selection.

https://bugzilla.gnome.org/show_bug.cgi?id=727487
2014-05-12 07:18:56 -04:00
Marcus Karlsson
45e65f2d49 docs: Add missing transfer annotation to GtkBox
The gtk_box_get_center_widget function is missing a transfer annotation
for the returned widget. No transfer is done, so set transfer to none.

https://bugzilla.gnome.org/show_bug.cgi?id=728093
2014-05-12 07:16:49 -04:00
Matthias Clasen
605a8fc158 gtk-demo: Fix images demo
The incremental loading was broken by GtkIconHelper - queuing a
redraw is no longer sufficient to cause GtkImage to redraw with
the new pixbuf contents.
Pointed out by Jasper St. Pierre.
2014-05-12 07:16:35 -04:00
Matthias Clasen
c435ca8913 gtk-demo: Fix the links example
The keynav dialog is transient to the example window; since the
example window is now modal, we need to make the keynav dialog
modal as well, so it can receive input.
Problem pointed out by Jasper St. Pierre.
2014-05-12 07:16:29 -04:00
Jiro Matsuzawa
26a1a824eb l10n: Update Japanese translation 2014-05-12 08:32:56 +09:00
David Mansfield
7451b48708 GdkCursor: Don't leak a cairo surface
The function gdk_cursor_new_from_pixbuf creates a cairo surface
to pass to its backend implementation, but doesn't destroy it
afterwards.
https://bugzilla.gnome.org/show_bug.cgi?id=729670
2014-05-07 19:38:47 -04:00
Ihar Hrachyshka
5b651d0dae Updated Belarusian translation 2014-05-04 22:05:50 +00:00
Paolo Borelli
7ff1142ee9 listbox: check gsequence end iter in get_row_at_index 2014-05-04 19:59:16 +02:00
Руслан Ижбулатов
affd7c1d9d W32: Add a theme for .app-notification
This is copied from Adwaita. Looks sufficiently ok.

https://bugzilla.gnome.org/show_bug.cgi?id=729346
2014-05-01 17:56:33 +00:00
Piotr Drąg
3a0b78fd98 Updated POTFILES.skip 2014-04-30 22:14:24 +02:00
Benjamin Otte
5eb6f4d2ab reftests: Add test for latest commit
Check that the label gets linebroken properly.
2014-04-29 19:48:35 +02:00
Benjamin Otte
35aec354d7 window: Subtract shadow from passed in width for height
... and height for width in size requests. Fixes mislayout in
control-center universal access panel.
2014-04-29 19:48:29 +02:00
Alexander Larsson
281ca4905a treeview: Fix prelight redraw when adjustment changes
When the adjustment changes (due to e.g. a mouse wheel scroll) we update
the prelight. The part that un-prelights the previous prelight was
broken by the the pixel cache, as it called update_prelight in the
middle of the scrolling operation, where the windows were moved
but the tree_view->priv->dy was not changed to the new value. This
caused the updates to the pixel cache to go to the wrong place.

We fix this by fully doing the scroll before we update_prelight().

https://bugzilla.gnome.org/show_bug.cgi?id=728284
2014-04-29 09:36:00 +02:00
Juan Pablo Ugarte
e9ba546203 GtkRecentChooserMenu: Set current uri before activating an item.
When activating an item using mnemonics GtkRecentChooserMenu does not select a
item before calling the item-activated signal thus
gtk_recent_chooser_get_current_uri() always return the last selected item
instead of the activated one.

Fixes Bug 495105 "Open recent file keyboard shortcuts do not work correctly"
2014-04-28 17:19:08 -03:00
Matej Urbančič
40926214c7 Updated Slovenian translation 2014-04-28 21:10:48 +02:00
Matej Urbančič
69b8aa8fcf Updated Slovenian translation 2014-04-28 21:07:27 +02:00
Руслан Ижбулатов
b99b0257c9 W32: Update the css to match the .modelbutton->.button.menuitem transition 2014-04-28 16:04:02 +00:00
Matthias Clasen
ee9454ce55 Rename the modelbutton style class
This is not a great name to use in themes; instead, add the
menuitem class, so themes can use .button.menuitem for styles
that are specific to menuitem-like buttons.
2014-04-27 18:51:03 -04:00
Juan Pablo Ugarte
539f18f998 Fixed crash in GtkLockButton if a button with permission set to NULL is clicked.
https://bugzilla.gnome.org/show_bug.cgi?id=728992
2014-04-25 22:20:39 -04:00
Matthias Clasen
01dac000a6 GtkWindow: Avoid a critical in F10 handling
The focus widget might be NULL, and we were forgetting to take
that possibility into account in one place.
2014-04-25 22:20:31 -04:00
Antoine Jacoutot
c478e31448 openbsd: properly set len for gtkmountoperation-x11
sysctl(3) is the correct way to get the lenght for len in this case.
Also drop unused headers and change style to match the rest of the file.
2014-04-25 22:20:10 -04:00
Marc-André Lureau
313714c1e1 gdk/win32: VK_SNAPSHOT maps to GDK_Print
Also, I am not sure the above VK_PRINT -> GDK_Print mapping is
correct, but it doesn't hurt yet.

https://bugzilla.gnome.org/show_bug.cgi?id=686170
2014-04-25 22:19:58 -04:00
Marc-André Lureau
208b9f0bbe win32: add more clipboard data checks to avoid crash
It may happen that the received clipboard data is empty, but
if it's of type image/bmp, gtk+ will crash:

gdk_property_change: 00030AD4 GDK_SELECTION image/bmp REPLACE 8*0 bits:
... delayed rendering
gdk_selection_send_notify_for_display: 00030AD4 CLIPBOARD image/bmp
GDK_SELECTION (no-op)
_gdk_win32_selection_convert_to_dib: 1252003C image/bmp

Program received signal SIGSEGV, Segmentation fault.
0x749a9f40 in msvcrt!memmove () from C:\Windows\syswow64\msvcrt.dll

Thread 1 (Thread 2248.0x1b34):
target=0xc07b) at gdkselection-win32.c:1292
at gdkevents-win32.c:3498
wparam=8, lparam=0) at gdkevents-win32.c:232
message=773, wparam=8, lparam=0)
    at gdkevents-win32.c:263
C:\Windows\syswow64\user32.dll
C:\Users\rugoosse\AppData\Local\virt-viewer\bin\libpangocairo-1.0-0.dll
wparam=0, lparam=-1687549457)
    at gdkevents-win32.c:248
C:\Users\rugoosse\AppData\Local\virt-viewer\bin\libpangocairo-1.0-0.dll

https://bugzilla.gnome.org/show_bug.cgi?id=728745
2014-04-25 22:19:49 -04:00
Matthias Clasen
fc34b4a2e3 DND: go back to a timeout for cancel animation
Using a tick callback does not really make sense here, since we
are not drawing in a window, but moving a toplevel around.
https://bugzilla.gnome.org/show_bug.cgi?id=728183
2014-04-25 22:19:26 -04:00
Jasper St. Pierre
3b0f7eb23e gtk-demo: Make sure to clear the timeout when we stop it 2014-04-25 22:18:52 -04:00
Matthias Clasen
4ccc2494b3 csd: Fix drag hightlight drawing
When making the entire window a drop target, as file-roller does,
we don't want to draw the drag highlight around the CSD window
decorations.
https://bugzilla.gnome.org/show_bug.cgi?id=728526
2014-04-25 22:17:53 -04:00
Руслан Ижбулатов
cb727c88dc W32: Add modelbutton styles
According to what i've been told, modelbuttons are supposed to look
flat, like menu items.

This is basically an improved copy of the menuitem styles.

https://bugzilla.gnome.org/show_bug.cgi?id=728810
2014-04-24 03:46:29 +00:00
Руслан Ижбулатов
f9375b1f6f W32: Add a set of "focused" styles to checkmarks
This prevents checkmarks in modelbuttons from being styled as buttons
(apparently, modelbuttons apply "focused" to their children, unlike
normal buttons).

https://bugzilla.gnome.org/show_bug.cgi?id=728808
2014-04-24 03:46:29 +00:00
Руслан Ижбулатов
a5ac6bb48a W32: Fix dummy prelight style for check/radio buttons
Use a dummy transparent gradient instead of actual color (which screws up
focus rectangle on prelight), and apply to non-prelight state as well.

https://bugzilla.gnome.org/show_bug.cgi?id=728807
2014-04-24 03:46:28 +00:00
Руслан Ижбулатов
fff108dd0a W32: remove the blue "selected" rectangle when activating a checkbutton
https://bugzilla.gnome.org/show_bug.cgi?id=728806
2014-04-24 03:46:28 +00:00
Matthias Clasen
37799e1b97 GtkScaleButton: Don't specify a icon size of zero
This only works for scalable icons, but breaks if we fall
back to pngs.
2014-04-22 18:34:35 -04:00
Matthias Clasen
f8aab7f341 Add a style class to model buttons
This will let us stop using the class name in Adwaita, and will
help with some future additions.
2014-04-22 11:10:38 -04:00
Dirgita
7a2f347678 Updated Indonesian translation 2014-04-22 14:31:34 +00:00
Volker Sobek
8fc1a1e52a docs: Fix parameter names for two functions
Don't use two different parameter names.
2014-04-21 23:18:39 +02:00
Yuri Myasoedov
0263a9712a Fixed Russian translation 2014-04-20 15:19:10 +04:00
Christian Kirbach
8da7f6861e Updated German translation 2014-04-19 12:01:04 +00:00
Bastien Nocera
391573ad2c gtkapplication: Fix incorrect value passed to g_variant_new()
The code expected to format @u, not u.

https://bugzilla.gnome.org/show_bug.cgi?id=728140
2014-04-18 10:44:52 +02:00
Руслан Ижбулатов
6015befd96 W32: correctly guess max window size from the size of the workarea of the screen it's on
Get monitor on which the most of the window is located (nearest monitor if
window is not on screen), get its work area (area not occupied by taskbar or
any other bars) and use that for maxsize.

Previous default of 30000 meant that windows maximized onto full screen,
even covering the area where taskbar is.

https://bugzilla.gnome.org/show_bug.cgi?id=726592
2014-04-16 22:44:15 +00:00
Daniel Mustieles
bf742b1e67 Updated Spanish translation 2014-04-15 14:27:22 +02:00
Daniel Mustieles
4823516339 Updated Spanish translation 2014-04-15 14:27:09 +02:00
Dirgita
03dd609544 Updated Indonesian translation 2014-04-15 06:56:20 +00:00
Matthias Clasen
074ce8958d 3.12.1 2014-04-12 08:20:01 -07:00
Matthias Clasen
0b911c3f41 Update expected output of messagedialog a11y test 2014-04-12 08:20:00 -07:00
Matthias Clasen
edcea7e60b window: Be more careful when propagating key events
We are keeping references on the widget we are handling as we
are iterating up, but that doesn't protect us against the entire
tree being axed from inside gtk_widget_handle_event.
https://bugzilla.gnome.org/show_bug.cgi?id=727644
2014-04-11 22:04:53 -07:00
Cosimo Cecchi
0ffc8a1eec entry: consider ascent and descent when requesting height
Commit d05191a010 change the height
requisition to be completely dependent on the PangoLayout, but that
breaks when the font has special characters with different metrics.
Use the maximum between the two instead.

https://bugzilla.gnome.org/show_bug.cgi?id=728054
2014-04-11 19:06:38 -07:00
Bastien Nocera
51aeb39bb0 gtkapplication: Fix passing NULL as the window to inhibit
gtk_application_inhibit() supports passing NULL, so don't
blindly pass the NULL window to
gtk_application_impl_dbus_get_window_system_id().

https://bugzilla.gnome.org/show_bug.cgi?id=728023
2014-04-11 18:52:09 -07:00
Matthias Clasen
750d7a2fe9 Update expected output for assistant a11y test
The headerbar and its content now shows up, as it should.
2014-04-10 15:54:48 -07:00
Matthias Clasen
365819be8e GtkAssistant: don't hide headerbar from a11y
GtkAssistant has its own accessible implementation, and we forgot
to update it when we added a headerbar.
2014-04-10 14:22:46 -07:00
Matthias Clasen
7d2f3530e8 GtkMessageDialog: Allow action-area-border theming again
This border does not interfere with headerbar-vs-content placement,
and we can allow themes to change it without breaking dialogs.
2014-04-10 13:57:48 -07:00
Matthias Clasen
1f1cd64028 GtkDialog: fix up handling of style properties
The use of border-width-set here was an attempt to differentiate
between explicitly set (from code / ui files) border width from
theme changes. But when we are calling gtk_window_set_border_width
to apply the theme value, the -set property gets set, and all
further theme changes are ignored. This has the effect of only
letting the default value of these properties get applied.

Fix this by unsetting border-width-set after applying theme values.
2014-04-10 13:57:47 -07:00
Руслан Ижбулатов
e41999cf98 W32: remove border on default buttons
https://bugzilla.gnome.org/show_bug.cgi?id=727973
2014-04-10 18:09:17 +00:00
Benjamin Otte
714c38c8b1 textview: Call map/unmap functions on pixel cache
https://bugzilla.gnome.org/show_bug.cgi?id=726475
2014-04-10 01:57:43 +02:00
Benjamin Otte
06010eead1 treeview: Call map/unmap functions on pixel cache
https://bugzilla.gnome.org/show_bug.cgi?id=726475
2014-04-10 01:57:43 +02:00
Benjamin Otte
0ede4d53cf viewport: Call map/unmap functions on pixel cache
https://bugzilla.gnome.org/show_bug.cgi?id=726475
2014-04-10 01:57:43 +02:00
Benjamin Otte
23dfc25583 pixelcache: Add map/unmap functions
Because GTK does not invalidate windows that aren't mapped, we cannot
update the pixel cache when the window it handles isn't mapped. So we
add API to call when GDK windows get mapped/unmapped.

https://bugzilla.gnome.org/show_bug.cgi?id=726475
2014-04-10 01:57:43 +02:00
Benjamin Otte
651f1c566a pixelcache: Split out a function
https://bugzilla.gnome.org/show_bug.cgi?id=726475
2014-04-10 01:57:36 +02:00
Chun-wei Fan
b7d55bfe14 Visual C++ Builds: Fix Header Installation
Make sure that gtk/a11y/gtkpopoveraccessible.h is copied, so that programs
using GTK+'s a11y will compile correctly.
2014-04-09 14:03:45 +08:00
Yuri Myasoedov
85ba100f23 Fixed Russian translation 2014-04-09 00:22:57 +04:00
137 changed files with 20647 additions and 12749 deletions

View File

@@ -33,11 +33,11 @@ MAINTAINERCLEANFILES = \
## Copy .pc files to target-specific names
gtk+-x11-3.0.pc gtk+-win32-3.0.pc gtk+-quartz-3.0.pc gtk+-broadway-3.0.pc gtk+-wayland-3.0.pc: gtk+-3.0.pc
gtk+-x11-3.0.pc gtk+-win32-3.0.pc gtk+-quartz-3.0.pc gtk+-broadway-3.0.pc gtk+-wayland-3.0.pc gtk+-mir-3.0.pc: gtk+-3.0.pc
rm -f $@ && \
cp gtk+-3.0.pc $@
gdk-x11-3.0.pc gdk-win32-3.0.pc gdk-quartz-3.0.pc gdk-broadway-3.0.pc gdk-wayland-3.0.pc: gdk-3.0.pc
gdk-x11-3.0.pc gdk-win32-3.0.pc gdk-quartz-3.0.pc gdk-broadway-3.0.pc gdk-wayland-3.0.pc gdk-mir-3.0.pc: gdk-3.0.pc
rm -f $@ && \
cp gdk-3.0.pc $@
@@ -59,12 +59,14 @@ DISTCLEANFILES = \
gtk+-quartz-3.0.pc \
gtk+-broadway-3.0.pc \
gtk+-wayland-3.0.pc \
gtk+-mir-3.0.pc \
gdk-3.0.pc \
gdk-x11-3.0.pc \
gdk-win32-3.0.pc \
gdk-quartz-3.0.pc \
gdk-broadway-3.0.pc \
gdk-wayland-3.0.pc \
gdk-mir-3.0.pc \
gail-3.0.pc \
config.lt

77
NEWS
View File

@@ -1,3 +1,80 @@
Overview of Changes in GTK+ 3.12.1 to 3.12.2
============================================
* Bug fixes:
495105 Open recent file keyboard shortcuts do not work correctly
686170 gdk/win32: VK_SNAPSHOT maps to GDK_Print
726592 W32: problems with CSDed windows
727487 Color picker check marks not cleared properly
728093 Add missing transfer annotation to gtk_box_get_center_widget
728140 Illegal parameter passed to g_variant_new in gtk_application...
728183 Drag and drop (GdkFrameClock) does not work for hidden widgets
728272 make broadway backend build on OpenBSD
728284 Graphics artifact when scrolling with hover-selection
728526 weird black border appear when dragging file
728745 win32: add more clipboard data checks to avoid crash
728806 W32: Check- and radio-buttons have a selection rectangle on ac...
728807 W32: Checkbutton focus rectangle becomes almost white on prelight
728808 W32: Checkboxes on modelbuttons are drawn like buttons themselves
728810 W32: Modelbuttons look like buttons
728992 GtkLockButton crash if clicked and permission is NULL
729346 W32: App-notification has no theme, shows up transparent
729451 Removing accels with application_set_accels_for_action
729670 cairo surface leaked for each cursor created from pixmap
* Translation updates:
Belarusian
German
Indonesian
Japanese
Russian
Slovenian
Spanish
Overview of Changes in GTK+ 3.12.0 to 3.12.1
============================================
* Bug fixes:
712752 GtkClipboard: add _get_default and _get_primary
722058 GtkTreeModelFilter bug
722817 Add gobject-introspection for GdkWin32
726298 gtk-font-name isn't correctly handled on Windows
726475 After looking at Asielriot solitare, I get rendering glitches...
726859 Assertion/crash if gtk_radio_menu_item_set_group() is called twice
726870 all: Name more idles and timeouts
726871 treeview: Lower the duration of validation iterations
726996 Label-for/Labelled-by AtkRelations missing for containers in ...
727009 redefinition of GtkPrinterCloudprint: cloudprint fails to build
727022 W32: Both inc- and dec-buttons on GtkSpinbutton are "inc"
727035 W32: Combobox button is drawn with two arrows
727036 W32: Combobox dropdown color is button-gray instead of window-white
727037 W32: Menu items look thin, while submenu arrows are huge
727075 W32: Combobox (with an entry) is gigantic
727078 W32: GtkPopover is transparent and non-interactable
727080 W32: Window re-size grip looks UGLY.
727210 W32: Prelight doesn't apply to check/radio marks
727211 W32: Selection background color applies to check/radio marks
727213 W32: Notebook widget is not styled correctly
727244 W32: Items selected in listbox have correct background color,...
727245 W32: No .dim-label style
727313 a11y: do not use deprecated a11y functions.
727322 docs: Remove '\' escape character from literals
727391 W32: scrollbar sliders have no "active" and "insensitive" styles
727410 W32: tooltips are not themed
727414 Redundant text in titlebar
727643 Segfault in gtk-3.12.0
727662 [PATCH] GtkVolumeButton displays "missing image" icons
727973 W32: focused button is visibly smaller
728023 Warning when passing NULL window to inhibit
727644 SEGV in gtk_window_propagate_key_event()
* Translation updates:
Basque
Catalan
Greek
Russian
Overview of Changes in GTK+ 3.11.9 to 3.12.0
============================================

View File

@@ -4,6 +4,10 @@
<Import Project="gtk-build-defines.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros">
<BinDir>$(SolutionDir)$(Configuration)\$(Platform)\bin</BinDir>
<InstalledDlls>$(BinDir)\$(GtkDllPrefix)gdk(GtkDllSuffix).dll;$(BinDir)\$(GtkDllPrefix)gtk(GtkDllSuffix).dll;$(BinDir)\$(GtkDllPrefix)gailutil(GtkDllSuffix).dll</InstalledDlls>
<InstalledBins>$(BinDir)\gtk3-demo.exe;$(BinDir)\gtk3-demo-application.exe</InstalledBins>
<InstalledBroadwayBins>$(BinDir)\broadwayd.exe</InstalledBroadwayBins>
<GtkDoInstallBin>
mkdir $(CopyDir)\bin
@@ -15,22 +19,22 @@ if "$(Configuration)" == "Release_Broadway" goto DO_BROADWAY_BIN
if "$(Configuration)" == "Debug_Broadway" goto DO_BROADWAY_BIN
copy $(Configuration)\$(Platform)\bin\*.dll $(CopyDir)\bin
copy $(BinDir)\*.dll $(CopyDir)\bin
copy $(Configuration)\$(Platform)\bin\*-$(ApiVersion).lib $(CopyDir)\lib
copy $(BinDir)\*-$(ApiVersion).lib $(CopyDir)\lib
copy $(Configuration)\$(Platform)\bin\*.exe $(CopyDir)\bin
copy $(BinDir)\*.exe $(CopyDir)\bin
goto DONE_BIN
:DO_BROADWAY_BIN
copy $(Configuration)\$(Platform)\bin\$(GtkDllPrefix)gdk$(GtkDllSuffix).dll $(CopyDir)\bin
copy $(BinDir)\$(GtkDllPrefix)gdk$(GtkDllSuffix).dll $(CopyDir)\bin
copy $(Configuration)\$(Platform)\bin\gdk-$(ApiVersion).lib $(CopyDir)\lib
copy $(BinDir)\gdk-$(ApiVersion).lib $(CopyDir)\lib
copy $(Configuration)\$(Platform)\bin\broadwayd.exe $(CopyDir)\bin
copy $(BinDir)\broadwayd.exe $(CopyDir)\bin
if "$(Configuration)" == "Release_Broadway" copy .\Release\$(Platform)\bin\$(GtkDllPrefix)gtk$(GtkDllSuffix).dll $(CopyDir)\bin
@@ -214,6 +218,8 @@ copy ..\..\..\gtk\a11y\gtknotebookpageaccessible.h $(CopyDir)\include\gtk-$(ApiV
copy ..\..\..\gtk\a11y\gtkpanedaccessible.h $(CopyDir)\include\gtk-$(ApiVersion)\gtk\a11y
copy ..\..\..\gtk\a11y\gtkpopoveraccessible.h $(CopyDir)\include\gtk-$(ApiVersion)\gtk\a11y
copy ..\..\..\gtk\a11y\gtkprogressbaraccessible.h $(CopyDir)\include\gtk-$(ApiVersion)\gtk\a11y
copy ..\..\..\gtk\a11y\gtkradiobuttonaccessible.h $(CopyDir)\include\gtk-$(ApiVersion)\gtk\a11y
@@ -796,6 +802,18 @@ copy ..\..\..\gdk\broadway\gdkbroadwayvisual.h $(CopyDir)\include\gtk-$(ApiVersi
<_PropertySheetDisplayName>gtkinstallsprops</_PropertySheetDisplayName>
</PropertyGroup>
<ItemGroup>
<BuildMacro Include="BinDir">
<Value>$(BinDir)</Value>
</BuildMacro>
<BuildMacro Include="InstalledDlls">
<Value>$(InstalledDlls)</Value>
</BuildMacro>
<BuildMacro Include="InstalledBins">
<Value>$(InstalledBins)</Value>
</BuildMacro>
<BuildMacro Include="InstalledBroadwayBins">
<Value>$(InstalledBroadwayBins)</Value>
</BuildMacro>
<BuildMacro Include="GtkDoInstallBin">
<Value>$(GtkDoInstallBin)</Value>
</BuildMacro>

View File

@@ -139,45 +139,49 @@
<ExtensionsToDeleteOnClean Condition="'$(Configuration)|$(Platform)'=='Release_Broadway|x64'" />
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<PreBuildEvent>
<Command>$(GtkDoInstallBin)$(GtkDoInstall)</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<PreBuildEvent>
<Command>$(GtkDoInstallBin)$(GtkDoInstall)</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<PreBuildEvent>
<Command>$(GtkDoInstallBin)$(GtkDoInstall)</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<PreBuildEvent>
<Command>$(GtkDoInstallBin)$(GtkDoInstall)</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_Broadway|Win32'">
<PreBuildEvent>
<Command>$(GtkDoInstallBin)$(GtkDoInstall)$(GtkDoInstallBroadwayHeaders)</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_Broadway|x64'">
<PreBuildEvent>
<Command>$(GtkDoInstallBin)$(GtkDoInstall)$(GtkDoInstallBroadwayHeaders)</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_Broadway|Win32'">
<PreBuildEvent>
<Command>$(GtkDoInstallBin)$(GtkDoInstall)$(GtkDoInstallBroadwayHeaders)</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_Broadway|x64'">
<PreBuildEvent>
<Command>$(GtkDoInstallBin)$(GtkDoInstall)$(GtkDoInstallBroadwayHeaders)</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<CustomBuild Include="..\..\..\config.h.win32">
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Installing Build Results...</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(GtkDoInstallBin)$(GtkDoInstall)</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(InstalledDlls);$(InstalledBins);%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug_Broadway|Win32'">Installing Build Results...</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug_Broadway|Win32'">$(GtkDoInstallBin)$(GtkDoInstall)$(GtkDoInstallBroadwayHeaders)</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug_Broadway|Win32'">$(InstalledDlls);$(InstalledBins);$(InstalledBroadwayBins);%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Installing Build Results...</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(GtkDoInstallBin)$(GtkDoInstall)</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(InstalledDlls);$(InstalledBins);%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug_Broadway|x64'">Installing Build Results...</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug_Broadway|x64'">$(GtkDoInstallBin)$(GtkDoInstall)$(GtkDoInstallBroadwayHeaders)</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug_Broadway|x64'">$(InstalledDlls);$(InstalledBins);$(InstalledBroadwayBins);%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Installing Build Results...</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(GtkDoInstallBin)$(GtkDoInstall)</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(InstalledDlls);$(InstalledBins);%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release_Broadway|Win32'">Installing Build Results...</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Release_Broadway|Win32'">$(GtkDoInstallBin)$(GtkDoInstall)$(GtkDoInstallBroadwayHeaders)</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release_Broadway|Win32'">$(InstalledDlls);$(InstalledBins);$(InstalledBroadwayBins);%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Installing Build Results...</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(GtkDoInstallBin)$(GtkDoInstall)</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(InstalledDlls);$(InstalledBins);%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release_Broadway|x64'">Installing Build Results...</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Release_Broadway|x64'">$(GtkDoInstallBin)$(GtkDoInstall)$(GtkDoInstallBroadwayHeaders)</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release_Broadway|x64'">$(InstalledDlls);$(InstalledBins);$(InstalledBroadwayBins);%(Outputs)</Outputs>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="gdk.vcxproj">
<Project>{fc5aadb5-95cd-4bf0-ba8b-0c16fe7073f7}</Project>

View File

@@ -121,6 +121,7 @@ copy ..\..\..\gtk\a11y\gtkmenushellaccessible.h $(CopyDir)\include\gtk-$(ApiVers
copy ..\..\..\gtk\a11y\gtknotebookaccessible.h $(CopyDir)\include\gtk-$(ApiVersion)\gtk\a11y&#x0D;&#x0A;
copy ..\..\..\gtk\a11y\gtknotebookpageaccessible.h $(CopyDir)\include\gtk-$(ApiVersion)\gtk\a11y&#x0D;&#x0A;
copy ..\..\..\gtk\a11y\gtkpanedaccessible.h $(CopyDir)\include\gtk-$(ApiVersion)\gtk\a11y&#x0D;&#x0A;
copy ..\..\..\gtk\a11y\gtkpopoveraccessible.h $(CopyDir)\include\gtk-$(ApiVersion)\gtk\a11y&#x0D;&#x0A;
copy ..\..\..\gtk\a11y\gtkprogressbaraccessible.h $(CopyDir)\include\gtk-$(ApiVersion)\gtk\a11y&#x0D;&#x0A;
copy ..\..\..\gtk\a11y\gtkradiobuttonaccessible.h $(CopyDir)\include\gtk-$(ApiVersion)\gtk\a11y&#x0D;&#x0A;
copy ..\..\..\gtk\a11y\gtkradiomenuitemaccessible.h $(CopyDir)\include\gtk-$(ApiVersion)\gtk\a11y&#x0D;&#x0A;

View File

@@ -10,8 +10,8 @@
m4_define([gtk_major_version], [3])
m4_define([gtk_minor_version], [12])
m4_define([gtk_micro_version], [1])
m4_define([gtk_interface_age], [1])
m4_define([gtk_micro_version], [3])
m4_define([gtk_interface_age], [3])
m4_define([gtk_binary_age],
[m4_eval(100 * gtk_minor_version + gtk_micro_version)])
m4_define([gtk_version],
@@ -322,6 +322,10 @@ AC_ARG_ENABLE(wayland-backend,
[AS_HELP_STRING([--enable-wayland-backend],
[enable the wayland gdk backend])],
[backend_set=yes])
AC_ARG_ENABLE(mir-backend,
[AS_HELP_STRING([--enable-mir-backend],
[enable the Mir gdk backend])],
[backend_set=yes])
if test -z "$backend_set"; then
if test "$platform_win32" = yes; then
@@ -329,6 +333,7 @@ if test -z "$backend_set"; then
else
enable_x11_backend=yes
enable_wayland_backend=maybe
enable_mir_backend=maybe
fi
fi
@@ -397,6 +402,11 @@ else
fi
AC_SUBST(DISABLE_ON_QUARTZ)
AC_CHECK_LIB([rt], [shm_open], [SHM_LIBS="-lrt"], [SHM_LIBS=""])
AC_SUBST(SHM_LIBS)
AC_CHECK_FUNCS(posix_fallocate)
if test "x$enable_broadway_backend" = xyes; then
GDK_BACKENDS="$GDK_BACKENDS broadway"
cairo_backends="$cairo_backends cairo"
@@ -445,6 +455,30 @@ else
AM_CONDITIONAL(USE_WAYLAND, false)
fi
MIR_DEPENDENCIES="mirclient"
if test "$enable_mir_backend" = "maybe" ; then
PKG_CHECK_EXISTS($MIR_DEPENDENCIES, [have_mir_deps=yes], [have_mir_deps=no])
AC_MSG_CHECKING([for MIR_DEPENDENCIES])
if test "$have_mir_deps" = "no" ; then
enable_mir_backend=no
else
enable_mir_backend=yes
fi
AC_MSG_RESULT($enable_mir_backend)
fi
if test "$enable_mir_backend" = "yes"; then
cairo_backends="$cairo_backends cairo"
GDK_BACKENDS="$GDK_BACKENDS mir"
GDK_WINDOWING="$GDK_WINDOWING
#define GDK_WINDOWING_MIR"
MIR_PACKAGES="$MIR_DEPENDENCIES"
AM_CONDITIONAL(USE_MIR, true)
else
AM_CONDITIONAL(USE_MIR, false)
fi
# strip leading space
GDK_BACKENDS=${GDK_BACKENDS#* }
@@ -1316,7 +1350,7 @@ CFLAGS="$saved_cflags"
LDFLAGS="$saved_ldflags"
GDK_PACKAGES="$PANGO_PACKAGES gdk-pixbuf-2.0 >= gdk_pixbuf_required_version cairo >= cairo_required_version cairo-gobject >= cairo_required_version"
GDK_PRIVATE_PACKAGES="$GDK_GIO_PACKAGE $X_PACKAGES $WAYLAND_PACKAGES $cairo_backends"
GDK_PRIVATE_PACKAGES="$GDK_GIO_PACKAGE $X_PACKAGES $WAYLAND_PACKAGES $MIR_PACKAGES $cairo_backends"
if test "x$enable_x11_backend" = xyes; then
GDK_PRIVATE_PACKAGES="$GDK_PRIVATE_PACKAGES pangoft2"
fi
@@ -1353,7 +1387,7 @@ fi
PKG_CHECK_MODULES(ATK, $ATK_PACKAGES)
GTK_PACKAGES="atk >= atk_required_version cairo >= cairo_required_version cairo-gobject >= cairo_required_version gdk-pixbuf-2.0 >= gdk_pixbuf_required_version gio-2.0 >= glib_required_version"
GTK_PRIVATE_PACKAGES="$ATK_PACKAGES"
GTK_PRIVATE_PACKAGES="$ATK_PACKAGES $WAYLAND_PACKAGES $MIR_PACKAGES"
if test "x$enable_x11_backend" = xyes; then
GTK_PRIVATE_PACKAGES="$GTK_PRIVATE_PACKAGES pangoft2"
fi
@@ -1876,6 +1910,7 @@ gdk/win32/rc/Makefile
gdk/win32/rc/gdk.rc
gdk/quartz/Makefile
gdk/wayland/Makefile
gdk/mir/Makefile
gdk/gdkversionmacros.h
gtk/Makefile
gtk/makefile.msc

View File

@@ -50,18 +50,21 @@ progressive_updated_callback (GdkPixbufLoader *loader,
gpointer data)
{
GtkWidget *image;
GdkPixbuf *pixbuf;
image = GTK_WIDGET (data);
/* We know the pixbuf inside the GtkImage has changed, but the image
* itself doesn't know this; so queue a redraw. If we wanted to be
* really efficient, we could use a drawing area or something
* instead of a GtkImage, so we could control the exact position of
* the pixbuf on the display, then we could queue a draw for only
* the updated area of the image.
* itself doesn't know this; so give it a hint by setting the pixbuf
* again. Queuing a redraw used to be sufficient, but nowadays GtkImage
* uses GtkIconHelper which caches the pixbuf state and will just redraw
* from the cache.
*/
gtk_widget_queue_draw (image);
pixbuf = gtk_image_get_pixbuf (GTK_IMAGE (image));
g_object_ref (pixbuf);
gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
g_object_unref (pixbuf);
}
static gint

View File

@@ -33,6 +33,7 @@ activate_link (GtkWidget *label,
"The term <i>keynav</i> is a shorthand for "
"keyboard navigation and refers to the process of using "
"a program (exclusively) via keyboard input.");
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
gtk_window_present (GTK_WINDOW (dialog));
g_signal_connect (dialog, "response", G_CALLBACK (response_cb), NULL);

View File

@@ -18,6 +18,8 @@ change_direction (GtkRevealer *revealer)
gtk_revealer_set_reveal_child (revealer, !revealed);
}
static guint timeout = 0;
static gboolean
reveal_one (gpointer data)
{
@@ -33,11 +35,15 @@ reveal_one (gpointer data)
G_CALLBACK (change_direction), NULL);
count++;
return count < 9;
if (count >= 9)
{
timeout = 0;
return FALSE;
}
else
return TRUE;
}
static guint timeout = 0;
static void
response_cb (GtkWidget *dialog,
gint response_id,

View File

@@ -145,6 +145,7 @@ content_files = \
osx.sgml \
broadway.xml \
wayland.xml \
mir.xml \
question_index.sgml \
resources.sgml \
text_widget.sgml \

View File

@@ -394,6 +394,11 @@ How to compile GTK+ itself
<arg choice="plain">--disable-wayland-backend</arg>
</group>
<sbr/>
<group>
<arg choice="plain">--enable-mir-backend</arg>
<arg choice="plain">--disable-mir-backend</arg>
</group>
<sbr/>
<group>
<arg choice="plain">--enable-introspection=[no/auto/yes]</arg>
</group>
@@ -595,8 +600,10 @@ How to compile GTK+ itself
<systemitem>--disable-quartz-backend</systemitem>,
<systemitem>--enable-broadway-backend</systemitem>,
<systemitem>--disable-broadway-backend</systemitem>,
<systemitem>--enable-wayland-backend</systemitem>, and
<systemitem>--disable-wayland-backend</systemitem></title>
<systemitem>--enable-wayland-backend</systemitem>,
<systemitem>--disable-wayland-backend</systemitem>
<systemitem>--enable-mir-backend</systemitem>, and
<systemitem>--disable-mir-backend</systemitem></title>
<para>
Enables specific backends for GDK. If none of these options

View File

@@ -605,12 +605,16 @@ example_app_startup (GApplication *app)
{
GtkBuilder *builder;
GMenuModel *app_menu;
const gchar *quit_accels[2] = { "&lt;Ctrl&gt;Q", NULL };
G_APPLICATION_CLASS (example_app_parent_class)->startup (app);
g_action_map_add_action_entries (G_ACTION_MAP (app),
app_entries, G_N_ELEMENTS (app_entries),
app);
gtk_application_set_accels_for_action (GTK_APPLICATION (app),
"app.quit",
quit_accels);
builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/app-menu.ui");
app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));
@@ -633,7 +637,7 @@ example_app_class_init (ExampleAppClass *class)
<para>Our preferences menu item does not do anything yet,
but the Quit menu item is fully functional. Note that it
can also be activated by the usual Ctrl-Q shortcut. The
shortcut was specified in the ui file.
shortcut was added with gtk_application_set_accels_for_action().
</para>
<para>The application menu looks like this:</para>
@@ -982,9 +986,8 @@ example_app_window_init (ExampleAppWindow *win)
<programlisting><xi:include href="../../../../examples/application10/window.ui" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
</informalexample>
<para>A small extra refinement that we have added here is to allow
the header bar to provide a fallback application menu, by setting
the show-fallback-app-menu property to TRUE. Here is how the
<para>A small extra bonus of using a header bar is that we get
a fallback application menu for free. Here is how the
application now looks, if this fallback is used.</para>
<informalfigure>

View File

@@ -394,6 +394,7 @@
<xi:include href="osx.sgml" />
<xi:include href="broadway.xml" />
<xi:include href="wayland.xml" />
<xi:include href="mir.xml" />
</part>
<xi:include href="glossary.xml" />

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 KiB

After

Width:  |  Height:  |  Size: 206 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 218 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 46 KiB

View File

@@ -0,0 +1,35 @@
<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
]>
<refentry id="gtk-mir">
<refmeta>
<refentrytitle>Using GTK+ with Mir</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GTK Library</refmiscinfo>
</refmeta>
<refnamediv>
<refname>Using GTK+ with Mir</refname>
<refpurpose>
Mir-specific aspects of using GTK+
</refpurpose>
</refnamediv>
<refsect1>
<title>Using GTK+ with Mir</title>
<para>
The GDK Mir backend provides support for running GTK+ applications
under Mir based display servers. To run your application in this way,
select the Mir backend by setting <literal>GDK_BACKEND=mir</literal>.
</para>
<para>
Currently, the Mir backend does not use any additional commandline
options or environment variables.
</para>
</refsect1>
</refentry>

View File

@@ -474,6 +474,11 @@ nevertheless.
<listitem><para>Selects the Wayland backend for connecting to Wayland display servers</para></listitem>
</varlistentry>
<varlistentry>
<term>mir</term>
<listitem><para>Selects the Mir backend for connecting to Mir display servers</para></listitem>
</varlistentry>
</variablelist>
Since 3.10, this environment variable can contain a comma-separated list
of backend names, which are tried in order. The list may also contain

View File

@@ -12,7 +12,6 @@
<item>
<attribute name="label" translatable="yes">_Quit</attribute>
<attribute name="action">app.quit</attribute>
<attribute name="accel"><![CDATA[<Ctrl>Q]]></attribute>
</item>
</section>
</menu>

View File

@@ -53,12 +53,16 @@ example_app_startup (GApplication *app)
{
GtkBuilder *builder;
GMenuModel *app_menu;
const gchar *quit_accels[2] = { "<Ctrl>Q", NULL };
G_APPLICATION_CLASS (example_app_parent_class)->startup (app);
g_action_map_add_action_entries (G_ACTION_MAP (app),
app_entries, G_N_ELEMENTS (app_entries),
app);
gtk_application_set_accels_for_action (GTK_APPLICATION (app),
"app.quit",
quit_accels);
builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/app-menu.ui");
app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));

View File

@@ -25,12 +25,6 @@ struct _ExampleAppPrefsPrivate
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
static void
preferences_closed (GtkWidget *button)
{
gtk_widget_destroy (gtk_widget_get_toplevel (button));
}
static void
example_app_prefs_init (ExampleAppPrefs *prefs)
{
@@ -68,12 +62,10 @@ example_app_prefs_class_init (ExampleAppPrefsClass *class)
"/org/gtk/exampleapp/prefs.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), preferences_closed);
}
ExampleAppPrefs *
example_app_prefs_new (ExampleAppWindow *win)
{
return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, NULL);
return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, "use-header-bar", TRUE, NULL);
}

View File

@@ -64,19 +64,6 @@
</child>
</object>
</child>
<child internal-child="action_area">
<object class="GtkButtonBox" id="action_area">
<property name="visible">True</property>
<child>
<object class="GtkButton" id="close">
<signal name="clicked" handler="preferences_closed"/>
<property name="visible">True</property>
<property name="label">_Close</property>
<property name="use-underline">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</template>

View File

@@ -9,7 +9,6 @@
<object class="GtkHeaderBar" id="header">
<property name="visible">True</property>
<property name="show-close-button">True</property>
<property name="show-fallback-app-menu">True</property>
<child>
<object class="GtkLabel" id="lines_label">
<property name="visible">False</property>
@@ -30,6 +29,7 @@
<child type="title">
<object class="GtkStackSwitcher" id="tabs">
<property name="visible">True</property>
<property name="margin">6</property>
<property name="stack">stack</property>
</object>
</child>
@@ -37,6 +37,9 @@
<object class="GtkToggleButton" id="search">
<property name="visible">True</property>
<property name="sensitive">False</property>
<style>
<class name="image-button"/>
</style>
<child>
<object class="GtkImage" id="search-icon">
<property name="visible">True</property>
@@ -52,6 +55,10 @@
<child>
<object class="GtkMenuButton" id="gears">
<property name="visible">True</property>
<property name="use-popover">True</property>
<style>
<class name="image-button"/>
</style>
<child>
<object class="GtkImage" id="gears-icon">
<property name="visible">True</property>

View File

@@ -15,6 +15,7 @@
<child type="title">
<object class="GtkStackSwitcher" id="tabs">
<property name="visible">True</property>
<property name="margin">6</property>
<property name="stack">stack</property>
</object>
</child>

View File

@@ -15,6 +15,7 @@
<child type="title">
<object class="GtkStackSwitcher" id="tabs">
<property name="visible">True</property>
<property name="margin">6</property>
<property name="stack">stack</property>
</object>
</child>

View File

@@ -12,7 +12,6 @@
<item>
<attribute name="label" translatable="yes">_Quit</attribute>
<attribute name="action">app.quit</attribute>
<attribute name="accel"><![CDATA[<Ctrl>Q]]></attribute>
</item>
</section>
</menu>

View File

@@ -46,12 +46,16 @@ example_app_startup (GApplication *app)
{
GtkBuilder *builder;
GMenuModel *app_menu;
const gchar *quit_accels[2] = { "<Ctrl>Q", NULL };
G_APPLICATION_CLASS (example_app_parent_class)->startup (app);
g_action_map_add_action_entries (G_ACTION_MAP (app),
app_entries, G_N_ELEMENTS (app_entries),
app);
gtk_application_set_accels_for_action (GTK_APPLICATION (app),
"app.quit",
quit_accels);
builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/app-menu.ui");
app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));

View File

@@ -15,6 +15,7 @@
<child type="title">
<object class="GtkStackSwitcher" id="tabs">
<property name="visible">True</property>
<property name="margin">6</property>
<property name="stack">stack</property>
</object>
</child>

View File

@@ -12,7 +12,6 @@
<item>
<attribute name="label" translatable="yes">_Quit</attribute>
<attribute name="action">app.quit</attribute>
<attribute name="accel"><![CDATA[<Ctrl>Q]]></attribute>
</item>
</section>
</menu>

View File

@@ -46,12 +46,16 @@ example_app_startup (GApplication *app)
{
GtkBuilder *builder;
GMenuModel *app_menu;
const gchar *quit_accels[2] = { "<Ctrl>Q", NULL };
G_APPLICATION_CLASS (example_app_parent_class)->startup (app);
g_action_map_add_action_entries (G_ACTION_MAP (app),
app_entries, G_N_ELEMENTS (app_entries),
app);
gtk_application_set_accels_for_action (GTK_APPLICATION (app),
"app.quit",
quit_accels);
builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/app-menu.ui");
app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));

View File

@@ -15,6 +15,7 @@
<child type="title">
<object class="GtkStackSwitcher" id="tabs">
<property name="visible">True</property>
<property name="margin">6</property>
<property name="stack">stack</property>
</object>
</child>

View File

@@ -12,7 +12,6 @@
<item>
<attribute name="label" translatable="yes">_Quit</attribute>
<attribute name="action">app.quit</attribute>
<attribute name="accel"><![CDATA[<Ctrl>Q]]></attribute>
</item>
</section>
</menu>

View File

@@ -4,12 +4,14 @@
#include "exampleappwin.h"
#include "exampleappprefs.h"
struct ExampleApp {
GtkApplication parent;
struct ExampleApp
{
GtkApplication parent;
};
struct ExampleAppClass {
GtkApplicationClass parent_class;
struct ExampleAppClass
{
GtkApplicationClass parent_class;
};
G_DEFINE_TYPE(ExampleApp, example_app, GTK_TYPE_APPLICATION);
@@ -24,12 +26,12 @@ preferences_activated (GSimpleAction *action,
GVariant *parameter,
gpointer app)
{
ExampleAppPrefs *prefs;
GtkWindow *win;
ExampleAppPrefs *prefs;
GtkWindow *win;
win = gtk_application_get_active_window (GTK_APPLICATION (app));
prefs = example_app_prefs_new (EXAMPLE_APP_WINDOW (win));
gtk_window_present (GTK_WINDOW (prefs));
win = gtk_application_get_active_window (GTK_APPLICATION (app));
prefs = example_app_prefs_new (EXAMPLE_APP_WINDOW (win));
gtk_window_present (GTK_WINDOW (prefs));
}
static void
@@ -40,36 +42,41 @@ quit_activated (GSimpleAction *action,
g_application_quit (G_APPLICATION (app));
}
static GActionEntry app_entries[] = {
{ "preferences", preferences_activated, NULL, NULL, NULL },
{ "quit", quit_activated, NULL, NULL, NULL }
static GActionEntry app_entries[] =
{
{ "preferences", preferences_activated, NULL, NULL, NULL },
{ "quit", quit_activated, NULL, NULL, NULL }
};
static void
example_app_startup (GApplication *app)
{
GtkBuilder *builder;
GMenuModel *app_menu;
GtkBuilder *builder;
GMenuModel *app_menu;
const gchar *quit_accels[2] = { "<Ctrl>Q", NULL };
G_APPLICATION_CLASS (example_app_parent_class)->startup (app);
G_APPLICATION_CLASS (example_app_parent_class)->startup (app);
g_action_map_add_action_entries (G_ACTION_MAP (app),
app_entries, G_N_ELEMENTS (app_entries),
app);
g_action_map_add_action_entries (G_ACTION_MAP (app),
app_entries, G_N_ELEMENTS (app_entries),
app);
gtk_application_set_accels_for_action (GTK_APPLICATION (app),
"app.quit",
quit_accels);
builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/app-menu.ui");
app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));
gtk_application_set_app_menu (GTK_APPLICATION (app), app_menu);
g_object_unref (builder);
builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/app-menu.ui");
app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));
gtk_application_set_app_menu (GTK_APPLICATION (app), app_menu);
g_object_unref (builder);
}
static void
example_app_activate (GApplication *app)
{
ExampleAppWindow *win;
ExampleAppWindow *win;
win = example_app_window_new (EXAMPLE_APP (app));
gtk_window_present (GTK_WINDOW (win));
win = example_app_window_new (EXAMPLE_APP (app));
gtk_window_present (GTK_WINDOW (win));
}
static void
@@ -78,35 +85,35 @@ example_app_open (GApplication *app,
gint n_files,
const gchar *hint)
{
GList *windows;
ExampleAppWindow *win;
int i;
GList *windows;
ExampleAppWindow *win;
int i;
windows = gtk_application_get_windows (GTK_APPLICATION (app));
if (windows)
win = EXAMPLE_APP_WINDOW (windows->data);
else
win = example_app_window_new (EXAMPLE_APP (app));
windows = gtk_application_get_windows (GTK_APPLICATION (app));
if (windows)
win = EXAMPLE_APP_WINDOW (windows->data);
else
win = example_app_window_new (EXAMPLE_APP (app));
for (i = 0; i < n_files; i++)
example_app_window_open (win, files[i]);
for (i = 0; i < n_files; i++)
example_app_window_open (win, files[i]);
gtk_window_present (GTK_WINDOW (win));
gtk_window_present (GTK_WINDOW (win));
}
static void
example_app_class_init (ExampleAppClass *class)
{
G_APPLICATION_CLASS (class)->startup = example_app_startup;
G_APPLICATION_CLASS (class)->activate = example_app_activate;
G_APPLICATION_CLASS (class)->open = example_app_open;
G_APPLICATION_CLASS (class)->startup = example_app_startup;
G_APPLICATION_CLASS (class)->activate = example_app_activate;
G_APPLICATION_CLASS (class)->open = example_app_open;
}
ExampleApp *
example_app_new (void)
{
return g_object_new (EXAMPLE_APP_TYPE,
"application-id", "org.gtk.exampleapp",
"flags", G_APPLICATION_HANDLES_OPEN,
NULL);
return g_object_new (EXAMPLE_APP_TYPE,
"application-id", "org.gtk.exampleapp",
"flags", G_APPLICATION_HANDLES_OPEN,
NULL);
}

View File

@@ -25,12 +25,6 @@ struct _ExampleAppPrefsPrivate
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
static void
preferences_closed (GtkWidget *button)
{
gtk_widget_destroy (gtk_widget_get_toplevel (button));
}
static void
example_app_prefs_init (ExampleAppPrefs *prefs)
{
@@ -68,12 +62,10 @@ example_app_prefs_class_init (ExampleAppPrefsClass *class)
"/org/gtk/exampleapp/prefs.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), preferences_closed);
}
ExampleAppPrefs *
example_app_prefs_new (ExampleAppWindow *win)
{
return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, NULL);
return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, "use-header-bar", TRUE, NULL);
}

View File

@@ -2,19 +2,22 @@
#include "exampleappwin.h"
#include <gtk/gtk.h>
struct ExampleAppWindow {
GtkApplicationWindow parent;
struct ExampleAppWindow
{
GtkApplicationWindow parent;
};
struct ExampleAppWindowClass {
GtkApplicationWindowClass parent_class;
struct ExampleAppWindowClass
{
GtkApplicationWindowClass parent_class;
};
typedef struct ExampleAppWindowPrivate ExampleAppWindowPrivate;
struct ExampleAppWindowPrivate {
GSettings *settings;
GtkWidget *stack;
struct ExampleAppWindowPrivate
{
GSettings *settings;
GtkWidget *stack;
};
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
@@ -22,87 +25,88 @@ G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLIC
static void
example_app_window_init (ExampleAppWindow *win)
{
ExampleAppWindowPrivate *priv;
ExampleAppWindowPrivate *priv;
priv = example_app_window_get_instance_private (win);
gtk_widget_init_template (GTK_WIDGET (win));
priv->settings = g_settings_new ("org.gtk.exampleapp");
priv = example_app_window_get_instance_private (win);
gtk_widget_init_template (GTK_WIDGET (win));
priv->settings = g_settings_new ("org.gtk.exampleapp");
g_settings_bind (priv->settings, "transition",
priv->stack, "transition-type",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (priv->settings, "transition",
priv->stack, "transition-type",
G_SETTINGS_BIND_DEFAULT);
}
static void
example_app_window_dispose (GObject *object)
{
ExampleAppWindow *win;
ExampleAppWindowPrivate *priv;
ExampleAppWindow *win;
ExampleAppWindowPrivate *priv;
win = EXAMPLE_APP_WINDOW (object);
priv = example_app_window_get_instance_private (win);
win = EXAMPLE_APP_WINDOW (object);
priv = example_app_window_get_instance_private (win);
g_clear_object (&priv->settings);
g_clear_object (&priv->settings);
G_OBJECT_CLASS (example_app_window_parent_class)->dispose (object);
G_OBJECT_CLASS (example_app_window_parent_class)->dispose (object);
}
static void
example_app_window_class_init (ExampleAppWindowClass *class)
{
G_OBJECT_CLASS (class)->dispose = example_app_window_dispose;
G_OBJECT_CLASS (class)->dispose = example_app_window_dispose;
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/exampleapp/window.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/exampleapp/window.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
}
ExampleAppWindow *
example_app_window_new (ExampleApp *app)
{
return g_object_new (EXAMPLE_APP_WINDOW_TYPE, "application", app, NULL);
return g_object_new (EXAMPLE_APP_WINDOW_TYPE, "application", app, NULL);
}
void
example_app_window_open (ExampleAppWindow *win,
GFile *file)
{
ExampleAppWindowPrivate *priv;
gchar *basename;
GtkWidget *scrolled, *view;
gchar *contents;
gsize length;
GtkTextBuffer *buffer;
GtkTextTag *tag;
GtkTextIter start_iter, end_iter;
ExampleAppWindowPrivate *priv;
gchar *basename;
GtkWidget *scrolled, *view;
gchar *contents;
gsize length;
GtkTextBuffer *buffer;
GtkTextTag *tag;
GtkTextIter start_iter, end_iter;
priv = example_app_window_get_instance_private (win);
basename = g_file_get_basename (file);
priv = example_app_window_get_instance_private (win);
basename = g_file_get_basename (file);
scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolled);
gtk_widget_set_hexpand (scrolled, TRUE);
gtk_widget_set_vexpand (scrolled, TRUE);
view = gtk_text_view_new ();
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
gtk_widget_show (view);
gtk_container_add (GTK_CONTAINER (scrolled), view);
gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolled);
gtk_widget_set_hexpand (scrolled, TRUE);
gtk_widget_set_vexpand (scrolled, TRUE);
view = gtk_text_view_new ();
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
gtk_widget_show (view);
gtk_container_add (GTK_CONTAINER (scrolled), view);
gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
if (g_file_load_contents (file, NULL, &contents, &length, NULL, NULL)) {
gtk_text_buffer_set_text (buffer, contents, length);
g_free (contents);
}
if (g_file_load_contents (file, NULL, &contents, &length, NULL, NULL))
{
gtk_text_buffer_set_text (buffer, contents, length);
g_free (contents);
}
tag = gtk_text_buffer_create_tag (buffer, NULL, NULL);
g_settings_bind (priv->settings, "font", tag, "font", G_SETTINGS_BIND_DEFAULT);
tag = gtk_text_buffer_create_tag (buffer, NULL, NULL);
g_settings_bind (priv->settings, "font", tag, "font", G_SETTINGS_BIND_DEFAULT);
gtk_text_buffer_get_start_iter (buffer, &start_iter);
gtk_text_buffer_get_end_iter (buffer, &end_iter);
gtk_text_buffer_apply_tag (buffer, tag, &start_iter, &end_iter);
gtk_text_buffer_get_start_iter (buffer, &start_iter);
gtk_text_buffer_get_end_iter (buffer, &end_iter);
gtk_text_buffer_apply_tag (buffer, tag, &start_iter, &end_iter);
g_free (basename);
g_free (basename);
}

View File

@@ -4,12 +4,12 @@
int
main (int argc, char *argv[])
{
/* Since this example is running uninstalled,
* we have to help it find its schema. This
* is *not* necessary in properly installed
* application.
*/
g_setenv ("GSETTINGS_SCHEMA_DIR", ".", FALSE);
/* Since this example is running uninstalled,
* we have to help it find its schema. This
* is *not* necessary in properly installed
* application.
*/
g_setenv ("GSETTINGS_SCHEMA_DIR", ".", FALSE);
return g_application_run (G_APPLICATION (example_app_new ()), argc, argv);
return g_application_run (G_APPLICATION (example_app_new ()), argc, argv);
}

View File

@@ -64,19 +64,6 @@
</child>
</object>
</child>
<child internal-child="action_area">
<object class="GtkButtonBox" id="action_area">
<property name="visible">True</property>
<child>
<object class="GtkButton" id="close">
<signal name="clicked" handler="preferences_closed"/>
<property name="visible">True</property>
<property name="label">_Close</property>
<property name="use-underline">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</template>

View File

@@ -15,6 +15,7 @@
<child type="title">
<object class="GtkStackSwitcher" id="tabs">
<property name="visible">True</property>
<property name="margin">6</property>
<property name="stack">stack</property>
</object>
</child>

View File

@@ -12,7 +12,6 @@
<item>
<attribute name="label" translatable="yes">_Quit</attribute>
<attribute name="action">app.quit</attribute>
<attribute name="accel"><![CDATA[<Ctrl>Q]]></attribute>
</item>
</section>
</menu>

View File

@@ -53,12 +53,16 @@ example_app_startup (GApplication *app)
{
GtkBuilder *builder;
GMenuModel *app_menu;
const gchar *quit_accels[2] = { "<Ctrl>Q", NULL };
G_APPLICATION_CLASS (example_app_parent_class)->startup (app);
g_action_map_add_action_entries (G_ACTION_MAP (app),
app_entries, G_N_ELEMENTS (app_entries),
app);
gtk_application_set_accels_for_action (GTK_APPLICATION (app),
"app.quit",
quit_accels);
builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/app-menu.ui");
app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));

View File

@@ -25,12 +25,6 @@ struct _ExampleAppPrefsPrivate
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
static void
preferences_closed (GtkWidget *button)
{
gtk_widget_destroy (gtk_widget_get_toplevel (button));
}
static void
example_app_prefs_init (ExampleAppPrefs *prefs)
{
@@ -68,12 +62,10 @@ example_app_prefs_class_init (ExampleAppPrefsClass *class)
"/org/gtk/exampleapp/prefs.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), preferences_closed);
}
ExampleAppPrefs *
example_app_prefs_new (ExampleAppWindow *win)
{
return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, NULL);
return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, "use-header-bar", TRUE, NULL);
}

View File

@@ -64,19 +64,6 @@
</child>
</object>
</child>
<child internal-child="action_area">
<object class="GtkButtonBox" id="action_area">
<property name="visible">True</property>
<child>
<object class="GtkButton" id="close">
<signal name="clicked" handler="preferences_closed"/>
<property name="visible">True</property>
<property name="label">_Close</property>
<property name="use-underline">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</template>

View File

@@ -15,6 +15,7 @@
<child type="title">
<object class="GtkStackSwitcher" id="tabs">
<property name="visible">True</property>
<property name="margin">6</property>
<property name="stack">stack</property>
</object>
</child>
@@ -22,6 +23,9 @@
<object class="GtkToggleButton" id="search">
<property name="visible">True</property>
<property name="sensitive">False</property>
<style>
<class name="image-button"/>
</style>
<child>
<object class="GtkImage" id="search-icon">
<property name="visible">True</property>

View File

@@ -12,7 +12,6 @@
<item>
<attribute name="label" translatable="yes">_Quit</attribute>
<attribute name="action">app.quit</attribute>
<attribute name="accel"><![CDATA[<Ctrl>Q]]></attribute>
</item>
</section>
</menu>

View File

@@ -53,12 +53,16 @@ example_app_startup (GApplication *app)
{
GtkBuilder *builder;
GMenuModel *app_menu;
const gchar *quit_accels[2] = { "<Ctrl>Q", NULL };
G_APPLICATION_CLASS (example_app_parent_class)->startup (app);
g_action_map_add_action_entries (G_ACTION_MAP (app),
app_entries, G_N_ELEMENTS (app_entries),
app);
gtk_application_set_accels_for_action (GTK_APPLICATION (app),
"app.quit",
quit_accels);
builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/app-menu.ui");
app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));

View File

@@ -25,12 +25,6 @@ struct _ExampleAppPrefsPrivate
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
static void
preferences_closed (GtkWidget *button)
{
gtk_widget_destroy (gtk_widget_get_toplevel (button));
}
static void
example_app_prefs_init (ExampleAppPrefs *prefs)
{
@@ -68,12 +62,10 @@ example_app_prefs_class_init (ExampleAppPrefsClass *class)
"/org/gtk/exampleapp/prefs.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), preferences_closed);
}
ExampleAppPrefs *
example_app_prefs_new (ExampleAppWindow *win)
{
return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, NULL);
return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, "use-header-bar", TRUE, NULL);
}

View File

@@ -64,19 +64,6 @@
</child>
</object>
</child>
<child internal-child="action_area">
<object class="GtkButtonBox" id="action_area">
<property name="visible">True</property>
<child>
<object class="GtkButton" id="close">
<signal name="clicked" handler="preferences_closed"/>
<property name="visible">True</property>
<property name="label">_Close</property>
<property name="use-underline">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</template>

View File

@@ -15,6 +15,7 @@
<child type="title">
<object class="GtkStackSwitcher" id="tabs">
<property name="visible">True</property>
<property name="margin">6</property>
<property name="stack">stack</property>
</object>
</child>
@@ -22,6 +23,9 @@
<object class="GtkToggleButton" id="search">
<property name="visible">True</property>
<property name="sensitive">False</property>
<style>
<class name="image-button"/>
</style>
<child>
<object class="GtkImage" id="search-icon">
<property name="visible">True</property>
@@ -37,6 +41,10 @@
<child>
<object class="GtkMenuButton" id="gears">
<property name="visible">True</property>
<property name="use-popover">True</property>
<style>
<class name="image-button"/>
</style>
<child>
<object class="GtkImage" id="gears-icon">
<property name="visible">True</property>

View File

@@ -12,7 +12,6 @@
<item>
<attribute name="label" translatable="yes">_Quit</attribute>
<attribute name="action">app.quit</attribute>
<attribute name="accel"><![CDATA[<Ctrl>Q]]></attribute>
</item>
</section>
</menu>

View File

@@ -53,12 +53,16 @@ example_app_startup (GApplication *app)
{
GtkBuilder *builder;
GMenuModel *app_menu;
const gchar *quit_accels[2] = { "<Ctrl>Q", NULL };
G_APPLICATION_CLASS (example_app_parent_class)->startup (app);
g_action_map_add_action_entries (G_ACTION_MAP (app),
app_entries, G_N_ELEMENTS (app_entries),
app);
gtk_application_set_accels_for_action (GTK_APPLICATION (app),
"app.quit",
quit_accels);
builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/app-menu.ui");
app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));

View File

@@ -25,12 +25,6 @@ struct _ExampleAppPrefsPrivate
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
static void
preferences_closed (GtkWidget *button)
{
gtk_widget_destroy (gtk_widget_get_toplevel (button));
}
static void
example_app_prefs_init (ExampleAppPrefs *prefs)
{
@@ -68,12 +62,10 @@ example_app_prefs_class_init (ExampleAppPrefsClass *class)
"/org/gtk/exampleapp/prefs.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), preferences_closed);
}
ExampleAppPrefs *
example_app_prefs_new (ExampleAppWindow *win)
{
return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, NULL);
return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, "use-header-bar", TRUE, NULL);
}

View File

@@ -64,19 +64,6 @@
</child>
</object>
</child>
<child internal-child="action_area">
<object class="GtkButtonBox" id="action_area">
<property name="visible">True</property>
<child>
<object class="GtkButton" id="close">
<signal name="clicked" handler="preferences_closed"/>
<property name="visible">True</property>
<property name="label">_Close</property>
<property name="use-underline">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</template>

View File

@@ -32,6 +32,7 @@
<child type="title">
<object class="GtkStackSwitcher" id="tabs">
<property name="visible">True</property>
<property name="margin">6</property>
<property name="stack">stack</property>
</object>
</child>
@@ -39,6 +40,9 @@
<object class="GtkToggleButton" id="search">
<property name="visible">True</property>
<property name="sensitive">False</property>
<style>
<class name="image-button"/>
</style>
<child>
<object class="GtkImage" id="search-icon">
<property name="visible">True</property>
@@ -54,6 +58,10 @@
<child>
<object class="GtkMenuButton" id="gears">
<property name="visible">True</property>
<property name="use-popover">True</property>
<style>
<class name="image-button"/>
</style>
<child>
<object class="GtkImage" id="gears-icon">
<property name="visible">True</property>

View File

@@ -508,6 +508,7 @@ static void
bloat_pad_startup (GApplication *application)
{
BloatPad *bloatpad = (BloatPad*) application;
GtkApplication *app = GTK_APPLICATION (application);
GtkBuilder *builder;
GMenu *menu;
GMenuItem *item;
@@ -517,6 +518,19 @@ bloat_pad_startup (GApplication *application)
GFile *file;
gchar *data;
gsize size;
gint i;
struct {
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 } }
};
G_APPLICATION_CLASS (bloat_pad_parent_class)
->startup (application);
@@ -606,15 +620,10 @@ bloat_pad_startup (GApplication *application)
" </submenu>"
" </menu>"
"</interface>", -1, NULL);
gtk_application_set_app_menu (GTK_APPLICATION (application), G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
gtk_application_set_menubar (GTK_APPLICATION (application), G_MENU_MODEL (gtk_builder_get_object (builder, "menubar")));
gtk_application_add_accelerator (GTK_APPLICATION (application), "<Primary>n", "app.new", NULL);
gtk_application_add_accelerator (GTK_APPLICATION (application), "<Primary>q", "app.quit", NULL);
gtk_application_add_accelerator (GTK_APPLICATION (application), "<Primary>c", "win.copy", NULL);
gtk_application_add_accelerator (GTK_APPLICATION (application), "<Primary>p", "win.paste", NULL);
gtk_application_add_accelerator (GTK_APPLICATION (application), "<Primary>l", "win.justify", g_variant_new_string ("left"));
gtk_application_add_accelerator (GTK_APPLICATION (application), "<Primary>m", "win.justify", g_variant_new_string ("center"));
gtk_application_add_accelerator (GTK_APPLICATION (application), "<Primary>r", "win.justify", g_variant_new_string ("right"));
gtk_application_set_app_menu (app, G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
gtk_application_set_menubar (app, G_MENU_MODEL (gtk_builder_get_object (builder, "menubar")));
for (i = 0; i < G_N_ELEMENTS (accels); i++)
gtk_application_set_accels_for_action (app, accels[i].action_and_target, accels[i].accelerators);
menu = G_MENU (gtk_builder_get_object (builder, "icon-menu"));
@@ -743,11 +752,12 @@ main (int argc, char **argv)
{
BloatPad *bloat_pad;
int status;
const gchar *accels[] = { "F11", NULL };
bloat_pad = bloat_pad_new ();
gtk_application_add_accelerator (GTK_APPLICATION (bloat_pad),
"F11", "win.fullscreen", NULL);
gtk_application_set_accels_for_action (GTK_APPLICATION (bloat_pad),
"win.fullscreen", accels);
status = g_application_run (G_APPLICATION (bloat_pad), argc, argv);

View File

@@ -13,7 +13,7 @@ INTROSPECTION_COMPILER_ARGS = \
SUBDIRS = $(GDK_BACKENDS) .
DIST_SUBDIRS = win32 x11 quartz broadway wayland
DIST_SUBDIRS = win32 x11 quartz broadway wayland mir
CLEANFILES =
@@ -193,6 +193,10 @@ if USE_WAYLAND
libgdk_3_la_LIBADD += wayland/libgdk-wayland.la
endif
if USE_MIR
libgdk_3_la_LIBADD += mir/libgdk-mir.la
endif
if HAVE_INTROSPECTION
introspection_files = \

View File

@@ -1,5 +1,6 @@
## Process this file with automake to produce Makefile.in
include $(top_srcdir)/Makefile.decl
NULL =
libgdkincludedir = $(includedir)/gtk-3.0/gdk
libgdkbroadwayincludedir = $(includedir)/gtk-3.0/gdk/broadway
@@ -75,7 +76,8 @@ libgdk_broadway_la_SOURCES = \
if OS_UNIX
libgdk_broadway_la_LIBADD = \
-lrt
$(SHM_LIBS) \
$(NULL)
endif
broadwayd_SOURCES = \
@@ -91,7 +93,7 @@ broadwayd_SOURCES = \
if OS_WIN32
broadwayd_LDADD = $(GDK_DEP_LIBS) -lws2_32
else
broadwayd_LDADD = $(GDK_DEP_LIBS) -lrt
broadwayd_LDADD = $(GDK_DEP_LIBS) @SHM_LIBS@
endif
MAINTAINERCLEANFILES = $(broadway_built_sources)

View File

@@ -540,12 +540,14 @@ map_named_shm (char *name, gsize size)
res = ftruncate (fd, size);
g_assert (res != -1);
#ifdef HAVE_POSIX_FALLOCATE
res = posix_fallocate (fd, 0, size);
if (res != 0)
{
shm_unlink (name);
g_error ("Not enough shared memory for window surface");
}
#endif
ptr = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);

View File

@@ -318,6 +318,7 @@ gdk_cursor_new_from_pixbuf (GdkDisplay *display,
const char *option;
char *end;
gint64 value;
GdkCursor *cursor;
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
@@ -346,7 +347,11 @@ gdk_cursor_new_from_pixbuf (GdkDisplay *display,
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, 1, NULL);
return GDK_DISPLAY_GET_CLASS (display)->get_cursor_for_surface (display, surface, x, y);
cursor = GDK_DISPLAY_GET_CLASS (display)->get_cursor_for_surface (display, surface, x, y);
cairo_surface_destroy (surface);
return cursor;
}
/**

View File

@@ -60,6 +60,10 @@
#include "wayland/gdkprivate-wayland.h"
#endif
#ifdef GDK_WINDOWING_MIR
#include "mir/gdkmir-private.h"
#endif
/**
* SECTION:gdkdisplaymanager
* @Short_description: Maintains a list of all open GdkDisplays
@@ -272,6 +276,9 @@ static GdkBackend gdk_backends[] = {
#ifdef GDK_WINDOWING_WAYLAND
{ "wayland", _gdk_wayland_display_open },
#endif
#ifdef GDK_WINDOWING_MIR
{ "mir", _gdk_mir_display_open },
#endif
#ifdef GDK_WINDOWING_BROADWAY
{ "broadway", _gdk_broadway_display_open },
#endif

39
gdk/mir/Makefile.am Normal file
View File

@@ -0,0 +1,39 @@
## Process this file with automake to produce Makefile.in
include $(top_srcdir)/Makefile.decl
libgdkincludedir = $(includedir)/gtk-3.0/gdk
libgdkmirincludedir = $(includedir)/gtk-3.0/gdk/mir
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gdk\" \
-DGDK_COMPILATION \
-I$(top_srcdir) \
-I$(top_srcdir)/gdk \
-I$(top_builddir)/gdk \
$(GDK_HIDDEN_VISIBILITY_CFLAGS) \
$(GTK_DEBUG_FLAGS) \
$(GDK_DEP_CFLAGS)
LDADDS = $(GDK_DEP_LIBS)
noinst_LTLIBRARIES = \
libgdk-mir.la
libgdk_mir_la_SOURCES = \
gdkmircursor.c \
gdkmirdevicemanager.c \
gdkmirdisplay.c \
gdkmireventsource.c \
gdkmirkeyboard.c \
gdkmirkeymap.c \
gdkmirpointer.c \
gdkmirscreen.c \
gdkmirwindow.c \
gdkmirwindowimpl.c \
gdkmir-debug.c \
gdkmir.h
libgdkinclude_HEADERS = \
gdkmir.h
-include $(top_srcdir)/git.mk

293
gdk/mir/gdkmir-debug.c Normal file
View File

@@ -0,0 +1,293 @@
/*
* Copyright © 2014 Canonical Ltd
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "gdkmir-private.h"
void
_gdk_mir_print_modifiers (unsigned int modifiers)
{
g_printerr (" Modifiers");
if ((modifiers & mir_key_modifier_alt) != 0)
g_printerr (" alt");
if ((modifiers & mir_key_modifier_alt_left) != 0)
g_printerr (" alt-left");
if ((modifiers & mir_key_modifier_alt_right) != 0)
g_printerr (" alt-right");
if ((modifiers & mir_key_modifier_shift) != 0)
g_printerr (" shift");
if ((modifiers & mir_key_modifier_shift_left) != 0)
g_printerr (" shift-left");
if ((modifiers & mir_key_modifier_shift_right) != 0)
g_printerr (" shift-right");
if ((modifiers & mir_key_modifier_sym) != 0)
g_printerr (" sym");
if ((modifiers & mir_key_modifier_function) != 0)
g_printerr (" function");
if ((modifiers & mir_key_modifier_ctrl) != 0)
g_printerr (" ctrl");
if ((modifiers & mir_key_modifier_ctrl_left) != 0)
g_printerr (" ctrl-left");
if ((modifiers & mir_key_modifier_ctrl_right) != 0)
g_printerr (" ctrl-right");
if ((modifiers & mir_key_modifier_meta) != 0)
g_printerr (" meta");
if ((modifiers & mir_key_modifier_meta_left) != 0)
g_printerr (" meta-left");
if ((modifiers & mir_key_modifier_meta_right) != 0)
g_printerr (" meta-right");
if ((modifiers & mir_key_modifier_caps_lock) != 0)
g_printerr (" caps-lock");
if ((modifiers & mir_key_modifier_num_lock) != 0)
g_printerr (" num-lock");
if ((modifiers & mir_key_modifier_scroll_lock) != 0)
g_printerr (" scroll-lock");
g_printerr ("\n");
}
void
_gdk_mir_print_key_event (const MirKeyEvent *event)
{
g_printerr ("KEY\n");
g_printerr (" Device %i\n", event->device_id);
g_printerr (" Source %i\n", event->source_id);
g_printerr (" Action ");
switch (event->action)
{
case mir_key_action_down:
g_printerr ("down");
break;
case mir_key_action_up:
g_printerr ("up");
break;
case mir_key_action_multiple:
g_printerr ("multiple");
break;
default:
g_printerr ("%u", event->action);
break;
}
g_printerr ("\n");
g_printerr (" Flags");
if ((event->flags & mir_key_flag_woke_here) != 0)
g_printerr (" woke-here");
if ((event->flags & mir_key_flag_soft_keyboard) != 0)
g_printerr (" soft-keyboard");
if ((event->flags & mir_key_flag_keep_touch_mode) != 0)
g_printerr (" keep-touch-mode");
if ((event->flags & mir_key_flag_from_system) != 0)
g_printerr (" from-system");
if ((event->flags & mir_key_flag_editor_action) != 0)
g_printerr (" editor-action");
if ((event->flags & mir_key_flag_canceled) != 0)
g_printerr (" canceled");
if ((event->flags & mir_key_flag_virtual_hard_key) != 0)
g_printerr (" virtual-hard-key");
if ((event->flags & mir_key_flag_long_press) != 0)
g_printerr (" long-press");
if ((event->flags & mir_key_flag_canceled_long_press) != 0)
g_printerr (" canceled-long-press");
if ((event->flags & mir_key_flag_tracking) != 0)
g_printerr (" tracking");
if ((event->flags & mir_key_flag_fallback) != 0)
g_printerr (" fallback");
g_printerr ("\n");
_gdk_mir_print_modifiers (event->modifiers);
g_printerr (" Key Code %i\n", event->key_code);
g_printerr (" Scan Code %i\n", event->scan_code);
g_printerr (" Repeat Count %i\n", event->repeat_count);
g_printerr (" Down Time %lli\n", (long long int) event->down_time);
g_printerr (" Event Time %lli\n", (long long int) event->event_time);
g_printerr (" Is System Key %s\n", event->is_system_key ? "true" : "false");
}
void
_gdk_mir_print_motion_event (const MirMotionEvent *event)
{
size_t i;
g_printerr ("MOTION\n");
g_printerr (" Device %i\n", event->device_id);
g_printerr (" Source %i\n", event->source_id);
g_printerr (" Action ");
switch (event->action)
{
case mir_motion_action_down:
g_printerr ("down");
break;
case mir_motion_action_up:
g_printerr ("up");
break;
case mir_motion_action_move:
g_printerr ("move");
break;
case mir_motion_action_cancel:
g_printerr ("cancel");
break;
case mir_motion_action_outside:
g_printerr ("outside");
break;
case mir_motion_action_pointer_down:
g_printerr ("pointer-down");
break;
case mir_motion_action_pointer_up:
g_printerr ("pointer-up");
break;
case mir_motion_action_hover_move:
g_printerr ("hover-move");
break;
case mir_motion_action_scroll:
g_printerr ("scroll");
break;
case mir_motion_action_hover_enter:
g_printerr ("hover-enter");
break;
case mir_motion_action_hover_exit:
g_printerr ("hover-exit");
break;
default:
g_printerr ("%u", event->action);
}
g_printerr ("\n");
g_printerr (" Flags");
switch (event->flags)
{
case mir_motion_flag_window_is_obscured:
g_printerr (" window-is-obscured");
break;
}
g_printerr ("\n");
_gdk_mir_print_modifiers (event->modifiers);
g_printerr (" Edge Flags %i\n", event->edge_flags);
g_printerr (" Button State");
switch (event->button_state)
{
case mir_motion_button_primary:
g_printerr (" primary");
break;
case mir_motion_button_secondary:
g_printerr (" secondary");
break;
case mir_motion_button_tertiary:
g_printerr (" tertiary");
break;
case mir_motion_button_back:
g_printerr (" back");
break;
case mir_motion_button_forward:
g_printerr (" forward");
break;
}
g_printerr ("\n");
g_printerr (" Offset (%f, %f)\n", event->x_offset, event->y_offset);
g_printerr (" Precision (%f, %f)\n", event->x_precision, event->y_precision);
g_printerr (" Down Time %lli\n", (long long int) event->down_time);
g_printerr (" Event Time %lli\n", (long long int) event->event_time);
g_printerr (" Pointer Coordinates\n");
for (i = 0; i < event->pointer_count; i++)
{
g_printerr (" ID=%i location=(%f, %f) raw=(%f, %f) touch=(%f, %f) size=%f pressure=%f orientation=%f scroll=(%f, %f) tool=",
event->pointer_coordinates[i].id,
event->pointer_coordinates[i].x, event->pointer_coordinates[i].y,
event->pointer_coordinates[i].raw_x, event->pointer_coordinates[i].raw_y,
event->pointer_coordinates[i].touch_major, event->pointer_coordinates[i].touch_minor,
event->pointer_coordinates[i].size,
event->pointer_coordinates[i].pressure,
event->pointer_coordinates[i].orientation,
event->pointer_coordinates[i].hscroll, event->pointer_coordinates[i].vscroll);
switch (event->pointer_coordinates[i].tool_type)
{
case mir_motion_tool_type_unknown:
g_printerr ("unknown");
break;
case mir_motion_tool_type_finger:
g_printerr ("finger");
break;
case mir_motion_tool_type_stylus:
g_printerr ("stylus");
break;
case mir_motion_tool_type_mouse:
g_printerr ("mouse");
break;
case mir_motion_tool_type_eraser:
g_printerr ("eraser");
break;
default:
g_printerr ("%u", event->pointer_coordinates[i].tool_type);
break;
}
g_printerr ("\n");
}
}
void
_gdk_mir_print_surface_event (const MirSurfaceEvent *event)
{
g_printerr ("SURFACE\n");
g_printerr (" Surface %i\n", event->id);
g_printerr (" Attribute ");
switch (event->attrib)
{
case mir_surface_attrib_type:
g_printerr ("type");
break;
case mir_surface_attrib_state:
g_printerr ("state");
break;
case mir_surface_attrib_swapinterval:
g_printerr ("swapinterval");
break;
case mir_surface_attrib_focus:
g_printerr ("focus");
break;
default:
g_printerr ("%u", event->attrib);
break;
}
g_printerr ("\n");
g_printerr (" Value %i\n", event->value);
}
void
_gdk_mir_print_resize_event (const MirResizeEvent *event)
{
g_printerr ("RESIZE\n");
g_printerr (" Surface %i\n", event->surface_id);
g_printerr (" Size (%i, %i)\n", event->width, event->height);
}
void
_gdk_mir_print_event (const MirEvent *event)
{
switch (event->type)
{
case mir_event_type_key:
_gdk_mir_print_key_event (&event->key);
break;
case mir_event_type_motion:
_gdk_mir_print_motion_event (&event->motion);
break;
case mir_event_type_surface:
_gdk_mir_print_surface_event (&event->surface);
break;
case mir_event_type_resize:
_gdk_mir_print_resize_event (&event->resize);
break;
default:
g_printerr ("EVENT %u\n", event->type);
break;
}
}

86
gdk/mir/gdkmir-private.h Normal file
View File

@@ -0,0 +1,86 @@
/*
* Copyright © 2014 Canonical Ltd
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GDK_PRIVATE_MIR_H__
#define __GDK_PRIVATE_MIR_H__
#include "config.h"
#include "gdkmir.h"
#include "gdkdisplay.h"
#include "gdkscreen.h"
#include "gdkdevicemanager.h"
#include "gdkkeys.h"
#include "gdkwindowimpl.h"
typedef struct _GdkMirWindowImpl GdkMirWindowImpl;
typedef struct _GdkMirWindowReference GdkMirWindowReference;
typedef struct _GdkMirEventSource GdkMirEventSource;
#define GDK_TYPE_MIR_WINDOW_IMPL (gdk_mir_window_impl_get_type ())
#define GDK_MIR_WINDOW_IMPL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WINDOW_IMPL_MIR, GdkMirWindowImpl))
#define GDK_IS_WINDOW_IMPL_MIR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WINDOW_IMPL_MIR))
GdkDisplay *_gdk_mir_display_open (const gchar *display_name);
GdkScreen *_gdk_mir_screen_new (GdkDisplay *display);
GdkDeviceManager *_gdk_mir_device_manager_new (GdkDisplay *display);
GdkDevice *_gdk_mir_device_manager_get_keyboard (GdkDeviceManager *device_manager);
GdkKeymap *_gdk_mir_keymap_new (void);
GdkDevice *_gdk_mir_keyboard_new (GdkDeviceManager *device_manager, const gchar *name);
GdkDevice *_gdk_mir_pointer_new (GdkDeviceManager *device_manager, const gchar *name);
void _gdk_mir_pointer_set_location (GdkDevice *pointer, gdouble x, gdouble y, GdkWindow *window, GdkModifierType mask);
GdkCursor *_gdk_mir_cursor_new (GdkDisplay *display, GdkCursorType type);
GdkWindowImpl *_gdk_mir_window_impl_new (void);
void _gdk_mir_window_impl_set_surface_state (GdkMirWindowImpl *impl, MirSurfaceState state);
void _gdk_mir_window_impl_set_cursor_state (GdkMirWindowImpl *impl, gdouble x, gdouble y, gboolean cursor_inside, MirMotionButton button_state);
void _gdk_mir_window_impl_get_cursor_state (GdkMirWindowImpl *impl, gdouble *x, gdouble *y, gboolean *cursor_inside, MirMotionButton *button_state);
GdkMirEventSource *_gdk_mir_display_get_event_source (GdkDisplay *display);
GdkMirEventSource *_gdk_mir_event_source_new (GdkDisplay *display);
GdkMirWindowReference *_gdk_mir_event_source_get_window_reference (GdkWindow *window);
void _gdk_mir_window_reference_unref (GdkMirWindowReference *ref);
void _gdk_mir_event_source_queue (GdkMirWindowReference *window_ref, const MirEvent *event);
void _gdk_mir_print_modifiers (unsigned int modifiers);
void _gdk_mir_print_key_event (const MirKeyEvent *event);
void _gdk_mir_print_motion_event (const MirMotionEvent *event);
void _gdk_mir_print_surface_event (const MirSurfaceEvent *event);
void _gdk_mir_print_resize_event (const MirResizeEvent *event);
void _gdk_mir_print_event (const MirEvent *event);
#endif /* __GDK_PRIVATE_MIR_H__ */

39
gdk/mir/gdkmir.h Normal file
View File

@@ -0,0 +1,39 @@
/*
* Copyright © 2014 Canonical Ltd
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GDK_MIR_H__
#define __GDK_MIR_H__
#include <gdk/gdk.h>
#include <mir_toolkit/mir_client_library.h>
#define GDK_TYPE_MIR_DISPLAY (gdk_mir_display_get_type ())
#define GDK_IS_MIR_DISPLAY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_DISPLAY))
#define GDK_TYPE_MIR_WINDOW (gdk_mir_window_get_type ())
#define GDK_IS_WINDOW_MIR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WINDOW_MIR))
GDK_AVAILABLE_IN_3_10
GType gdk_mir_display_get_type (void);
GDK_AVAILABLE_IN_3_10
struct MirConnection *gdk_mir_display_get_mir_connection (GdkDisplay *display);
GDK_AVAILABLE_IN_3_10
GType gdk_mir_window_get_type (void);
#endif /* __GDK_MIR_H__ */

73
gdk/mir/gdkmircursor.c Normal file
View File

@@ -0,0 +1,73 @@
/*
* Copyright © 2014 Canonical Ltd
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gdkcursorprivate.h"
#include "gdkmir.h"
#include "gdkmir-private.h"
typedef struct GdkMirCursor GdkMirCursor;
typedef struct GdkMirCursorClass GdkMirCursorClass;
#define GDK_TYPE_MIR_CURSOR (gdk_mir_cursor_get_type ())
#define GDK_MIR_CURSOR(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_MIR_CURSOR, GdkMirCursor))
#define GDK_MIR_CURSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_MIR_CURSOR, GdkMirCursorClass))
#define GDK_IS_MIR_CURSOR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_CURSOR))
#define GDK_IS_MIR_CURSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_MIR_CURSOR))
#define GDK_MIR_CURSOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_MIR_CURSOR, GdkMirCursorClass))
struct GdkMirCursor
{
GdkCursor parent_instance;
};
struct GdkMirCursorClass
{
GdkCursorClass parent_class;
};
G_DEFINE_TYPE (GdkMirCursor, gdk_mir_cursor, GDK_TYPE_CURSOR)
GdkCursor *
_gdk_mir_cursor_new (GdkDisplay *display, GdkCursorType type)
{
return g_object_new (GDK_TYPE_MIR_CURSOR, "display", display, "cursor-type", type, NULL);
}
cairo_surface_t *
gdk_mir_cursor_get_surface (GdkCursor *cursor,
gdouble *x_hot,
gdouble *y_hot)
{
g_printerr ("gdk_mir_cursor_get_surface\n");
return NULL;
}
static void
gdk_mir_cursor_init (GdkMirCursor *cursor)
{
}
static void
gdk_mir_cursor_class_init (GdkMirCursorClass *klass)
{
GdkCursorClass *cursor_class = GDK_CURSOR_CLASS (klass);
cursor_class->get_surface = gdk_mir_cursor_get_surface;
}

View File

@@ -0,0 +1,120 @@
/*
* Copyright © 2014 Canonical Ltd
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gdkdevicemanagerprivate.h"
#include "gdkdisplayprivate.h"
#include "gdkdeviceprivate.h"
#include "gdkmir.h"
#include "gdkmir-private.h"
typedef struct GdkMirDeviceManager GdkMirDeviceManager;
typedef struct GdkMirDeviceManagerClass GdkMirDeviceManagerClass;
#define GDK_TYPE_MIR_DEVICE_MANAGER (gdk_mir_device_manager_get_type ())
#define GDK_MIR_DEVICE_MANAGER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_MIR_DEVICE_MANAGER, GdkMirDeviceManager))
#define GDK_MIR_DEVICE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_MIR_DEVICE_MANAGER, GdkMirDeviceManagerClass))
#define GDK_IS_MIR_DEVICE_MANAGER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_DEVICE_MANAGER))
#define GDK_IS_MIR_DEVICE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_MIR_DEVICE_MANAGER))
#define GDK_MIR_DEVICE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_MIR_DEVICE_MANAGER, GdkMirDeviceManagerClass))
struct GdkMirDeviceManager
{
GdkDeviceManager parent_instance;
GdkDevice *pointer;
GdkDevice *keyboard;
};
struct GdkMirDeviceManagerClass
{
GdkDeviceManagerClass parent_class;
};
G_DEFINE_TYPE (GdkMirDeviceManager, gdk_mir_device_manager, GDK_TYPE_DEVICE_MANAGER)
GdkDeviceManager *
_gdk_mir_device_manager_new (GdkDisplay *display)
{
return g_object_new (GDK_TYPE_MIR_DEVICE_MANAGER, "display", display, NULL);
}
static GList *
gdk_mir_device_manager_list_devices (GdkDeviceManager *device_manager,
GdkDeviceType type)
{
//g_printerr ("gdk_mir_device_manager_list_devices (%u)\n", type);
GdkMirDeviceManager *dm = GDK_MIR_DEVICE_MANAGER (device_manager);
if (type == GDK_DEVICE_TYPE_MASTER)
{
GList *devices;
devices = g_list_append (NULL, dm->keyboard);
devices = g_list_append (devices, dm->pointer);
return devices;
}
return NULL;
}
static GdkDevice *
gdk_mir_device_manager_get_client_pointer (GdkDeviceManager *device_manager)
{
//g_printerr ("gdk_mir_device_manager_get_client_pointer\n");
return GDK_MIR_DEVICE_MANAGER (device_manager)->pointer;
}
GdkDevice *
_gdk_mir_device_manager_get_keyboard (GdkDeviceManager *device_manager)
{
return GDK_MIR_DEVICE_MANAGER (device_manager)->keyboard;
}
static void
gdk_mir_device_manager_init (GdkMirDeviceManager *device_manager)
{
}
static void
gdk_mir_device_manager_constructed (GObject *object)
{
GdkMirDeviceManager *device_manager = GDK_MIR_DEVICE_MANAGER (object);
device_manager->keyboard = _gdk_mir_keyboard_new (GDK_DEVICE_MANAGER (device_manager), "Mir Keyboard");
device_manager->pointer = _gdk_mir_pointer_new (GDK_DEVICE_MANAGER (device_manager), "Mir Pointer");
_gdk_device_set_associated_device (device_manager->keyboard, device_manager->pointer);
_gdk_device_set_associated_device (device_manager->pointer, device_manager->keyboard);
gdk_device_manager_get_display (GDK_DEVICE_MANAGER (device_manager))->core_pointer = device_manager->pointer;
G_OBJECT_CLASS (gdk_mir_device_manager_parent_class)->constructed (object);
}
static void
gdk_mir_device_manager_class_init (GdkMirDeviceManagerClass *klass)
{
GdkDeviceManagerClass *device_manager_class = GDK_DEVICE_MANAGER_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
device_manager_class->list_devices = gdk_mir_device_manager_list_devices;
device_manager_class->get_client_pointer = gdk_mir_device_manager_get_client_pointer;
object_class->constructed = gdk_mir_device_manager_constructed;
}

571
gdk/mir/gdkmirdisplay.c Normal file
View File

@@ -0,0 +1,571 @@
/*
* Copyright © 2014 Canonical Ltd
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gdkdisplayprivate.h"
#include "gdkinternals.h"
#include "gdkmir.h"
#include "gdkmir-private.h"
#define GDK_MIR_DISPLAY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DISPLAY_MIR, GdkMirDisplay))
#define GDK_MIR_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DISPLAY_MIR, GdkMirDisplayClass))
#define GDK_IS_MIR_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_MIR_DISPLAY))
#define GDK_MIR_DISPLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_MIR_DISPLAY, GdkMirDisplayImplClass))
typedef struct GdkMirDisplay
{
GdkDisplay parent_instance;
/* Connection to Mir server */
MirConnection *connection;
/* Event source */
GdkMirEventSource *event_source;
/* Serial number? */
gulong serial;
/* Screen information */
GdkScreen *screen;
GdkCursor *cursor;
GdkKeymap *keymap;
} GdkMirDisplay;
typedef struct GdkMirDisplayClass
{
GdkDisplayClass parent_class;
} GdkMirDisplayClass;
/**
* SECTION:mir_interaction
* @Short_description: Mir backend-specific functions
* @Title: Mir Interaction
*
* The functions in this section are specific to the GDK Mir backend.
* To use them, you need to include the <literal>&lt;gdk/gdkmir.h&gt;</literal>
* header and use the Mir-specific pkg-config files to build your
* application (either <literal>gdk-mir-3.0</literal> or
* <literal>gtk+-mir-3.0</literal>).
*
* To make your code compile with other GDK backends, guard backend-specific
* calls by an ifdef as follows. Since GDK may be built with multiple
* backends, you should also check for the backend that is in use (e.g. by
* using the GDK_IS_MIR_DISPLAY() macro).
* |[
* #ifdef GDK_WINDOWING_MIR
* if (GDK_IS_MIR_DISPLAY (display))
* {
* /&ast; make Mir-specific calls here &ast;/
* }
* else
* #endif
* #ifdef GDK_WINDOWING_X11
* if (GDK_IS_X11_DISPLAY (display))
* {
* /&ast; make X11-specific calls here &ast;/
* }
* else
* #endif
* g_error ("Unsupported GDK backend");
* ]|
*/
G_DEFINE_TYPE (GdkMirDisplay, gdk_mir_display, GDK_TYPE_DISPLAY)
GdkDisplay *
_gdk_mir_display_open (const gchar *display_name)
{
MirConnection *connection;
GdkMirDisplay *display;
g_printerr ("gdk_mir_display_open\n");
connection = mir_connect_sync (NULL, "GDK-Mir");
if (!connection)
return NULL;
if (!mir_connection_is_valid (connection))
{
g_printerr ("Failed to connect to Mir: %s\n", mir_connection_get_error_message (connection));
mir_connection_release (connection);
return NULL;
}
display = g_object_new (GDK_TYPE_MIR_DISPLAY, NULL);
display->connection = connection;
GDK_DISPLAY (display)->device_manager = _gdk_mir_device_manager_new (GDK_DISPLAY (display));
display->screen = _gdk_mir_screen_new (GDK_DISPLAY (display));
g_signal_emit_by_name (display, "opened");
return GDK_DISPLAY (display);
}
/**
* gdk_mir_display_get_mir_connection
* @display: (type GdkMirDisplay): a #GdkDisplay
*
* Returns the #MirConnection for a #GdkDisplay
*
* Returns: (transfer none): a #MirConnection
*
* Since: 3.14
*/
struct MirConnection *
gdk_mir_display_get_mir_connection (GdkDisplay *display)
{
g_return_val_if_fail (GDK_IS_MIR_DISPLAY (display), NULL);
return GDK_MIR_DISPLAY (display)->connection;
}
GdkMirEventSource *
_gdk_mir_display_get_event_source (GdkDisplay *display)
{
g_return_val_if_fail (GDK_IS_MIR_DISPLAY (display), NULL);
return GDK_MIR_DISPLAY (display)->event_source;
}
static void
gdk_mir_display_dispose (GObject *object)
{
GdkMirDisplay *display = GDK_MIR_DISPLAY (object);
g_object_unref (display->screen);
display->screen = NULL;
G_OBJECT_CLASS (gdk_mir_display_parent_class)->dispose (object);
}
static void
gdk_mir_display_finalize (GObject *object)
{
GdkMirDisplay *display = GDK_MIR_DISPLAY (object);
mir_connection_release (display->connection);
G_OBJECT_CLASS (gdk_mir_display_parent_class)->finalize (object);
}
static const gchar *
gdk_mir_display_get_name (GdkDisplay *display)
{
//g_printerr ("gdk_mir_display_get_name\n");
return "Mir";
}
static GdkScreen *
gdk_mir_display_get_default_screen (GdkDisplay *display)
{
//g_printerr ("gdk_mir_display_get_default_screen\n");
return GDK_MIR_DISPLAY (display)->screen;
}
static void
gdk_mir_display_beep (GdkDisplay *display)
{
g_printerr ("gdk_mir_display_beep\n");
/* No system level beep... */
}
static void
gdk_mir_display_sync (GdkDisplay *display)
{
g_printerr ("gdk_mir_display_sync\n");
}
static void
gdk_mir_display_flush (GdkDisplay *display)
{
g_printerr ("gdk_mir_display_flush\n");
}
static gboolean
gdk_mir_display_has_pending (GdkDisplay *display)
{
g_printerr ("gdk_mir_display_has_pending\n");
/* We don't need to poll for events - so nothing pending */
return FALSE;
}
static void
gdk_mir_display_queue_events (GdkDisplay *display)
{
//g_printerr ("gdk_mir_display_queue_events\n");
/* We don't need to poll for events - so don't do anything*/
}
static void
gdk_mir_display_make_default (GdkDisplay *display)
{
//g_printerr ("gdk_mir_display_make_default\n");
}
static GdkWindow *
gdk_mir_display_get_default_group (GdkDisplay *display)
{
g_printerr ("gdk_mir_display_get_default_group\n");
return NULL;
}
static gboolean
gdk_mir_display_supports_shapes (GdkDisplay *display)
{
g_printerr ("gdk_mir_display_supports_shapes\n");
/* Mir doesn't support shaped windows */
return FALSE;
}
static gboolean
gdk_mir_display_supports_input_shapes (GdkDisplay *display)
{
g_printerr ("gdk_mir_display_supports_input_shapes\n");
return FALSE;
}
static gboolean
gdk_mir_display_supports_composite (GdkDisplay *display)
{
g_printerr ("gdk_mir_display_supports_composite\n");
return FALSE;
}
static gboolean
gdk_mir_display_supports_clipboard_persistence (GdkDisplay *display)
{
g_printerr ("gdk_mir_display_supports_clipboard_persistence\n");
return FALSE;
}
static gboolean
gdk_mir_display_supports_cursor_alpha (GdkDisplay *display)
{
g_printerr ("gdk_mir_display_supports_cursor_alpha\n");
return FALSE;
}
static gboolean
gdk_mir_display_supports_cursor_color (GdkDisplay *display)
{
g_printerr ("gdk_mir_display_supports_cursor_color\n");
return FALSE;
}
static gboolean
gdk_mir_display_supports_selection_notification (GdkDisplay *display)
{
g_printerr ("gdk_mir_display_supports_selection_notification\n");
return FALSE;
}
static gboolean
gdk_mir_display_request_selection_notification (GdkDisplay *display,
GdkAtom selection)
{
g_printerr ("gdk_mir_display_request_selection_notification\n");
return FALSE;
}
static void
gdk_mir_display_store_clipboard (GdkDisplay *display,
GdkWindow *clipboard_window,
guint32 time_,
const GdkAtom *targets,
gint n_targets)
{
g_printerr ("gdk_mir_display_store_clipboard\n");
}
static void
gdk_mir_display_get_default_cursor_size (GdkDisplay *display,
guint *width,
guint *height)
{
g_printerr ("gdk_mir_display_get_default_cursor_size\n");
*width = *height = 32; // FIXME: Random value
}
static void
gdk_mir_display_get_maximal_cursor_size (GdkDisplay *display,
guint *width,
guint *height)
{
g_printerr ("gdk_mir_display_get_maximal_cursor_size\n");
*width = *height = 32; // FIXME: Random value
}
static GdkCursor *
gdk_mir_display_get_cursor_for_type (GdkDisplay *display,
GdkCursorType cursor_type)
{
//g_printerr ("gdk_mir_display_get_cursor_for_type (%u)\n", cursor_type);
/* We don't support configurable cursors */
return g_object_ref (GDK_MIR_DISPLAY (display)->cursor);
}
static GdkCursor *
gdk_mir_display_get_cursor_for_name (GdkDisplay *display,
const gchar *name)
{
g_printerr ("gdk_mir_display_get_cursor_for_name (\"%s\")\n", name);
/* We don't support configurable cursors */
return g_object_ref (GDK_MIR_DISPLAY (display)->cursor);
}
static GdkCursor *
gdk_mir_display_get_cursor_for_surface (GdkDisplay *display,
cairo_surface_t *surface,
gdouble x,
gdouble y)
{
g_printerr ("gdk_mir_display_get_cursor_for_surface (%f, %f)\n", x, y);
return NULL;
}
static GList *
gdk_mir_display_list_devices (GdkDisplay *display)
{
g_printerr ("gdk_mir_display_list_devices\n");
// FIXME: Should this access the device manager?
return NULL;
}
static GdkAppLaunchContext *
gdk_mir_display_get_app_launch_context (GdkDisplay *display)
{
g_printerr ("gdk_mir_display_get_app_launch_context\n");
return NULL;
}
static void
gdk_mir_display_before_process_all_updates (GdkDisplay *display)
{
g_printerr ("gdk_mir_display_before_process_all_updates\n");
}
static void
gdk_mir_display_after_process_all_updates (GdkDisplay *display)
{
g_printerr ("gdk_mir_display_after_process_all_updates\n");
}
static gulong
gdk_mir_display_get_next_serial (GdkDisplay *display)
{
//g_printerr ("gdk_mir_display_get_next_serial\n");
return GDK_MIR_DISPLAY (display)->serial++;
}
static void
gdk_mir_display_notify_startup_complete (GdkDisplay *display,
const gchar *startup_id)
{
//g_printerr ("gdk_mir_display_notify_startup_complete\n");
}
static void
gdk_mir_display_event_data_copy (GdkDisplay *display,
const GdkEvent *src,
GdkEvent *dst)
{
//g_printerr ("gdk_mir_display_event_data_copy\n");
}
static void
gdk_mir_display_event_data_free (GdkDisplay *display,
GdkEvent *event)
{
//g_printerr ("gdk_mir_display_event_data_free\n");
}
static void
gdk_mir_display_create_window_impl (GdkDisplay *display,
GdkWindow *window,
GdkWindow *real_parent,
GdkScreen *screen,
GdkEventMask event_mask,
GdkWindowAttr *attributes,
gint attributes_mask)
{
g_printerr ("gdk_mir_display_create_window_impl");
g_printerr (" window=%p", window);
g_printerr (" location=(%d, %d)", window->x, window->y);
g_printerr (" size=(%d, %d)", window->width, window->height);
g_printerr ("\n");
if (attributes->wclass != GDK_INPUT_OUTPUT)
return;
window->impl = _gdk_mir_window_impl_new ();
}
static GdkKeymap *
gdk_mir_display_get_keymap (GdkDisplay *display)
{
//g_printerr ("gdk_mir_display_get_keymap\n");
return GDK_MIR_DISPLAY (display)->keymap;
}
static void
gdk_mir_display_push_error_trap (GdkDisplay *display)
{
g_printerr ("gdk_mir_display_push_error_trap\n");
}
static gint
gdk_mir_display_pop_error_trap (GdkDisplay *display,
gboolean ignored)
{
g_printerr ("gdk_mir_display_pop_error_trap\n");
return 0;
}
static GdkWindow *
gdk_mir_display_get_selection_owner (GdkDisplay *display,
GdkAtom selection)
{
g_printerr ("gdk_mir_display_get_selection_owner\n");
return NULL;
}
static gboolean
gdk_mir_display_set_selection_owner (GdkDisplay *display,
GdkWindow *owner,
GdkAtom selection,
guint32 time,
gboolean send_event)
{
g_printerr ("gdk_mir_display_set_selection_owner\n");
return FALSE;
}
static void
gdk_mir_display_send_selection_notify (GdkDisplay *display,
GdkWindow *requestor,
GdkAtom selection,
GdkAtom target,
GdkAtom property,
guint32 time)
{
g_printerr ("gdk_mir_display_send_selection_notify\n");
}
static gint
gdk_mir_display_get_selection_property (GdkDisplay *display,
GdkWindow *requestor,
guchar **data,
GdkAtom *ret_type,
gint *ret_format)
{
g_printerr ("gdk_mir_display_get_selection_property\n");
return 0;
}
static void
gdk_mir_display_convert_selection (GdkDisplay *display,
GdkWindow *requestor,
GdkAtom selection,
GdkAtom target,
guint32 time)
{
g_printerr ("gdk_mir_display_convert_selection\n");
}
static gint
gdk_mir_display_text_property_to_utf8_list (GdkDisplay *display,
GdkAtom encoding,
gint format,
const guchar *text,
gint length,
gchar ***list)
{
g_printerr ("gdk_mir_display_text_property_to_utf8_list\n");
return 0;
}
static gchar *
gdk_mir_display_utf8_to_string_target (GdkDisplay *display,
const gchar *str)
{
g_printerr ("gdk_mir_display_utf8_to_string_target\n");
return NULL;
}
static void
gdk_mir_display_init (GdkMirDisplay *display)
{
display->event_source = _gdk_mir_event_source_new (GDK_DISPLAY (display));
display->cursor = _gdk_mir_cursor_new (GDK_DISPLAY (display), GDK_ARROW);
display->keymap = _gdk_mir_keymap_new ();
}
static void
gdk_mir_display_class_init (GdkMirDisplayClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkDisplayClass *display_class = GDK_DISPLAY_CLASS (klass);
object_class->dispose = gdk_mir_display_dispose;
object_class->finalize = gdk_mir_display_finalize;
display_class->window_type = gdk_mir_window_get_type ();
display_class->get_name = gdk_mir_display_get_name;
display_class->get_default_screen = gdk_mir_display_get_default_screen;
display_class->beep = gdk_mir_display_beep;
display_class->sync = gdk_mir_display_sync;
display_class->flush = gdk_mir_display_flush;
display_class->has_pending = gdk_mir_display_has_pending;
display_class->queue_events = gdk_mir_display_queue_events;
display_class->make_default = gdk_mir_display_make_default;
display_class->get_default_group = gdk_mir_display_get_default_group;
display_class->supports_shapes = gdk_mir_display_supports_shapes;
display_class->supports_input_shapes = gdk_mir_display_supports_input_shapes;
display_class->supports_composite = gdk_mir_display_supports_composite;
display_class->supports_clipboard_persistence = gdk_mir_display_supports_clipboard_persistence;
display_class->supports_cursor_alpha = gdk_mir_display_supports_cursor_alpha;
display_class->supports_cursor_color = gdk_mir_display_supports_cursor_color;
display_class->supports_selection_notification = gdk_mir_display_supports_selection_notification;
display_class->request_selection_notification = gdk_mir_display_request_selection_notification;
display_class->store_clipboard = gdk_mir_display_store_clipboard;
display_class->get_default_cursor_size = gdk_mir_display_get_default_cursor_size;
display_class->get_maximal_cursor_size = gdk_mir_display_get_maximal_cursor_size;
display_class->get_cursor_for_type = gdk_mir_display_get_cursor_for_type;
display_class->get_cursor_for_name = gdk_mir_display_get_cursor_for_name;
display_class->get_cursor_for_surface = gdk_mir_display_get_cursor_for_surface;
display_class->list_devices = gdk_mir_display_list_devices;
display_class->get_app_launch_context = gdk_mir_display_get_app_launch_context;
display_class->before_process_all_updates = gdk_mir_display_before_process_all_updates;
display_class->after_process_all_updates = gdk_mir_display_after_process_all_updates;
display_class->get_next_serial = gdk_mir_display_get_next_serial;
display_class->notify_startup_complete = gdk_mir_display_notify_startup_complete;
display_class->event_data_copy = gdk_mir_display_event_data_copy;
display_class->event_data_free = gdk_mir_display_event_data_free;
display_class->create_window_impl = gdk_mir_display_create_window_impl;
display_class->get_keymap = gdk_mir_display_get_keymap;
display_class->push_error_trap = gdk_mir_display_push_error_trap;
display_class->pop_error_trap = gdk_mir_display_pop_error_trap;
display_class->get_selection_owner = gdk_mir_display_get_selection_owner;
display_class->set_selection_owner = gdk_mir_display_set_selection_owner;
display_class->send_selection_notify = gdk_mir_display_send_selection_notify;
display_class->get_selection_property = gdk_mir_display_get_selection_property;
display_class->convert_selection = gdk_mir_display_convert_selection;
display_class->text_property_to_utf8_list = gdk_mir_display_text_property_to_utf8_list;
display_class->utf8_to_string_target = gdk_mir_display_utf8_to_string_target;
}

624
gdk/mir/gdkmireventsource.c Normal file
View File

@@ -0,0 +1,624 @@
/*
* Copyright © 2014 Canonical Ltd
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gdkinternals.h"
#include "gdkdisplayprivate.h"
#include "gdkmir.h"
#include "gdkmir-private.h"
struct _GdkMirWindowReference {
GdkMirEventSource *source;
GdkWindow *window;
gint ref_count;
};
typedef struct {
GdkMirWindowReference *window_ref;
MirEvent event;
} GdkMirQueuedEvent;
struct _GdkMirEventSource
{
GSource parent_instance;
GMutex mir_event_lock;
GQueue mir_events;
GdkDisplay *display;
};
static void
send_event (GdkWindow *window, GdkDevice *device, GdkEvent *event)
{
GdkDisplay *display;
GList *node;
gdk_event_set_device (event, device);
gdk_event_set_screen (event, gdk_display_get_screen (gdk_window_get_display (window), 0));
event->any.window = g_object_ref (window);
display = gdk_window_get_display (window);
node = _gdk_event_queue_append (display, event);
_gdk_windowing_got_event (display, node, event, _gdk_display_get_next_serial (display));
}
static void
set_key_event_string (GdkEventKey *event)
{
gunichar c = 0;
if (event->keyval != GDK_KEY_VoidSymbol)
c = gdk_keyval_to_unicode (event->keyval);
if (c)
{
gchar buf[7];
gint len;
gsize bytes_written;
/* Apply the control key - Taken from Xlib
*/
if (event->state & GDK_CONTROL_MASK)
{
if ((c >= '@' && c < '\177') || c == ' ') c &= 0x1F;
else if (c == '2')
{
event->string = g_memdup ("\0\0", 2);
event->length = 1;
buf[0] = '\0';
return;
}
else if (c >= '3' && c <= '7') c -= ('3' - '\033');
else if (c == '8') c = '\177';
else if (c == '/') c = '_' & 0x1F;
}
len = g_unichar_to_utf8 (c, buf);
buf[len] = '\0';
event->string = g_locale_from_utf8 (buf, len,
NULL, &bytes_written,
NULL);
if (event->string)
event->length = bytes_written;
}
else if (event->keyval == GDK_KEY_Escape)
{
event->length = 1;
event->string = g_strdup ("\033");
}
else if (event->keyval == GDK_KEY_Return ||
event->keyval == GDK_KEY_KP_Enter)
{
event->length = 1;
event->string = g_strdup ("\r");
}
if (!event->string)
{
event->length = 0;
event->string = g_strdup ("");
}
}
static void
generate_key_event (GdkWindow *window, GdkEventType type, guint state, guint keyval, guint16 keycode, gboolean is_modifier)
{
GdkEvent *event;
event = gdk_event_new (type);
event->key.state = state;
event->key.keyval = keyval;
event->key.hardware_keycode = keycode + 8;
event->key.is_modifier = is_modifier;
set_key_event_string (&event->key);
send_event (window, _gdk_mir_device_manager_get_keyboard (gdk_display_get_device_manager (gdk_window_get_display (window))), event);
}
static GdkDevice *
get_pointer (GdkWindow *window)
{
return gdk_device_manager_get_client_pointer (gdk_display_get_device_manager (gdk_window_get_display (window)));
}
static void
generate_button_event (GdkWindow *window, GdkEventType type, gdouble x, gdouble y, guint button, guint state)
{
GdkEvent *event;
event = gdk_event_new (type);
event->button.x = x;
event->button.y = y;
event->button.state = state;
event->button.button = button;
send_event (window, get_pointer (window), event);
}
static void
generate_scroll_event (GdkWindow *window, gdouble x, gdouble y, gdouble delta_x, gdouble delta_y, guint state)
{
GdkEvent *event;
event = gdk_event_new (GDK_SCROLL);
event->scroll.x = x;
event->scroll.y = y;
event->scroll.state = state;
event->scroll.direction = GDK_SCROLL_SMOOTH;
event->scroll.delta_x = delta_x;
event->scroll.delta_y = delta_y;
send_event (window, get_pointer (window), event);
}
static void
generate_motion_event (GdkWindow *window, gdouble x, gdouble y, guint state)
{
GdkEvent *event;
event = gdk_event_new (GDK_MOTION_NOTIFY);
event->motion.x = x;
event->motion.y = y;
event->motion.state = state;
event->motion.is_hint = FALSE;
send_event (window, get_pointer (window), event);
}
static void
generate_crossing_event (GdkWindow *window, GdkEventType type, gdouble x, gdouble y)
{
GdkEvent *event;
event = gdk_event_new (type);
event->crossing.x = x;
event->crossing.y = y;
event->crossing.mode = GDK_CROSSING_NORMAL;
event->crossing.detail = GDK_NOTIFY_ANCESTOR;
event->crossing.focus = TRUE;
send_event (window, get_pointer (window), event);
}
static void
generate_focus_event (GdkWindow *window, gboolean focused)
{
GdkEvent *event;
if (focused)
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FOCUSED);
else
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FOCUSED, 0);
event = gdk_event_new (GDK_FOCUS_CHANGE);
event->focus_change.send_event = FALSE;
event->focus_change.in = focused;
send_event (window, get_pointer (window), event);
}
static guint
get_modifier_state (unsigned int modifiers, unsigned int button_state)
{
guint modifier_state = 0;
if ((modifiers & mir_key_modifier_alt) != 0)
modifier_state |= GDK_MOD1_MASK;
if ((modifiers & mir_key_modifier_shift) != 0)
modifier_state |= GDK_SHIFT_MASK;
if ((modifiers & mir_key_modifier_ctrl) != 0)
modifier_state |= GDK_CONTROL_MASK;
if ((modifiers & mir_key_modifier_meta) != 0)
modifier_state |= GDK_SUPER_MASK;
if ((modifiers & mir_key_modifier_caps_lock) != 0)
modifier_state |= GDK_LOCK_MASK;
if ((button_state & mir_motion_button_primary) != 0)
modifier_state |= GDK_BUTTON1_MASK;
if ((button_state & mir_motion_button_secondary) != 0)
modifier_state |= GDK_BUTTON3_MASK;
if ((button_state & mir_motion_button_tertiary) != 0)
modifier_state |= GDK_BUTTON2_MASK;
return modifier_state;
}
/*
GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (event_data->window->impl);
MirMotionButton changed_button_state;
GdkEventType event_type;
gdouble x, y;
guint modifier_state;
gboolean is_modifier = FALSE;
*/
static void
handle_key_event (GdkWindow *window, const MirKeyEvent *event)
{
guint modifier_state;
gboolean is_modifier = FALSE;
modifier_state = get_modifier_state (event->modifiers, 0); // FIXME: Need to track button state
switch (event->action)
{
case mir_key_action_down:
case mir_key_action_up:
// FIXME: Convert keycode
// FIXME: is_modifier
generate_key_event (window,
event->action == mir_key_action_down ? GDK_KEY_PRESS : GDK_KEY_RELEASE,
modifier_state,
event->key_code,
event->scan_code,
is_modifier);
break;
default:
//case mir_key_action_multiple:
// FIXME
break;
}
}
static void
handle_motion_event (GdkWindow *window, const MirMotionEvent *event)
{
GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
gdouble x, y;
gboolean cursor_inside;
MirMotionButton button_state;
guint modifier_state;
GdkEventType event_type;
MirMotionButton changed_button_state;
_gdk_mir_window_impl_get_cursor_state (impl, &x, &y, &cursor_inside, &button_state);
if (event->pointer_count > 0)
{
x = event->pointer_coordinates[0].x;
y = event->pointer_coordinates[0].y;
}
modifier_state = get_modifier_state (event->modifiers, event->button_state);
/* The Mir events generate hover-exits even while inside the window so
counteract this by always generating an enter notify on all other events */
if (!cursor_inside && event->action != mir_motion_action_hover_exit)
{
cursor_inside = TRUE;
generate_crossing_event (window, GDK_ENTER_NOTIFY, x, y);
}
/* Update which window has focus */
_gdk_mir_pointer_set_location (get_pointer (window), x, y, window, modifier_state);
switch (event->action)
{
case mir_motion_action_down:
case mir_motion_action_up:
event_type = event->action == mir_motion_action_down ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE;
changed_button_state = button_state ^ event->button_state;
if ((changed_button_state & mir_motion_button_primary) != 0)
generate_button_event (window, event_type, x, y, GDK_BUTTON_PRIMARY, modifier_state);
if ((changed_button_state & mir_motion_button_secondary) != 0)
generate_button_event (window, event_type, x, y, GDK_BUTTON_SECONDARY, modifier_state);
if ((changed_button_state & mir_motion_button_tertiary) != 0)
generate_button_event (window, event_type, x, y, GDK_BUTTON_MIDDLE, modifier_state);
button_state = event->button_state;
break;
case mir_motion_action_scroll:
generate_scroll_event (window, x, y, event->pointer_coordinates[0].hscroll, event->pointer_coordinates[0].vscroll, modifier_state);
break;
case mir_motion_action_move: // move with button
case mir_motion_action_hover_move: // move without button
generate_motion_event (window, x, y, modifier_state);
break;
case mir_motion_action_hover_exit:
cursor_inside = FALSE;
generate_crossing_event (window, GDK_LEAVE_NOTIFY, x, y);
break;
}
_gdk_mir_window_impl_set_cursor_state (impl, x, y, cursor_inside, button_state);
}
static void
handle_surface_event (GdkWindow *window, const MirSurfaceEvent *event)
{
GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
switch (event->attrib)
{
case mir_surface_attrib_type:
break;
case mir_surface_attrib_state:
_gdk_mir_window_impl_set_surface_state (impl, event->value);
// FIXME: notify
break;
case mir_surface_attrib_swapinterval:
break;
case mir_surface_attrib_focus:
generate_focus_event (window, event->value != 0);
break;
default:
break;
}
}
static void
generate_configure_event (GdkWindow *window,
gint width,
gint height)
{
GdkEvent *event;
event = gdk_event_new (GDK_CONFIGURE);
event->configure.send_event = FALSE;
event->configure.width = width;
event->configure.height = height;
send_event (window, get_pointer (window), event);
}
static void
handle_resize_event (GdkWindow *window,
const MirResizeEvent *event)
{
window->width = event->width;
window->height = event->height;
_gdk_window_update_size (window);
generate_configure_event (window, event->width, event->height);
}
typedef struct
{
GdkWindow *window;
MirEvent event;
} EventData;
static void
gdk_mir_event_source_queue_event (GdkDisplay *display,
GdkWindow *window,
const MirEvent *event)
{
if (g_getenv ("GDK_MIR_LOG_EVENTS"))
_gdk_mir_print_event (event);
// FIXME: Only generate events if the window wanted them?
switch (event->type)
{
case mir_event_type_key:
handle_key_event (window, &event->key);
break;
case mir_event_type_motion:
handle_motion_event (window, &event->motion);
break;
case mir_event_type_surface:
handle_surface_event (window, &event->surface);
break;
case mir_event_type_resize:
handle_resize_event (window, &event->resize);
break;
default:
g_assert_not_reached ();
// FIXME?
break;
}
}
static GdkMirQueuedEvent *
gdk_mir_event_source_take_queued_event (GdkMirEventSource *source)
{
GdkMirQueuedEvent *queued_event;
g_mutex_lock (&source->mir_event_lock);
queued_event = g_queue_pop_head (&source->mir_events);
g_mutex_unlock (&source->mir_event_lock);
return queued_event;
}
static void
gdk_mir_queued_event_free (GdkMirQueuedEvent *event)
{
_gdk_mir_window_reference_unref (event->window_ref);
g_slice_free (GdkMirQueuedEvent, event);
}
static void
gdk_mir_event_source_convert_events (GdkMirEventSource *source)
{
GdkMirQueuedEvent *event;
while ((event = gdk_mir_event_source_take_queued_event (source)))
{
GdkWindow *window = event->window_ref->window;
/* The window may have been destroyed in the main thread while the
* event was being dispatched...
*/
if (window != NULL)
gdk_mir_event_source_queue_event (source->display, window, &event->event);
else
g_warning ("window was destroyed before event arrived...");
gdk_mir_queued_event_free (event);
}
}
static gboolean
gdk_mir_event_source_prepare (GSource *g_source,
gint *timeout)
{
GdkMirEventSource *source = (GdkMirEventSource *) g_source;
gboolean mir_events_in_queue;
if (_gdk_event_queue_find_first (source->display))
return TRUE;
g_mutex_lock (&source->mir_event_lock);
mir_events_in_queue = g_queue_get_length (&source->mir_events) > 0;
g_mutex_unlock (&source->mir_event_lock);
return mir_events_in_queue;
}
static gboolean
gdk_mir_event_source_check (GSource *g_source)
{
return gdk_mir_event_source_prepare (g_source, NULL);
}
static gboolean
gdk_mir_event_source_dispatch (GSource *g_source,
GSourceFunc callback,
gpointer user_data)
{
GdkMirEventSource *source = (GdkMirEventSource *) g_source;
GdkEvent *event;
/* First, run the queue of events from the thread */
gdk_mir_event_source_convert_events (source);
/* Next, dispatch one single event from the display's queue.
*
* If there is more than one event then we will soon find ourselves
* back here again.
*/
gdk_threads_enter ();
event = gdk_display_get_event (source->display);
if (event)
{
_gdk_event_emit (event);
gdk_event_free (event);
}
gdk_threads_leave ();
return TRUE;
}
static void
gdk_mir_event_source_finalize (GSource *g_source)
{
GdkMirEventSource *source = (GdkMirEventSource *) g_source;
GdkMirQueuedEvent *event;
while ((event = gdk_mir_event_source_take_queued_event (source)))
gdk_mir_queued_event_free (event);
g_mutex_clear (&source->mir_event_lock);
}
static GSourceFuncs gdk_mir_event_source_funcs = {
gdk_mir_event_source_prepare,
gdk_mir_event_source_check,
gdk_mir_event_source_dispatch,
gdk_mir_event_source_finalize
};
GdkMirEventSource *
_gdk_mir_event_source_new (GdkDisplay *display)
{
GdkMirEventSource *source;
GSource *g_source;
g_source = g_source_new (&gdk_mir_event_source_funcs, sizeof (GdkMirEventSource));
g_source_attach (g_source, NULL);
source = (GdkMirEventSource *) g_source;
g_mutex_init (&source->mir_event_lock);
source->display = display;
return source;
}
GdkMirWindowReference *
_gdk_mir_event_source_get_window_reference (GdkWindow *window)
{
static GQuark win_ref_quark;
GdkMirWindowReference *ref;
if G_UNLIKELY (!win_ref_quark)
win_ref_quark = g_quark_from_string ("GdkMirEventSource window reference");
ref = g_object_get_qdata (G_OBJECT (window), win_ref_quark);
if (!ref)
{
GdkMirEventSource *source;
source = _gdk_mir_display_get_event_source (gdk_window_get_display (window));
g_source_ref ((GSource *) source);
ref = g_slice_new (GdkMirWindowReference);
ref->window = window;
ref->source = source;
ref->ref_count = 0;
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &ref->window);
g_object_set_qdata_full (G_OBJECT (window), win_ref_quark,
ref, (GDestroyNotify) _gdk_mir_window_reference_unref);
}
g_atomic_int_inc (&ref->ref_count);
return ref;
}
void
_gdk_mir_window_reference_unref (GdkMirWindowReference *ref)
{
if (g_atomic_int_dec_and_test (&ref->ref_count))
{
if (ref->window)
g_object_remove_weak_pointer (G_OBJECT (ref->window), (gpointer *) &ref->window);
g_source_unref ((GSource *) ref->source);
g_slice_free (GdkMirWindowReference, ref);
}
}
void
_gdk_mir_event_source_queue (GdkMirWindowReference *window_ref,
const MirEvent *event)
{
GdkMirEventSource *source = window_ref->source;
GdkMirQueuedEvent *queued_event;
/* We are in the wrong thread right now. We absolutely cannot touch
* the window.
*
* We can do pretty much anything we want with the source, though...
*/
queued_event = g_slice_new (GdkMirQueuedEvent);
g_atomic_int_inc (&window_ref->ref_count);
queued_event->window_ref = window_ref;
queued_event->event = *event;
g_mutex_lock (&source->mir_event_lock);
g_queue_push_tail (&source->mir_events, queued_event);
g_mutex_unlock (&source->mir_event_lock);
g_main_context_wakeup (NULL);
}

173
gdk/mir/gdkmirkeyboard.c Normal file
View File

@@ -0,0 +1,173 @@
/*
* Copyright © 2014 Canonical Ltd
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gdkdeviceprivate.h"
typedef struct GdkMirKeyboard GdkMirKeyboard;
typedef struct GdkMirKeyboardClass GdkMirKeyboardClass;
#define GDK_TYPE_MIR_KEYBOARD (gdk_mir_keyboard_get_type ())
#define GDK_MIR_KEYBOARD(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_MIR_KEYBOARD, GdkMirKeyboard))
#define GDK_MIR_KEYBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_MIR_KEYBOARD, GdkMirKeyboardClass))
#define GDK_IS_MIR_KEYBOARD(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_KEYBOARD))
#define GDK_IS_MIR_KEYBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_MIR_KEYBOARD))
#define GDK_MIR_KEYBOARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_MIR_KEYBOARD, GdkMirKeyboardClass))
struct GdkMirKeyboard
{
GdkDevice parent_instance;
};
struct GdkMirKeyboardClass
{
GdkDeviceClass parent_class;
};
G_DEFINE_TYPE (GdkMirKeyboard, gdk_mir_keyboard, GDK_TYPE_DEVICE)
GdkDevice *
_gdk_mir_keyboard_new (GdkDeviceManager *device_manager, const gchar *name)
{
return g_object_new (GDK_TYPE_MIR_KEYBOARD,
"display", gdk_device_manager_get_display (device_manager),
"device-manager", device_manager,
"name", name,
"type", GDK_DEVICE_TYPE_MASTER,
"input-source", GDK_SOURCE_KEYBOARD,
"input-mode", GDK_MODE_SCREEN,
"has-cursor", FALSE,
NULL);
}
static gboolean
gdk_mir_keyboard_get_history (GdkDevice *device,
GdkWindow *window,
guint32 start,
guint32 stop,
GdkTimeCoord ***events,
gint *n_events)
{
g_printerr ("gdk_mir_keyboard_get_history\n");
return FALSE;
}
static void
gdk_mir_keyboard_get_state (GdkDevice *device,
GdkWindow *window,
gdouble *axes,
GdkModifierType *mask)
{
g_printerr ("gdk_mir_keyboard_get_state\n");
}
static void
gdk_mir_keyboard_set_window_cursor (GdkDevice *device,
GdkWindow *window,
GdkCursor *cursor)
{
//g_printerr ("gdk_mir_keyboard_set_window_cursor\n");
/* Keyboards don't have cursors... */
}
static void
gdk_mir_keyboard_warp (GdkDevice *device,
GdkScreen *screen,
gdouble x,
gdouble y)
{
//g_printerr ("gdk_mir_keyboard_warp\n");
/* Can't warp a keyboard... */
}
static void
gdk_mir_keyboard_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
gdouble *root_x,
gdouble *root_y,
gdouble *win_x,
gdouble *win_y,
GdkModifierType *mask)
{
g_printerr ("gdk_mir_keyboard_query_state\n");
}
static GdkGrabStatus
gdk_mir_keyboard_grab (GdkDevice *device,
GdkWindow *window,
gboolean owner_events,
GdkEventMask event_mask,
GdkWindow *confine_to,
GdkCursor *cursor,
guint32 time_)
{
//g_printerr ("gdk_mir_keyboard_grab\n");
/* Mir doesn't do grabs, so sure, you have the grab */
return GDK_GRAB_SUCCESS;
}
static void
gdk_mir_keyboard_ungrab (GdkDevice *device,
guint32 time_)
{
//g_printerr ("gdk_mir_keyboard_ungrab\n");
/* Mir doesn't do grabs */
}
static GdkWindow *
gdk_mir_keyboard_window_at_position (GdkDevice *device,
gdouble *win_x,
gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel)
{
//g_printerr ("gdk_mir_keyboard_window_at_position (%f, %f)\n", *win_x, *win_y);
/* Keyboard don't have locations... */
return NULL; // FIXME: Or the window with the keyboard focus?
}
static void
gdk_mir_keyboard_select_window_events (GdkDevice *device,
GdkWindow *window,
GdkEventMask event_mask)
{
g_printerr ("gdk_mir_keyboard_select_window_events\n");
}
static void
gdk_mir_keyboard_init (GdkMirKeyboard *device)
{
}
static void
gdk_mir_keyboard_class_init (GdkMirKeyboardClass *klass)
{
GdkDeviceClass *device_class = GDK_DEVICE_CLASS (klass);
device_class->get_history = gdk_mir_keyboard_get_history;
device_class->get_state = gdk_mir_keyboard_get_state;
device_class->set_window_cursor = gdk_mir_keyboard_set_window_cursor;
device_class->warp = gdk_mir_keyboard_warp;
device_class->query_state = gdk_mir_keyboard_query_state;
device_class->grab = gdk_mir_keyboard_grab;
device_class->ungrab = gdk_mir_keyboard_ungrab;
device_class->window_at_position = gdk_mir_keyboard_window_at_position;
device_class->select_window_events = gdk_mir_keyboard_select_window_events;
}

466
gdk/mir/gdkmirkeymap.c Normal file
View File

@@ -0,0 +1,466 @@
/*
* Copyright © 2014 Canonical Ltd
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <xkbcommon/xkbcommon.h>
#include "gdkkeysprivate.h"
typedef struct GdkMirKeymap GdkMirKeymap;
typedef struct GdkMirKeymapClass GdkMirKeymapClass;
#define GDK_TYPE_MIR_KEYMAP (gdk_mir_keymap_get_type ())
#define GDK_MIR_KEYMAP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_MIR_KEYMAP, GdkMirKeymap))
#define GDK_MIR_KEYMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_MIR_KEYMAP, GdkMirKeymapClass))
#define GDK_IS_MIR_KEYMAP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_KEYMAP))
#define GDK_IS_MIR_KEYMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_MIR_KEYMAP))
#define GDK_MIR_KEYMAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_MIR_KEYMAP, GdkMirKeymapClass))
struct GdkMirKeymap
{
GdkKeymap parent_instance;
struct xkb_keymap *xkb_keymap;
struct xkb_state *xkb_state;
PangoDirection *direction;
gboolean bidi;
};
struct GdkMirKeymapClass
{
GdkKeymapClass parent_class;
};
G_DEFINE_TYPE (GdkMirKeymap, gdk_mir_keymap, GDK_TYPE_KEYMAP)
GdkKeymap *
_gdk_mir_keymap_new (void)
{
return g_object_new (GDK_TYPE_MIR_KEYMAP, NULL);
}
static PangoDirection
gdk_mir_keymap_get_direction (GdkKeymap *keymap)
{
//g_printerr ("gdk_mir_keymap_get_direction\n");
GdkMirKeymap *mir_keymap = GDK_MIR_KEYMAP (keymap);
gint i;
for (i = 0; i < xkb_keymap_num_layouts (mir_keymap->xkb_keymap); i++)
{
if (xkb_state_layout_index_is_active (mir_keymap->xkb_state, i, XKB_STATE_LAYOUT_EFFECTIVE))
return mir_keymap->direction[i];
}
return PANGO_DIRECTION_NEUTRAL;
}
static gboolean
gdk_mir_keymap_have_bidi_layouts (GdkKeymap *keymap)
{
//g_printerr ("gdk_mir_keymap_have_bidi_layouts\n");
return FALSE;
}
static gboolean
gdk_mir_keymap_get_caps_lock_state (GdkKeymap *keymap)
{
//g_printerr ("gdk_mir_keymap_get_caps_lock_state\n");
return xkb_state_led_name_is_active (GDK_MIR_KEYMAP (keymap)->xkb_state, XKB_LED_NAME_CAPS);
}
static gboolean
gdk_mir_keymap_get_num_lock_state (GdkKeymap *keymap)
{
//g_printerr ("gdk_mir_keymap_get_num_lock_state\n");
return xkb_state_led_name_is_active (GDK_MIR_KEYMAP (keymap)->xkb_state, XKB_LED_NAME_NUM);
}
static gboolean
gdk_mir_keymap_get_entries_for_keyval (GdkKeymap *keymap,
guint keyval,
GdkKeymapKey **keys,
gint *n_keys)
{
//g_printerr ("gdk_mir_keymap_get_entries_for_keyval\n");
GdkMirKeymap *mir_keymap = GDK_MIR_KEYMAP (keymap);
GArray *key_array;
guint keycode;
key_array = g_array_new (FALSE, FALSE, sizeof (GdkKeymapKey));
for (keycode = 8; keycode < 255; keycode++) /* FIXME: min/max keycode */
{
gint num_layouts, layout;
num_layouts = xkb_keymap_num_layouts_for_key (mir_keymap->xkb_keymap, keycode);
for (layout = 0; layout < num_layouts; layout++)
{
gint num_levels, level;
num_levels = xkb_keymap_num_levels_for_key (mir_keymap->xkb_keymap, keycode, layout);
for (level = 0; level < num_levels; level++)
{
const xkb_keysym_t *syms;
gint num_syms, sym;
num_syms = xkb_keymap_key_get_syms_by_level (mir_keymap->xkb_keymap, keycode, layout, level, &syms);
for (sym = 0; sym < num_syms; sym++)
{
if (syms[sym] == keyval)
{
GdkKeymapKey key;
key.keycode = keycode;
key.group = layout;
key.level = level;
g_array_append_val (key_array, key);
}
}
}
}
}
*n_keys = key_array->len;
*keys = (GdkKeymapKey*) g_array_free (key_array, FALSE);
return TRUE;
}
static gboolean
gdk_mir_keymap_get_entries_for_keycode (GdkKeymap *keymap,
guint hardware_keycode,
GdkKeymapKey **keys,
guint **keyvals,
gint *n_entries)
{
//g_printerr ("gdk_mir_keymap_get_entries_for_keycode\n");
GdkMirKeymap *mir_keymap = GDK_MIR_KEYMAP (keymap);
gint num_layouts, layout;
gint num_entries;
gint i;
num_layouts = xkb_keymap_num_layouts_for_key (mir_keymap->xkb_keymap, hardware_keycode);
num_entries = 0;
for (layout = 0; layout < num_layouts; layout++)
num_entries += xkb_keymap_num_levels_for_key (mir_keymap->xkb_keymap, hardware_keycode, layout);
if (n_entries)
*n_entries = num_entries;
if (keys)
*keys = g_new0 (GdkKeymapKey, num_entries);
if (keyvals)
*keyvals = g_new0 (guint, num_entries);
i = 0;
for (layout = 0; layout < num_layouts; layout++)
{
gint num_levels, level;
num_levels = xkb_keymap_num_levels_for_key (mir_keymap->xkb_keymap, hardware_keycode, layout);
for (level = 0; level < num_levels; level++)
{
const xkb_keysym_t *syms;
int num_syms;
num_syms = xkb_keymap_key_get_syms_by_level (mir_keymap->xkb_keymap, hardware_keycode, layout, 0, &syms);
if (keys)
{
(*keys)[i].keycode = hardware_keycode;
(*keys)[i].group = layout;
(*keys)[i].level = level;
}
if (keyvals && num_syms > 0)
(*keyvals)[i] = syms[0];
i++;
}
}
return num_entries > 0;
}
static guint
gdk_mir_keymap_lookup_key (GdkKeymap *keymap,
const GdkKeymapKey *key)
{
//g_printerr ("gdk_mir_keymap_lookup_key\n");
GdkMirKeymap *mir_keymap = GDK_MIR_KEYMAP (keymap);
const xkb_keysym_t *syms;
int num_syms;
num_syms = xkb_keymap_key_get_syms_by_level (mir_keymap->xkb_keymap,
key->keycode,
key->group,
key->level,
&syms);
if (num_syms > 0)
return syms[0];
else
return XKB_KEY_NoSymbol;
}
static guint32
get_xkb_modifiers (struct xkb_keymap *xkb_keymap,
GdkModifierType state)
{
guint32 mods = 0;
if (state & GDK_SHIFT_MASK)
mods |= 1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_SHIFT);
if (state & GDK_LOCK_MASK)
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)
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, "Mod2");
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");
return mods;
}
static GdkModifierType
get_gdk_modifiers (struct xkb_keymap *xkb_keymap,
guint32 mods)
{
GdkModifierType state = 0;
if (mods & (1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_SHIFT)))
state |= GDK_SHIFT_MASK;
if (mods & (1 << xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_CAPS)))
state |= GDK_LOCK_MASK;
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, "Mod2")))
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;
return state;
}
static gboolean
gdk_mir_keymap_translate_keyboard_state (GdkKeymap *keymap,
guint hardware_keycode,
GdkModifierType state,
gint group,
guint *keyval,
gint *effective_group,
gint *effective_level,
GdkModifierType *consumed_modifiers)
{
//g_printerr ("gdk_mir_keymap_translate_keyboard_state\n");
GdkMirKeymap *mir_keymap = GDK_MIR_KEYMAP (keymap);
struct xkb_state *xkb_state;
guint32 modifiers;
guint32 consumed;
xkb_layout_index_t layout;
xkb_level_index_t level;
xkb_keysym_t sym;
modifiers = get_xkb_modifiers (mir_keymap->xkb_keymap, state);
xkb_state = xkb_state_new (mir_keymap->xkb_keymap);
xkb_state_update_mask (xkb_state, modifiers, 0, 0, group, 0, 0);
layout = xkb_state_key_get_layout (xkb_state, hardware_keycode);
level = xkb_state_key_get_level (xkb_state, hardware_keycode, layout);
sym = xkb_state_key_get_one_sym (xkb_state, hardware_keycode);
consumed = modifiers & ~xkb_state_mod_mask_remove_consumed (xkb_state, hardware_keycode, modifiers);
xkb_state_unref (xkb_state);
if (keyval)
*keyval = sym;
if (effective_group)
*effective_group = layout;
if (effective_level)
*effective_level = level;
if (consumed_modifiers)
*consumed_modifiers = get_gdk_modifiers (mir_keymap->xkb_keymap, consumed);
return TRUE;
}
static void
gdk_mir_keymap_add_virtual_modifiers (GdkKeymap *keymap,
GdkModifierType *state)
{
//g_printerr ("gdk_mir_keymap_add_virtual_modifiers\n");
// FIXME: What is this?
}
static gboolean
gdk_mir_keymap_map_virtual_modifiers (GdkKeymap *keymap,
GdkModifierType *state)
{
//g_printerr ("gdk_mir_keymap_map_virtual_modifiers\n");
// FIXME: What is this?
return TRUE;
}
static guint
gdk_mir_keymap_get_modifier_state (GdkKeymap *keymap)
{
//g_printerr ("gdk_mir_keymap_get_modifier_state\n");
GdkMirKeymap *mir_keymap = GDK_MIR_KEYMAP (keymap);
xkb_mod_mask_t mods;
mods = xkb_state_serialize_mods (mir_keymap->xkb_state, XKB_STATE_MODS_EFFECTIVE);
return get_gdk_modifiers (mir_keymap->xkb_keymap, mods);
}
static void
update_direction (GdkMirKeymap *keymap)
{
gint num_layouts;
gint *rtl;
guint key;
gboolean have_rtl, have_ltr;
gint i;
num_layouts = xkb_keymap_num_layouts (keymap->xkb_keymap);
g_free (keymap->direction);
keymap->direction = g_new0 (PangoDirection, num_layouts);
rtl = g_new0 (gint, num_layouts);
for (key = 8; key < 255; key++) /* FIXME: min/max keycode */
{
gint layouts;
gint layout;
layouts = xkb_keymap_num_layouts_for_key (keymap->xkb_keymap, key);
for (layout = 0; layout < layouts; layout++)
{
const xkb_keysym_t *syms;
gint num_syms;
gint sym;
num_syms = xkb_keymap_key_get_syms_by_level (keymap->xkb_keymap, key, layout, 0, &syms);
for (sym = 0; sym < num_syms; sym++)
{
PangoDirection dir;
dir = pango_unichar_direction (xkb_keysym_to_utf32 (syms[sym]));
switch (dir)
{
case PANGO_DIRECTION_RTL:
rtl[layout]++;
break;
case PANGO_DIRECTION_LTR:
rtl[layout]--;
break;
default:
break;
}
}
}
}
have_rtl = have_ltr = FALSE;
for (i = 0; i < num_layouts; i++)
{
if (rtl[i] > 0)
{
keymap->direction[i] = PANGO_DIRECTION_RTL;
have_rtl = TRUE;
}
else
{
keymap->direction[i] = PANGO_DIRECTION_LTR;
have_ltr = TRUE;
}
}
if (have_rtl && have_ltr)
keymap->bidi = TRUE;
g_free (rtl);
}
static void
gdk_mir_keymap_init (GdkMirKeymap *keymap)
{
struct xkb_context *context;
struct xkb_rule_names names;
context = xkb_context_new (0);
names.rules = "evdev";
names.model = "pc105";
names.layout = "us";
names.variant = "";
names.options = "";
keymap->xkb_keymap = xkb_keymap_new_from_names (context, &names, 0);
keymap->xkb_state = xkb_state_new (keymap->xkb_keymap);
xkb_context_unref (context);
update_direction (keymap);
}
static void
gdk_mir_keymap_finalize (GObject *object)
{
GdkMirKeymap *keymap = GDK_MIR_KEYMAP (object);
xkb_keymap_unref (keymap->xkb_keymap);
xkb_state_unref (keymap->xkb_state);
g_free (keymap->direction);
G_OBJECT_CLASS (gdk_mir_keymap_parent_class)->finalize (object);
}
static void
gdk_mir_keymap_class_init (GdkMirKeymapClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkKeymapClass *keymap_class = GDK_KEYMAP_CLASS (klass);
object_class->finalize = gdk_mir_keymap_finalize;
keymap_class->get_direction = gdk_mir_keymap_get_direction;
keymap_class->have_bidi_layouts = gdk_mir_keymap_have_bidi_layouts;
keymap_class->get_caps_lock_state = gdk_mir_keymap_get_caps_lock_state;
keymap_class->get_num_lock_state = gdk_mir_keymap_get_num_lock_state;
keymap_class->get_entries_for_keyval = gdk_mir_keymap_get_entries_for_keyval;
keymap_class->get_entries_for_keycode = gdk_mir_keymap_get_entries_for_keycode;
keymap_class->lookup_key = gdk_mir_keymap_lookup_key;
keymap_class->translate_keyboard_state = gdk_mir_keymap_translate_keyboard_state;
keymap_class->add_virtual_modifiers = gdk_mir_keymap_add_virtual_modifiers;
keymap_class->map_virtual_modifiers = gdk_mir_keymap_map_virtual_modifiers;
keymap_class->get_modifier_state = gdk_mir_keymap_get_modifier_state;
}

250
gdk/mir/gdkmirpointer.c Normal file
View File

@@ -0,0 +1,250 @@
/*
* Copyright © 2014 Canonical Ltd
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gdkdeviceprivate.h"
#include "gdkscreen.h"
#include "gdkwindow.h"
typedef struct GdkMirPointer GdkMirPointer;
typedef struct GdkMirPointerClass GdkMirPointerClass;
#define GDK_TYPE_MIR_POINTER (gdk_mir_pointer_get_type ())
#define GDK_MIR_POINTER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_MIR_POINTER, GdkMirPointer))
#define GDK_MIR_POINTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_MIR_POINTER, GdkMirPointerClass))
#define GDK_IS_MIR_POINTER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_POINTER))
#define GDK_IS_MIR_POINTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_MIR_POINTER))
#define GDK_MIR_POINTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_MIR_POINTER, GdkMirPointerClass))
struct GdkMirPointer
{
GdkDevice parent_instance;
/* Location of pointer */
gdouble x;
gdouble y;
/* Window this pointer is over */
GdkWindow *over_window;
/* Current modifier mask */
GdkModifierType modifier_mask;
};
struct GdkMirPointerClass
{
GdkDeviceClass parent_class;
};
G_DEFINE_TYPE (GdkMirPointer, gdk_mir_pointer, GDK_TYPE_DEVICE)
GdkDevice *
_gdk_mir_pointer_new (GdkDeviceManager *device_manager, const gchar *name)
{
return g_object_new (GDK_TYPE_MIR_POINTER,
"display", gdk_device_manager_get_display (device_manager),
"device-manager", device_manager,
"name", name,
"type", GDK_DEVICE_TYPE_MASTER,
"input-source", GDK_SOURCE_MOUSE,
"input-mode", GDK_MODE_SCREEN,
"has-cursor", TRUE,
NULL);
}
void
_gdk_mir_pointer_set_location (GdkDevice *pointer,
gdouble x,
gdouble y,
GdkWindow *window,
GdkModifierType mask)
{
GdkMirPointer *p = GDK_MIR_POINTER (pointer);
p->x = x;
p->y = y;
if (p->over_window)
g_object_unref (p->over_window);
p->over_window = g_object_ref (window);
p->modifier_mask = mask;
}
static gboolean
gdk_mir_pointer_get_history (GdkDevice *device,
GdkWindow *window,
guint32 start,
guint32 stop,
GdkTimeCoord ***events,
gint *n_events)
{
g_printerr ("gdk_mir_pointer_get_history\n");
return FALSE;
}
static void
gdk_mir_pointer_get_state (GdkDevice *device,
GdkWindow *window,
gdouble *axes,
GdkModifierType *mask)
{
//g_printerr ("gdk_mir_pointer_get_state\n");
GdkMirPointer *p = GDK_MIR_POINTER (device);
gdouble x, y;
gdk_window_get_device_position_double (window, device, &x, &y, mask);
if (axes)
{
axes[0] = p->x;
axes[1] = p->y;
}
}
static void
gdk_mir_pointer_set_window_cursor (GdkDevice *device,
GdkWindow *window,
GdkCursor *cursor)
{
//g_printerr ("gdk_mir_pointer_set_window_cursor\n");
/* Mir doesn't support cursors */
}
static void
gdk_mir_pointer_warp (GdkDevice *device,
GdkScreen *screen,
gdouble x,
gdouble y)
{
//g_printerr ("gdk_mir_pointer_warp\n");
/* Mir doesn't support warping */
}
static void
gdk_mir_pointer_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
gdouble *root_x,
gdouble *root_y,
gdouble *win_x,
gdouble *win_y,
GdkModifierType *mask)
{
//g_printerr ("gdk_mir_pointer_query_state\n");
GdkMirPointer *p = GDK_MIR_POINTER (device);
if (root_window)
*root_window = gdk_screen_get_root_window (gdk_display_get_default_screen (gdk_device_get_display (device)));
if (child_window)
*child_window = p->over_window;
if (root_x)
*root_x = p->x;
if (root_y)
*root_y = p->y;
if (win_x)
*win_x = p->x; // FIXME
if (win_y)
*win_y = p->y;
if (mask)
*mask = p->modifier_mask;
}
static GdkGrabStatus
gdk_mir_pointer_grab (GdkDevice *device,
GdkWindow *window,
gboolean owner_events,
GdkEventMask event_mask,
GdkWindow *confine_to,
GdkCursor *cursor,
guint32 time_)
{
//g_printerr ("gdk_mir_pointer_grab\n");
/* Mir doesn't do grabs, so sure, you have the grab */
return GDK_GRAB_SUCCESS;
}
static void
gdk_mir_pointer_ungrab (GdkDevice *device,
guint32 time_)
{
//g_printerr ("gdk_mir_pointer_ungrab\n");
/* Mir doesn't do grabs */
}
static GdkWindow *
gdk_mir_pointer_window_at_position (GdkDevice *device,
gdouble *win_x,
gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel)
{
//g_printerr ("gdk_mir_pointer_window_at_position\n");
GdkMirPointer *p = GDK_MIR_POINTER (device);
if (win_x)
*win_x = p->x;
if (win_y)
*win_y = p->y;
if (mask)
*mask = p->modifier_mask;
return p->over_window;
}
static void
gdk_mir_pointer_select_window_events (GdkDevice *device,
GdkWindow *window,
GdkEventMask event_mask)
{
g_printerr ("gdk_mir_pointer_select_window_events\n");
// FIXME?
}
static void
gdk_mir_pointer_init (GdkMirPointer *device)
{
}
static void
gdk_mir_pointer_finalize (GObject *object)
{
GdkMirPointer *p = GDK_MIR_POINTER (object);
if (p->over_window)
g_object_unref (p->over_window);
G_OBJECT_CLASS (gdk_mir_pointer_parent_class)->finalize (object);
}
static void
gdk_mir_pointer_class_init (GdkMirPointerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkDeviceClass *device_class = GDK_DEVICE_CLASS (klass);
object_class->finalize = gdk_mir_pointer_finalize;
device_class->get_history = gdk_mir_pointer_get_history;
device_class->get_state = gdk_mir_pointer_get_state;
device_class->set_window_cursor = gdk_mir_pointer_set_window_cursor;
device_class->warp = gdk_mir_pointer_warp;
device_class->query_state = gdk_mir_pointer_query_state;
device_class->grab = gdk_mir_pointer_grab;
device_class->ungrab = gdk_mir_pointer_ungrab;
device_class->window_at_position = gdk_mir_pointer_window_at_position;
device_class->select_window_events = gdk_mir_pointer_select_window_events;
}

720
gdk/mir/gdkmirscreen.c Normal file
View File

@@ -0,0 +1,720 @@
/*
* Copyright © 2014 Canonical Ltd
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
#include "gdkscreenprivate.h"
#include "gdkdisplayprivate.h"
#include "gdkvisualprivate.h"
#include "gdkinternals.h"
#include "gdkmir.h"
#include "gdkmir-private.h"
#define VISUAL_TYPE GDK_VISUAL_TRUE_COLOR
#define VISUAL_DEPTH 32
typedef struct GdkMirScreen GdkMirScreen;
typedef struct GdkMirScreenClass GdkMirScreenClass;
#define GDK_TYPE_MIR_SCREEN (gdk_mir_screen_get_type ())
#define GDK_MIR_SCREEN(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_MIR_SCREEN, GdkMirScreen))
#define GDK_MIR_SCREEN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_MIR_SCREEN, GdkMirScreenClass))
#define GDK_IS_MIR_SCREEN(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_SCREEN))
#define GDK_IS_MIR_SCREEN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_MIR_SCREEN))
#define GDK_MIR_SCREEN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_MIR_SCREEN, GdkMirScreenClass))
struct GdkMirScreen
{
GdkScreen parent_instance;
/* Display this screen is running on */
GdkDisplay *display;
/* Current monitor configuration */
MirDisplayConfiguration *display_config;
GdkVisual *visual;
GdkWindow *root_window;
};
struct GdkMirScreenClass
{
GdkScreenClass parent_class;
};
G_DEFINE_TYPE (GdkMirScreen, gdk_mir_screen, GDK_TYPE_SCREEN)
static MirConnection *
get_connection (GdkMirScreen *screen)
{
return gdk_mir_display_get_mir_connection (GDK_DISPLAY (screen->display));
}
static void
get_screen_size (MirDisplayConfiguration *config, gint *width, gint *height)
{
uint32_t i;
*width = 0;
*height = 0;
if (!config)
return;
for (i = 0; i < config->num_outputs; i++)
{
MirDisplayOutput *o = &config->outputs[i];
gint w, h;
if (!o->used)
continue;
w = o->position_x + o->modes[o->current_mode].horizontal_resolution;
if (w > *width)
*width = w;
h = o->position_y + o->modes[o->current_mode].vertical_resolution;
if (h > *height)
*height = h;
}
}
static void
update_display_config (GdkMirScreen *screen)
{
gdk_mir_display_get_mir_connection (GDK_DISPLAY (screen->display));
mir_display_config_destroy (screen->display_config);
screen->display_config = mir_connection_create_display_config (get_connection (screen));
}
static void
config_changed_cb (MirConnection *connection, void *data)
{
GdkMirScreen *screen = data;
gint old_width, old_height, new_width, new_height;
get_screen_size (screen->display_config, &old_width, &old_height);
update_display_config (screen);
get_screen_size (screen->display_config, &new_width, &new_height);
g_signal_emit_by_name (screen, "monitors-changed");
if (old_width > 0 && (old_width != new_width || old_height != new_height))
g_signal_emit_by_name (screen, "size-changed");
}
GdkScreen *
_gdk_mir_screen_new (GdkDisplay *display)
{
GdkMirScreen *screen;
screen = g_object_new (GDK_TYPE_MIR_SCREEN, NULL);
screen->display = display;
mir_connection_set_display_config_change_callback (get_connection (screen), config_changed_cb, display);
update_display_config (screen);
return GDK_SCREEN (screen);
}
static void
gdk_mir_screen_dispose (GObject *object)
{
G_OBJECT_CLASS (gdk_mir_screen_parent_class)->dispose (object);
}
static void
gdk_mir_screen_finalize (GObject *object)
{
G_OBJECT_CLASS (gdk_mir_screen_parent_class)->finalize (object);
}
static GdkDisplay *
gdk_mir_screen_get_display (GdkScreen *screen)
{
//g_printerr ("gdk_mir_screen_get_display\n");
return GDK_DISPLAY (GDK_MIR_SCREEN (screen)->display);
}
static MirDisplayOutput *
get_output (GdkScreen *screen, gint monitor_num)
{
MirDisplayConfiguration *config;
uint32_t i, j;
config = GDK_MIR_SCREEN (screen)->display_config;
for (i = 0, j = 0; i < config->num_outputs; i++)
{
if (!config->outputs[i].used)
continue;
if (j == monitor_num)
return &config->outputs[i];
j++;
}
return NULL;
}
static gint
gdk_mir_screen_get_width (GdkScreen *screen)
{
g_printerr ("gdk_mir_screen_get_width\n");
gint width, height;
get_screen_size (GDK_MIR_SCREEN (screen)->display_config, &width, &height);
return width;
}
static gint
gdk_mir_screen_get_height (GdkScreen *screen)
{
g_printerr ("gdk_mir_screen_get_height\n");
gint width, height;
get_screen_size (GDK_MIR_SCREEN (screen)->display_config, &width, &height);
return height;
}
static gint
gdk_mir_screen_get_width_mm (GdkScreen *screen)
{
g_printerr ("gdk_mir_screen_get_width_mm\n");
// FIXME: A combination of all screens?
return get_output (screen, 0)->physical_width_mm;
}
static gint
gdk_mir_screen_get_height_mm (GdkScreen *screen)
{
g_printerr ("gdk_mir_screen_get_height_mm\n");
// FIXME: A combination of all screens?
return get_output (screen, 0)->physical_height_mm;
}
static gint
gdk_mir_screen_get_number (GdkScreen *screen)
{
//g_printerr ("gdk_mir_screen_get_number\n");
/* There is only one screen... */
return 0;
}
static GdkWindow *
gdk_mir_screen_get_root_window (GdkScreen *screen)
{
//g_printerr ("gdk_mir_screen_get_root_window\n");
GdkMirScreen *s = GDK_MIR_SCREEN (screen);
gint width, height;
if (s->root_window)
return s->root_window;
get_screen_size (GDK_MIR_SCREEN (screen)->display_config, &width, &height);
s->root_window = _gdk_display_create_window (s->display);
s->root_window->impl = _gdk_mir_window_impl_new ();
s->root_window->impl_window = s->root_window;
s->root_window->visual = s->visual;
s->root_window->window_type = GDK_WINDOW_ROOT;
s->root_window->depth = VISUAL_DEPTH;
s->root_window->x = 0;
s->root_window->y = 0;
s->root_window->abs_x = 0;
s->root_window->abs_y = 0;
s->root_window->width = width;
s->root_window->height = height;
s->root_window->viewable = TRUE;
return s->root_window;
}
static gint
gdk_mir_screen_get_n_monitors (GdkScreen *screen)
{
//g_printerr ("gdk_mir_screen_get_n_monitors\n");
MirDisplayConfiguration *config;
uint32_t i;
gint count = 0;
config = GDK_MIR_SCREEN (screen)->display_config;
for (i = 0; i < config->num_outputs; i++)
if (config->outputs[i].used)
count++;
return count;
}
static gint
gdk_mir_screen_get_primary_monitor (GdkScreen *screen)
{
g_printerr ("gdk_mir_screen_get_primary_monitor\n");
return 0; //?
}
static gint
gdk_mir_screen_get_monitor_width_mm (GdkScreen *screen,
gint monitor_num)
{
g_printerr ("gdk_mir_screen_get_monitor_width_mm (%d)\n", monitor_num);
return get_output (screen, monitor_num)->physical_width_mm;
}
static gint
gdk_mir_screen_get_monitor_height_mm (GdkScreen *screen,
gint monitor_num)
{
g_printerr ("gdk_mir_screen_get_monitor_height_mm (%d)\n", monitor_num);
return get_output (screen, monitor_num)->physical_height_mm;
}
static gchar *
gdk_mir_screen_get_monitor_plug_name (GdkScreen *screen,
gint monitor_num)
{
g_printerr ("gdk_mir_screen_get_monitor_plug_name (%d)\n", monitor_num);
return NULL; //?
}
static void
gdk_mir_screen_get_monitor_geometry (GdkScreen *screen,
gint monitor_num,
GdkRectangle *dest)
{
//g_printerr ("gdk_mir_screen_get_monitor_geometry (%d)\n", monitor_num);
MirDisplayOutput *output;
MirDisplayMode *mode;
output = get_output (screen, monitor_num);
mode = &output->modes[output->current_mode];
dest->x = output->position_x;
dest->y = output->position_y;
dest->width = mode->horizontal_resolution;
dest->height = mode->vertical_resolution;
}
static void
gdk_mir_screen_get_monitor_workarea (GdkScreen *screen,
gint monitor_num,
GdkRectangle *dest)
{
//g_printerr ("gdk_mir_screen_get_monitor_workarea (%d)\n", monitor_num);
// FIXME: Don't know what this is
gdk_mir_screen_get_monitor_geometry (screen, monitor_num, dest);
}
static GList *
gdk_mir_screen_list_visuals (GdkScreen *screen)
{
g_printerr ("gdk_mir_screen_list_visuals\n");
return g_list_append (NULL, GDK_MIR_SCREEN (screen)->visual);
}
static GdkVisual *
gdk_mir_screen_get_system_visual (GdkScreen *screen)
{
//g_printerr ("gdk_mir_screen_get_system_visual\n");
return GDK_MIR_SCREEN (screen)->visual;
}
static GdkVisual *
gdk_mir_screen_get_rgba_visual (GdkScreen *screen)
{
//g_printerr ("gdk_mir_screen_get_rgba_visual\n");
return GDK_MIR_SCREEN (screen)->visual;
}
static gboolean
gdk_mir_screen_is_composited (GdkScreen *screen)
{
//g_printerr ("gdk_mir_screen_is_composited\n");
/* We're always composited */
return TRUE;
}
static gchar *
gdk_mir_screen_make_display_name (GdkScreen *screen)
{
g_printerr ("gdk_mir_screen_make_display_name\n");
return NULL; // FIXME
}
static GdkWindow *
gdk_mir_screen_get_active_window (GdkScreen *screen)
{
g_printerr ("gdk_mir_screen_get_active_window\n");
return NULL; // FIXME
}
static GList *
gdk_mir_screen_get_window_stack (GdkScreen *screen)
{
g_printerr ("gdk_mir_screen_get_window_stack\n");
return NULL; // FIXME
}
static void
gdk_mir_screen_broadcast_client_message (GdkScreen *screen,
GdkEvent *event)
{
g_printerr ("gdk_mir_screen_broadcast_client_message\n");
// FIXME
}
static gboolean
gdk_mir_screen_get_setting (GdkScreen *screen,
const gchar *name,
GValue *value)
{
//g_printerr ("gdk_mir_screen_get_setting (\"%s\")\n", name);
if (strcmp (name, "gtk-theme-name") == 0)
{
g_value_set_string (value, "Ambiance");
return TRUE;
}
if (strcmp (name, "gtk-font-name") == 0)
{
g_value_set_string (value, "Ubuntu");
return TRUE;
}
if (strcmp (name, "gtk-enable-animations") == 0)
{
g_value_set_boolean (value, TRUE);
return TRUE;
}
if (strcmp (name, "gtk-xft-dpi") == 0)
{
g_value_set_int (value, 96 * 1024);
return TRUE;
}
if (strcmp (name, "gtk-xft-antialias") == 0)
{
g_value_set_int (value, TRUE);
return TRUE;
}
if (strcmp (name, "gtk-xft-hinting") == 0)
{
g_value_set_int (value, TRUE);
return TRUE;
}
if (strcmp (name, "gtk-xft-hintstyle") == 0)
{
g_value_set_static_string (value, "hintfull");
return TRUE;
}
if (strcmp (name, "gtk-xft-rgba") == 0)
{
g_value_set_static_string (value, "rgba");
return TRUE;
}
if (g_str_equal (name, "gtk-modules"))
{
g_value_set_string (value, NULL);
return TRUE;
}
if (g_str_equal (name, "gtk-application-prefer-dark-theme"))
{
g_value_set_boolean (value, FALSE);
return TRUE;
}
if (g_str_equal (name, "gtk-key-theme-name"))
{
g_value_set_string (value, NULL);
return TRUE;
}
if (g_str_equal (name, "gtk-double-click-time"))
{
g_value_set_int (value, 250);
return TRUE;
}
if (g_str_equal (name, "gtk-double-click-distance"))
{
g_value_set_int (value, 5);
return TRUE;
}
if (g_str_equal (name, "gtk-cursor-theme-name"))
{
g_value_set_string (value, "Raleigh");
return TRUE;
}
if (g_str_equal (name, "gtk-cursor-theme-size"))
{
g_value_set_int (value, 128);
return TRUE;
}
if (g_str_equal (name, "gtk-icon-theme-name"))
{
g_value_set_string (value, "hicolor");
return TRUE;
}
if (g_str_equal (name, "gtk-shell-shows-app-menu"))
{
g_value_set_boolean (value, FALSE);
return TRUE;
}
if (g_str_equal (name, "gtk-shell-shows-menubar"))
{
g_value_set_boolean (value, FALSE);
return TRUE;
}
if (g_str_equal (name, "gtk-shell-shows-desktop"))
{
g_value_set_boolean (value, FALSE);
return TRUE;
}
if (g_str_equal (name, "gtk-recent-files-enabled"))
{
g_value_set_boolean (value, FALSE);
return TRUE;
}
if (g_str_equal (name, "gtk-alternative-sort-arrows"))
{
g_value_set_boolean (value, FALSE);
return TRUE;
}
if (g_str_equal (name, "gtk-enable-accels"))
{
g_value_set_boolean (value, TRUE);
return TRUE;
}
if (g_str_equal (name, "gtk-enable-mnemonics"))
{
g_value_set_boolean (value, TRUE);
return TRUE;
}
if (g_str_equal (name, "gtk-menu-images"))
{
g_value_set_boolean (value, FALSE);
return TRUE;
}
if (g_str_equal (name, "gtk-button-images"))
{
g_value_set_boolean (value, FALSE);
return TRUE;
}
if (g_str_equal (name, "gtk-split-cursor"))
{
g_value_set_boolean (value, TRUE);
return TRUE;
}
if (g_str_equal (name, "gtk-im-module"))
{
g_value_set_string (value, NULL);
return TRUE;
}
if (g_str_equal (name, "gtk-menu-bar-accel"))
{
g_value_set_string (value, "F10");
return TRUE;
}
if (g_str_equal (name, "gtk-cursor-blink"))
{
g_value_set_boolean (value, TRUE);
return TRUE;
}
if (g_str_equal (name, "gtk-cursor-blink-time"))
{
g_value_set_int (value, 1200);
return TRUE;
}
if (g_str_equal (name, "gtk-cursor-blink-timeout"))
{
g_value_set_int (value, 10);
return TRUE;
}
if (g_str_equal (name, "gtk-entry-select-on-focus"))
{
g_value_set_boolean (value, FALSE);
return TRUE;
}
if (g_str_equal (name, "gtk-error-bell"))
{
g_value_set_boolean (value, FALSE);
return TRUE;
}
if (g_str_equal (name, "gtk-label-select-on-focus"))
{
g_value_set_boolean (value, FALSE);
return TRUE;
}
g_warning ("unknown property %s", name);
return FALSE;
}
static gint
gdk_mir_screen_visual_get_best_depth (GdkScreen *screen)
{
g_printerr ("gdk_mir_screen_visual_get_best_depth\n");
return VISUAL_DEPTH;
}
static GdkVisualType
gdk_mir_screen_visual_get_best_type (GdkScreen *screen)
{
g_printerr ("gdk_mir_screen_visual_get_best_type\n");
return VISUAL_TYPE;
}
static GdkVisual*
gdk_mir_screen_visual_get_best (GdkScreen *screen)
{
g_printerr ("gdk_mir_screen_visual_get_best\n");
return GDK_MIR_SCREEN (screen)->visual;
}
static GdkVisual*
gdk_mir_screen_visual_get_best_with_depth (GdkScreen *screen,
gint depth)
{
g_printerr ("gdk_mir_screen_visual_get_best_with_depth (%d)\n", depth);
return GDK_MIR_SCREEN (screen)->visual;
}
static GdkVisual*
gdk_mir_screen_visual_get_best_with_type (GdkScreen *screen,
GdkVisualType visual_type)
{
g_printerr ("gdk_mir_screen_visual_get_best_with_type (%d)\n", visual_type);
return GDK_MIR_SCREEN (screen)->visual;
}
static GdkVisual*
gdk_mir_screen_visual_get_best_with_both (GdkScreen *screen,
gint depth,
GdkVisualType visual_type)
{
g_printerr ("gdk_mir_screen_visual_get_best_with_both\n");
return GDK_MIR_SCREEN (screen)->visual;
}
static void
gdk_mir_screen_query_depths (GdkScreen *screen,
gint **depths,
gint *count)
{
g_printerr ("gdk_mir_screen_query_depths\n");
static gint supported_depths[] = { VISUAL_DEPTH };
*depths = supported_depths;
*count = 1;
}
static void
gdk_mir_screen_query_visual_types (GdkScreen *screen,
GdkVisualType **visual_types,
gint *count)
{
g_printerr ("gdk_mir_screen_query_visual_types\n");
static GdkVisualType supported_visual_types[] = { VISUAL_TYPE };
*visual_types = supported_visual_types;
*count = 1;
}
static gint
gdk_mir_screen_get_monitor_scale_factor (GdkScreen *screen,
gint monitor_num)
{
//g_printerr ("gdk_mir_screen_get_monitor_scale_factor (%d)\n", monitor_num);
/* Don't support monitor scaling */
return 1;
}
static void
gdk_mir_screen_init (GdkMirScreen *screen)
{
screen->visual = g_object_new (GDK_TYPE_VISUAL, NULL);
screen->visual->screen = GDK_SCREEN (screen);
screen->visual->type = VISUAL_TYPE;
screen->visual->depth = VISUAL_DEPTH;
}
static void
gdk_mir_screen_class_init (GdkMirScreenClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkScreenClass *screen_class = GDK_SCREEN_CLASS (klass);
object_class->dispose = gdk_mir_screen_dispose;
object_class->finalize = gdk_mir_screen_finalize;
screen_class->get_display = gdk_mir_screen_get_display;
screen_class->get_width = gdk_mir_screen_get_width;
screen_class->get_height = gdk_mir_screen_get_height;
screen_class->get_width_mm = gdk_mir_screen_get_width_mm;
screen_class->get_height_mm = gdk_mir_screen_get_height_mm;
screen_class->get_number = gdk_mir_screen_get_number;
screen_class->get_root_window = gdk_mir_screen_get_root_window;
screen_class->get_n_monitors = gdk_mir_screen_get_n_monitors;
screen_class->get_primary_monitor = gdk_mir_screen_get_primary_monitor;
screen_class->get_monitor_width_mm = gdk_mir_screen_get_monitor_width_mm;
screen_class->get_monitor_height_mm = gdk_mir_screen_get_monitor_height_mm;
screen_class->get_monitor_plug_name = gdk_mir_screen_get_monitor_plug_name;
screen_class->get_monitor_geometry = gdk_mir_screen_get_monitor_geometry;
screen_class->get_monitor_workarea = gdk_mir_screen_get_monitor_workarea;
screen_class->list_visuals = gdk_mir_screen_list_visuals;
screen_class->get_system_visual = gdk_mir_screen_get_system_visual;
screen_class->get_rgba_visual = gdk_mir_screen_get_rgba_visual;
screen_class->is_composited = gdk_mir_screen_is_composited;
screen_class->make_display_name = gdk_mir_screen_make_display_name;
screen_class->get_active_window = gdk_mir_screen_get_active_window;
screen_class->get_window_stack = gdk_mir_screen_get_window_stack;
screen_class->broadcast_client_message = gdk_mir_screen_broadcast_client_message;
screen_class->get_setting = gdk_mir_screen_get_setting;
screen_class->visual_get_best_depth = gdk_mir_screen_visual_get_best_depth;
screen_class->visual_get_best_type = gdk_mir_screen_visual_get_best_type;
screen_class->visual_get_best = gdk_mir_screen_visual_get_best;
screen_class->visual_get_best_with_depth = gdk_mir_screen_visual_get_best_with_depth;
screen_class->visual_get_best_with_type = gdk_mir_screen_visual_get_best_with_type;
screen_class->visual_get_best_with_both = gdk_mir_screen_visual_get_best_with_both;
screen_class->query_depths = gdk_mir_screen_query_depths;
screen_class->query_visual_types = gdk_mir_screen_query_visual_types;
screen_class->get_monitor_scale_factor = gdk_mir_screen_get_monitor_scale_factor;
}

52
gdk/mir/gdkmirwindow.c Normal file
View File

@@ -0,0 +1,52 @@
/*
* Copyright © 2014 Canonical Ltd
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gdkinternals.h"
#include "gdkmir.h"
#define GDK_MIR_WINDOW(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WINDOW_MIR, GdkMirWindow))
#define GDK_MIR_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WINDOW_MIR, GdkMirWindowClass))
#define GDK_IS_WINDOW_MIR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WINDOW_MIR))
#define GDK_MIR_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WINDOW_MIR, GdkMirWindowClass))
typedef struct _GdkMirWindow GdkMirWindow;
typedef struct _GdkMirWindowClass GdkMirWindowClass;
struct _GdkMirWindow
{
GdkWindow parent_instance;
};
struct _GdkMirWindowClass
{
GdkWindowClass parent_class;
};
G_DEFINE_TYPE (GdkMirWindow, gdk_mir_window, GDK_TYPE_WINDOW)
static void
gdk_mir_window_init (GdkMirWindow *impl)
{
}
static void
gdk_mir_window_class_init (GdkMirWindowClass *klass)
{
}

1269
gdk/mir/gdkmirwindowimpl.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -3076,8 +3076,27 @@ gdk_event_translate (MSG *msg,
}
else
{
mmi->ptMaxTrackSize.x = 30000;
mmi->ptMaxTrackSize.y = 30000;
HMONITOR winmon;
MONITORINFO moninfo;
winmon = MonitorFromWindow (GDK_WINDOW_HWND (window), MONITOR_DEFAULTTONEAREST);
moninfo.cbSize = sizeof (moninfo);
if (GetMonitorInfoA (winmon, &moninfo))
{
mmi->ptMaxTrackSize.x = moninfo.rcWork.right - moninfo.rcWork.left;
mmi->ptMaxTrackSize.y = moninfo.rcWork.bottom - moninfo.rcWork.top;
}
else
{
/* Apparently, this is just a very big number (bigger than any widget
* could realistically be) to make sure the window is as big as
* possible when maximized.
*/
mmi->ptMaxTrackSize.x = 30000;
mmi->ptMaxTrackSize.y = 30000;
}
}
if (impl->hint_flags & (GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE))

View File

@@ -146,6 +146,8 @@ handle_special (guint vk,
*ksymp = GDK_KEY_Select; break;
case VK_PRINT:
*ksymp = GDK_KEY_Print; break;
case VK_SNAPSHOT:
*ksymp = GDK_KEY_Print; break;
case VK_EXECUTE:
*ksymp = GDK_KEY_Execute; break;
case VK_INSERT:

View File

@@ -186,6 +186,12 @@ _gdk_win32_window_change_property (GdkWindow *window,
format == 8 &&
mode == GDK_PROP_MODE_REPLACE)
{
if (type == _image_bmp && nelements < sizeof (BITMAPFILEHEADER))
{
g_warning ("Clipboard contains invalid bitmap data");
return;
}
if (type == _utf8_string)
{
if (!OpenClipboard (GDK_WINDOW_HWND (window)))

View File

@@ -1285,10 +1285,15 @@ _gdk_win32_selection_convert_to_dib (HGLOBAL hdata,
if (target == _image_bmp)
{
/* No conversion is needed, just strip the BITMAPFILEHEADER */
HGLOBAL hdatanew;
SIZE_T size = GlobalSize (hdata) - sizeof (BITMAPFILEHEADER);
guchar *ptr = GlobalLock (hdata);
SIZE_T size;
guchar *ptr;
g_return_val_if_fail (GlobalSize (hdata) >= sizeof (BITMAPFILEHEADER), NULL);
/* No conversion is needed, just strip the BITMAPFILEHEADER */
size = GlobalSize (hdata) - sizeof (BITMAPFILEHEADER);
ptr = GlobalLock (hdata);
memmove (ptr, ptr + sizeof (BITMAPFILEHEADER), size);
GlobalUnlock (hdata);

View File

@@ -456,7 +456,7 @@ gtk_entry_accessible_initialize (AtkObject *obj,
gtk_entry_accessible->priv->selection_bound = start_pos;
/* Set up signal callbacks */
g_signal_connect (entry, "insert-text", G_CALLBACK (insert_text_cb), NULL);
g_signal_connect_after (entry, "insert-text", G_CALLBACK (insert_text_cb), NULL);
g_signal_connect (entry, "delete-text", G_CALLBACK (delete_text_cb), NULL);
if (gtk_entry_get_visibility (entry))
@@ -1390,16 +1390,18 @@ insert_text_cb (GtkEditable *editable,
gint *position)
{
GtkEntryAccessible *accessible;
gint length;
if (new_text_length == 0)
return;
accessible = GTK_ENTRY_ACCESSIBLE (gtk_widget_get_accessible (GTK_WIDGET (editable)));
length = g_utf8_strlen (new_text, new_text_length);
g_signal_emit_by_name (accessible,
"text-changed::insert",
*position,
g_utf8_strlen (new_text, new_text_length));
*position - length,
length);
}
/* We connect to GtkEditable::delete-text, since it carries

View File

@@ -50,7 +50,8 @@ gtk_list_box_row_accessible_ref_state_set (AtkObject *obj)
if (widget != NULL)
{
parent = gtk_widget_get_parent (widget);
if (gtk_list_box_get_selection_mode (GTK_LIST_BOX (parent)) != GTK_SELECTION_NONE)
if (parent != NULL &&
gtk_list_box_get_selection_mode (GTK_LIST_BOX (parent)) != GTK_SELECTION_NONE)
atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE);
if (widget == (GtkWidget*)gtk_list_box_get_selected_row (GTK_LIST_BOX (parent)))

View File

@@ -50,9 +50,6 @@
* @Short_description: Manipulating stock icons
* @Title: Themeable Stock Images
*
* Browse the available stock icons using
* the “gtk3-demo” application.
*
* An icon factory manages a collection of #GtkIconSet; a #GtkIconSet manages a
* set of variants of a particular icon (i.e. a #GtkIconSet contains variants for
* different sizes and widget states). Icons in an icon factory are named by a

View File

@@ -339,7 +339,7 @@ gtk_application_impl_dbus_inhibit (GtkApplicationImpl *impl,
"Inhibit",
g_variant_new ("(s@usu)",
dbus->app_id,
gtk_application_impl_dbus_get_window_system_id (dbus, window),
window ? gtk_application_impl_dbus_get_window_system_id (dbus, window) : g_variant_new_uint32 (0),
reason,
flags),
G_DBUS_CALL_FLAGS_NONE,

View File

@@ -1477,10 +1477,13 @@ normalise_detailed_name (const gchar *detailed_action_name)
* @accels: (array zero-terminated=1): a list of accelerators in the format understood by
* gtk_accelerator_parse()
*
* Sets one or more keyboard accelerator that will trigger the
* Sets zero or more keyboard accelerators that will trigger the
* given action. The first item in @accels will be the primary
* accelerator, which may be displayed in the UI.
*
* To remove all accelerators for an action, use an empty, zero-terminated
* array for @accels.
*
* Since: 3.12
*/
void

View File

@@ -691,6 +691,18 @@ gtk_application_window_real_map (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_application_window_parent_class)->map (widget);
}
static void
gtk_application_window_real_unmap (GtkWidget *widget)
{
GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget);
/* XXX could eliminate this by tweaking gtk_window_unmap */
if (window->priv->menubar)
gtk_widget_unmap (window->priv->menubar);
GTK_WIDGET_CLASS (gtk_application_window_parent_class)->unmap (widget);
}
static void
gtk_application_window_real_forall_internal (GtkContainer *container,
gboolean include_internal,
@@ -811,6 +823,7 @@ gtk_application_window_class_init (GtkApplicationWindowClass *class)
widget_class->realize = gtk_application_window_real_realize;
widget_class->unrealize = gtk_application_window_real_unrealize;
widget_class->map = gtk_application_window_real_map;
widget_class->unmap = gtk_application_window_real_unmap;
object_class->get_property = gtk_application_window_get_property;
object_class->set_property = gtk_application_window_set_property;
object_class->dispose = gtk_application_window_dispose;

View File

@@ -2425,7 +2425,7 @@ gtk_assistant_accessible_get_n_children (AtkObject *accessible)
if (widget == NULL)
return 0;
return g_list_length (GTK_ASSISTANT (widget)->priv->pages) + 1;
return g_list_length (GTK_ASSISTANT (widget)->priv->pages) + 2;
}
static AtkObject *
@@ -2461,6 +2461,11 @@ gtk_assistant_accessible_ref_child (AtkObject *accessible,
child = priv->action_area;
title = NULL;
}
else if (index == n_pages + 1)
{
child = priv->headerbar;
title = NULL;
}
else
return NULL;

View File

@@ -2614,7 +2614,7 @@ gtk_box_set_center_widget (GtkBox *box,
*
* Retrieves the center widget of the box.
*
* Returns: the center widget
* Returns: (transfer none): the center widget
*
* Since: 3.12
*/

View File

@@ -101,9 +101,14 @@ select_swatch (GtkColorChooserWidget *cc,
return;
if (cc->priv->current != NULL)
gtk_widget_unset_state_flags (GTK_WIDGET (cc->priv->current), GTK_STATE_FLAG_SELECTED);
{
gtk_widget_unset_state_flags (GTK_WIDGET (cc->priv->current), GTK_STATE_FLAG_SELECTED);
gtk_widget_queue_draw (GTK_WIDGET (cc->priv->current));
}
gtk_widget_set_state_flags (GTK_WIDGET (swatch), GTK_STATE_FLAG_SELECTED, FALSE);
cc->priv->current = swatch;
gtk_widget_queue_draw (GTK_WIDGET (cc->priv->current));
gtk_color_swatch_get_rgba (swatch, &color);
g_settings_set (cc->priv->settings, "selected-color", "(bdddd)",

View File

@@ -2548,9 +2548,13 @@ gtk_combo_box_popdown (GtkComboBox *combo_box)
if (!gtk_widget_get_realized (GTK_WIDGET (combo_box)))
return;
if (!gtk_widget_is_drawable (priv->popup_window))
return;
if (priv->grab_keyboard)
gdk_device_ungrab (priv->grab_keyboard, GDK_CURRENT_TIME);
gdk_device_ungrab (priv->grab_pointer, GDK_CURRENT_TIME);
if (priv->grab_pointer)
gdk_device_ungrab (priv->grab_pointer, GDK_CURRENT_TIME);
gtk_device_grab_remove (priv->popup_window, priv->grab_pointer);
gtk_widget_hide (priv->popup_window);

View File

@@ -574,7 +574,6 @@ gtk_dialog_class_init (GtkDialogClass *class)
* content area of the dialog, as returned by
* gtk_dialog_get_content_area(), unless gtk_container_set_border_width()
* was called on that widget directly.
*
*/
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("content-area-border",
@@ -611,6 +610,14 @@ gtk_dialog_class_init (GtkDialogClass *class)
6,
GTK_PARAM_READABLE));
/**
* GtkDialog:action-area-border:
*
* The default border width used around the
* action area of the dialog, as returned by
* gtk_dialog_get_action_area(), unless gtk_container_set_border_width()
* was called on that widget directly.
*/
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("action-area-border",
P_("Action area border"),
@@ -668,8 +675,11 @@ update_spacings (GtkDialog *dialog)
NULL);
if (!_gtk_container_get_border_width_set (GTK_CONTAINER (priv->vbox)))
gtk_container_set_border_width (GTK_CONTAINER (priv->vbox),
content_area_border);
{
gtk_container_set_border_width (GTK_CONTAINER (priv->vbox),
content_area_border);
_gtk_container_set_border_width_set (GTK_CONTAINER (priv->vbox), FALSE);
}
if (!_gtk_box_get_spacing_set (GTK_BOX (priv->vbox)))
{
@@ -681,8 +691,11 @@ update_spacings (GtkDialog *dialog)
button_spacing);
if (!_gtk_container_get_border_width_set (GTK_CONTAINER (priv->action_area)))
gtk_container_set_border_width (GTK_CONTAINER (priv->action_area),
action_area_border);
{
gtk_container_set_border_width (GTK_CONTAINER (priv->action_area),
action_area_border);
_gtk_container_set_border_width_set (GTK_CONTAINER (priv->action_area), FALSE);
}
}
static void

View File

@@ -256,9 +256,7 @@ static void gtk_drag_selection_get (GtkWidget *widget,
guint32 time,
gpointer data);
static void gtk_drag_anim_destroy (GtkDragAnim *anim);
static gboolean gtk_drag_anim_tick (GtkWidget *widget,
GdkFrameClock *frame_clock,
gpointer data);
static gboolean gtk_drag_anim_timeout (gpointer data);
static void gtk_drag_remove_icon (GtkDragSourceInfo *info);
static void gtk_drag_source_info_destroy (GtkDragSourceInfo *info);
static void gtk_drag_add_update_idle (GtkDragSourceInfo *info);
@@ -1246,24 +1244,38 @@ gtk_drag_highlight_draw (GtkWidget *widget,
cairo_t *cr,
gpointer data)
{
int width = gtk_widget_get_allocated_width (widget);
int height = gtk_widget_get_allocated_height (widget);
GtkAllocation alloc;
GtkStyleContext *context;
if (GTK_IS_WINDOW (widget))
{
/* We don't want to draw the drag highlight around the
* CSD window decorations
*/
gtk_widget_get_allocation (gtk_bin_get_child (GTK_BIN (widget)), &alloc);
}
else
{
alloc.x = 0;
alloc.y = 0;
alloc.width = gtk_widget_get_allocated_width (widget);
alloc.height = gtk_widget_get_allocated_height (widget);
}
context = gtk_widget_get_style_context (widget);
gtk_style_context_save (context);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_DND);
gtk_render_frame (context, cr, 0, 0, width, height);
gtk_render_frame (context, cr, alloc.x, alloc.y, alloc.width, alloc.height);
gtk_style_context_restore (context);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); /* black */
cairo_set_line_width (cr, 1.0);
cairo_rectangle (cr,
0.5, 0.5,
width - 1, height - 1);
alloc.x + 0.5, alloc.y + 0.5,
alloc.width - 1, alloc.height - 1);
cairo_stroke (cr);
return FALSE;
@@ -3793,7 +3805,7 @@ gtk_drag_drop_finished (GtkDragSourceInfo *info,
* to respond really late, we still are OK.
*/
gtk_drag_clear_source_info (info->context);
gtk_widget_add_tick_callback (info->widget, gtk_drag_anim_tick, anim, (GDestroyNotify) gtk_drag_anim_destroy);
gdk_threads_add_timeout_full (G_PRIORITY_DEFAULT, 17, gtk_drag_anim_timeout, anim, (GDestroyNotify) gtk_drag_anim_destroy);
}
}
}
@@ -4024,13 +4036,13 @@ gtk_drag_anim_destroy (GtkDragAnim *anim)
}
static gboolean
gtk_drag_anim_tick (GtkWidget *widget,
GdkFrameClock *frame_clock,
gpointer data)
gtk_drag_anim_timeout (gpointer data)
{
GtkWidget *icon_window;
GtkDragAnim *anim = data;
GtkDragSourceInfo *info = anim->info;
GtkWidget *widget = info->widget;
GdkFrameClock *frame_clock = gtk_widget_get_frame_clock (widget);
gint64 current_time = gdk_frame_clock_get_frame_time (frame_clock);
int hot_x, hot_y;
double f = (current_time - anim->start_time) / (double) ANIM_TIME;

View File

@@ -3452,6 +3452,7 @@ gtk_entry_get_preferred_height_and_baseline_for_width (GtkWidget *widget,
_gtk_entry_get_borders (entry, &borders);
pango_layout_get_pixel_size (layout, NULL, &height);
height = MAX (height, PANGO_PIXELS (priv->ascent + priv->descent));
height += borders.top + borders.bottom;
baseline = pango_layout_get_baseline (layout) / PANGO_SCALE;

View File

@@ -1887,8 +1887,8 @@ gtk_header_bar_buildable_init (GtkBuildableIface *iface)
* @bar: A #GtkHeaderBar
* @child: the #GtkWidget to be added to @bar
*
* Adds @child to @box, packed with reference to the
* start of the @box.
* Adds @child to @bar, packed with reference to the
* start of the @bar.
*
* Since: 3.10
*/
@@ -1904,8 +1904,8 @@ gtk_header_bar_pack_start (GtkHeaderBar *bar,
* @bar: A #GtkHeaderBar
* @child: the #GtkWidget to be added to @bar
*
* Adds @child to @box, packed with reference to the
* end of the @box.
* Adds @child to @bar, packed with reference to the
* end of the @bar.
*
* Since: 3.10
*/

View File

@@ -1256,6 +1256,7 @@ load_themes (GtkIconTheme *icon_theme)
* in gnome is a pragmatic solution to prevent missing
* icons in GTK+ applications when run under, e.g. KDE.
*/
insert_theme (icon_theme, "Adwaita");
insert_theme (icon_theme, "gnome");
insert_theme (icon_theme, DEFAULT_THEME_NAME);
priv->themes = g_list_reverse (priv->themes);
@@ -5327,8 +5328,10 @@ gtk_icon_theme_lookup_by_gicon_for_scale (GtkIconTheme *icon_theme,
GList *list, *l;
GtkIconInfo *base_info, *emblem_info;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (GTK_IS_NUMERABLE_ICON (icon))
_gtk_numerable_icon_set_background_icon_size (GTK_NUMERABLE_ICON (icon), size / 2);
G_GNUC_END_IGNORE_DEPRECATIONS
base = g_emblemed_icon_get_icon (G_EMBLEMED_ICON (icon));
base_info = gtk_icon_theme_lookup_by_gicon_for_scale (icon_theme, base, size, scale, flags);

View File

@@ -496,8 +496,10 @@ gtk_list_box_get_selected_row (GtkListBox *list_box)
* @index_: the index of the row
*
* Gets the n:th child in the list (not counting headers).
* If @_index is negative or larger than the number of items in the
* list, %NULL is returned.
*
* Returns: (transfer none): the child #GtkWidget
* Returns: (transfer none): the child #GtkWidget or %NULL
*
* Since: 3.10
*/
@@ -513,7 +515,7 @@ gtk_list_box_get_row_at_index (GtkListBox *list_box,
priv = gtk_list_box_get_instance_private (list_box);
iter = g_sequence_get_iter_at_pos (priv->children, index_);
if (iter)
if (!g_sequence_iter_is_end (iter))
return g_sequence_get (iter);
return NULL;

View File

@@ -451,8 +451,10 @@ gtk_lock_button_clicked (GtkButton *button)
{
GtkLockButtonPrivate *priv = GTK_LOCK_BUTTON (button)->priv;
/* if we already have a pending interactive check, then do nothing */
if (priv->cancellable != NULL)
/* if we already have a pending interactive check or permission is not set,
* then do nothing
*/
if (priv->cancellable != NULL || priv->permission == NULL)
return;
if (g_permission_get_allowed (priv->permission))

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