Commit Graph

758 Commits

Author SHA1 Message Date
Emmanuele Bassi
74bd3f3810 quartz: Fix typo that broke debug builds 2016-08-22 09:23:02 +01:00
Matthias Clasen
82fd72a477 Opt in to structured logging
Define G_LOG_USE_STRUCTURED, so that all our g_debug, g_warning,
etc calls directly use structured logging and provide source information.
2016-07-22 23:13:20 -04:00
Matthias Clasen
0f476590fb Make gdk_event_get_pointer_emulated public
There is not strong reason to keep the getter private.
At the same time, strip _-prefixes from a few other GdkEvent
APIs. Update all callers.
2016-05-10 15:16:45 -04:00
Jonas Ådahl
1a4f000f3b gdk/dnd: Don't use default display when getting cursor
Always associate a drag context with a GdkDisplay and use that when
getting a cursor for a given action.

If we don't do this, dragging on a window that doesn't use the default
display will make us use cursors from the wrong display.

https://bugzilla.gnome.org/show_bug.cgi?id=765565
2016-04-26 23:03:24 +08:00
Frediano Ziglio
cf14fea5a8 Save scancode inside GdkEventPrivate
Windows save in hardware_keycode an information which is not so low
level and some application require the hardware scancode.
As Windows provides this information save it in GdkEventPrivate
and provide a function to get this information.
For no Windows system the function return the hardware_keycode instead.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=765259
2016-04-21 22:35:47 -04:00
Friedrich Beckmann
fe80230985 quartz: zoom/rotate change compile/runtime check from 10.7 to 10.8
The zoom/rotate change for quartz does not build on 10.7. This change
adds zoom/rotate support in quartz only for 10.8 and following. The
problems is described here:
https://bugzilla.gnome.org/show_bug.cgi?id=760276 and here
https://trac.macports.org/ticket/51052
NSEventPhaseMayBegin was only introduced in 10.8 although documentation
says it is introduced in 10.7. Tests on 10.7 indicate that the phase
property for the Magnify event is not supported at all on 10.7
2016-04-09 18:05:59 -04:00
Christoph Reiter
3f077ec36f quartz: fix pixelated image surfaces in retina/hidpi mode
gtk+ currently depends on the scaling factor and the cairo device scale
of both the backend surfaces and image surfaces to be equal.

Until now we didn't apply a cairo device scale at all and depended on the
automatic scaling of CGContexts. This works when drawing with cairo but
fails in case of image surfaces, which get requested at a too small size.

To make the quartz backend behave more like the X11 one, set the cairo device
scale on the surface in gdk_quartz_ref_cairo_surface(). As this conflicts
with the default scaling done by CGContext (we would get double scaling)
undo the CGContext scaling using CGContextScaleCTM().

This patch is based on the following patches by Brion Vibber:
    https://bugzilla.gnome.org/show_bug.cgi?id=740199#c4
    https://bugs.freedesktop.org/show_bug.cgi?id=69796#c4

https://bugzilla.gnome.org/show_bug.cgi?id=763779
2016-03-23 16:27:10 +01:00
Christian Hergert
1bd5be6b7c quartz: fix quartz build
More fallout from recent refactoring.

See also b3860e407d.
2016-03-17 21:18:58 -07:00
Friedrich Beckmann
8879052887 added NSEventTypeMagnify and NSEventTypeRotate for ZOOM and ROTATE gestures
MacOS provides the NSEventTypeMagnify which is very similar to the
Gtk ZOOM gesture and NSEventTypeRotate which is very similar to the
Gtk Rotate gesture. Those two event sequences are translated to a
sequence of GDK_TOUCHPAD_PINCH events. This sequence is then detected
in the upper gtk layers as Gtk Zoom/Rotate Gestures.

https://bugzilla.gnome.org/show_bug.cgi?id=760276
2016-03-11 09:59:01 -05:00
Philip Chimento
b3860e407d quartz: Get core pointer from device manager
Some spots missed in the earlier refactor removing core_pointer from
the GdkDisplay struct.

https://bugzilla.gnome.org/show_bug.cgi?id=762820
2016-03-09 22:11:07 -08:00
Paolo Borelli
4a6f8a065a gdk: remove the display->list_devices vfunc
gdk_display_list_devices is deprecated and all the backends
implement the same fallback by delegating to the device manager
and caching the list (caching it is needed since the method does
not transfer ownership of the container).
The compat code can be shared among all backends and we can
initialize the list lazily only in the case someone calls the
deprecated method.

https://bugzilla.gnome.org/show_bug.cgi?id=762891
2016-02-29 21:53:58 +01:00
Paolo Borelli
38ad57948c gdk: remove the core_pointer field from GdkDisplay
It is not used anymore, so no need to set it

https://bugzilla.gnome.org/show_bug.cgi?id=762820
2016-02-29 14:15:04 +01:00
Paolo Borelli
502744be85 quartz: get the core pointer from the device manager
https://bugzilla.gnome.org/show_bug.cgi?id=762820
2016-02-29 14:15:04 +01:00
Matthias Clasen
2a2d254a8b quartz: Don't use g_print for debug output
The g_print documentation explicitly says not to do this, since
g_print is meant to be redirected by applications. Instead use
g_message for logging that can be triggered via GTK_DEBUG.
2016-02-28 21:40:23 -05:00
Matthias Clasen
4f422d1f5b quartz: Strip newlines from g_warning and g_error
g_logv adds one for us already.
2016-02-28 12:23:12 -05:00
Paolo Borelli
70d689cddd gdk: calculate pixel color shift and precision lazily
This gets rid of the decompose_mask utility entirely and simplifies
backend code.
2016-02-27 12:27:54 +01:00
Paolo Borelli
f73e7680ed gdk: factor out utility shared among backends
Removes duplicated code and makes sure we use the version which
is safe against infinite loops
2016-02-27 10:46:59 +01:00
Allin Cottrell
46d3611052 Fix Quartz Full Screen Crash. 2016-02-21 16:22:27 -08:00
Carlos Garnacho
af54b82c0a quartz: Use GdkSeatDefault to implement GdkSeat 2015-12-15 00:40:21 +01:00
Matthias Clasen
268c7a3e44 gdk: Allow passing the start coordinates in drag_begin
Add a variant of gdk_drag_begin that takes the start position
in addition to the device. All backend implementation have been
updated to accept (and ignore) the new arguments.

Subsequent commits will make use of the data in some backends.
2015-12-13 10:39:43 -05:00
Matthias Clasen
64c5b97be8 quartz: Don't use the instancetype keyword
gdkcursor-quartz.c uses the instancetype keyword, which doesn't seem to
be supported in the version of Objective C that Snow Leopard uses.
Replacing that keyword with the thing it represents makes it build.

Patch by Ryan Hendrickson,
http://bugzilla.gnome.org/show_bug.cgi?id=756770
2015-10-25 13:26:01 -04:00
John Ralls
c55ff6e41f Bug 736125 - The default gtk accelerator mod mask does not include all default backend modifiers 2015-08-25 15:54:58 -04:00
Christoph Reiter
6eaf5bd0f2 quartz: Implement CSD drag resize for all edges/corners
Manual resizing for CSD windows only worked with the bottom
right corner. This extends it to work for all corners and edges.

https://bugzilla.gnome.org/show_bug.cgi?id=753329
2015-08-08 13:28:35 +02:00
Christoph Reiter
2c329f5b3a quartz: disable system shadows if a GdkWindow shadow is set.
The shadow will be drawn in the wrong place in those cases so all we can
do is disable it. This fixes double shadows drawn around menus, popups
and tooltips.

https://bugzilla.gnome.org/show_bug.cgi?id=734984
2015-07-27 17:26:46 +02:00
Patrick Griffis
ee73e27fd7 quartz: Fix building
Broken by 6d04183c5d and 6ac07a2e85
2015-07-27 09:33:32 -04:00
Matthias Clasen
6d04183c5d quartz: Check if a drag ends inside a known window
If a drag ends inside a known window, set the dest_window field
in the drag context. This information is needed to implemented
notebook tab dragging.

https://bugzilla.gnome.org/show_bug.cgi?id=752638
2015-07-26 02:05:47 -04:00
Christoph Reiter
7ed5816829 quartz: remove maximized state when the window position/size is changed
So a window can be maximized/zoomed again after being moved away from
its maximized position. This makes the zoom button on non-CSD windows
work as before.
2015-07-23 13:20:05 +02:00
Christoph Reiter
eb37fd22e7 quartz: implement maximized/unmaximized
Instead of using the default zoom behaviour use the internal
maximized state for selecting our own zoom target. This makes
zooming work for CSD windows where for some reason the
given default zoom target is the current window frame itself
resulting in a shadowless window of the same size.

While this makes the zoom button behave a bit different as expected
it makes things more consistent with other platforms and fixes CSD
zooming.
2015-07-23 13:19:09 +02:00
Christoph Reiter
61ce90a8e2 quartz: make moving CSD windows right up to the screen's menu bar work.
The default implementation prevents the window + shadow to move above
the menu bar. Change it so only the window is considered.
2015-07-23 13:18:49 +02:00
Tom Schoonjans
7d43cda493 gdkwindow-quartz: partial aspect ratio support
Support was added for GDK_HINT_ASPECT in
gdk_quartz_window_set_geometry_hints though with one restriction:
min_aspect and max_aspect have to be equal, which I believe corresponds
to the most common usage. A warning will be printed if this condition is
not met but min_aspect will be used anyway.
2015-07-07 09:36:29 -07:00
Pietro Gagliardi
3c8b80dce2 Implemented most of the GDK named cursors on Mac OS X.
Only "wait" and "all-scroll" are not implemented properly. OS X does not
seem to have a proper interface to either cursor. Approximations are used
instead; see the code.

See bug 749178.
2015-05-16 17:11:44 -04:00
Matthias Clasen
be9915b16a quartz: Support css cursor names
We want these to work across platforms, so do a best-effort
approximation. We could do much better here by copying what
webkit does.

https://bugzilla.gnome.org/show_bug.cgi?id=749178
2015-05-11 22:29:07 -04:00
Philip Chimento
0c4deb656e quartz: Non-implementation of GdkGLContext
This makes sure the Quartz backend returns an error when asked to create
a GL context, rather than crashing because of a NULL vfunc.

https://bugzilla.gnome.org/show_bug.cgi?id=740199
2015-05-09 23:59:29 -04:00
Fabiano Fidêncio
fea2e7bf35 gdkkeys: Add support to _get_scroll_lock_state()
GdkKeymap already has support for _get_num_lock_state() and
_get_caps_lock_state(). Adding _get_scroll_lock_state() would be good
for completness and some backends (Windows?) could take advantage of
this.
2015-04-27 20:07:52 -03:00
Thibault Saunier
fb581a1084 gdk/quartz: Fix mixup in attributes usage creating window implementation
First, attributes can be NULL (which is always the case when calling
gdk_window_ensure_native) so do not unconditionally dereference it.

Then the window_type should be taken directly from the GdkWindow as
in other backends (such as the X11 one for example).

https://bugzilla.gnome.org/show_bug.cgi?id=744942
2015-02-22 15:50:39 +01:00
Philip Chimento
ec37fbe2e2 quartz: NSWindow NULL check in get_scale_factor
Sending backingScaleFactor to a NULL NSWindow will silently give the
value 0 for the scale factor, causing insidious divide-by-zero bugs down
the line. This checks if the NSWindow is NULL first, as seems to happen
throughout the rest of the file.

Note that I don't have a hi-DPI OS X machine to test this on, though.

https://bugzilla.gnome.org/show_bug.cgi?id=738338
2014-12-24 14:57:40 -08:00
Jasper St. Pierre
8976e84ded gdkwindow: Don't pass the region to the impl when beginning a paint
It's unused. At the same time, rename "begin_paint_region" to
"begin_paint". This will help us clean up how GDK painting works
in the future to allow more creative use of double-buffering.
2014-11-22 08:08:34 -08:00
Jasper St. Pierre
ec2925a5bf quartz: Don't bother storing the paint_clip_region
It's unused.
2014-11-22 08:07:28 -08:00
Matthias Clasen
3a2bf9d878 quartz: Move the FullscreenSavedGeometry definition earlier
Move the FullscreenSavedGeometry before the first (conditional)
use, to fix the build on OS X 10.6.

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

https://bugzilla.gnome.org/show_bug.cgi?id=737561
2014-10-27 06:46:12 -04:00
Benjamin Otte
5e4672092a gdk: Deprecate static gravities
... and remove all implementations. The API allows to not work "if the
server doesn't support it. So from now on, no server does!
2014-10-06 02:38:40 +02:00
Marek Kasik
8b5d30d439 Remove redundant checks for NULL
Remove checks for NULL before g_free() and g_clear_object().
Merge check for NULL, freeing of pointer and its setting
to NULL by g_clear_pointer().

https://bugzilla.gnome.org/show_bug.cgi?id=733157
2014-10-02 19:06:03 +02:00
Jesse van den Kieboom
b107c9f02c quartz: Get default font size from user font
https://bugzilla.gnome.org/show_bug.cgi?id=735321
2014-08-28 20:02:20 +02:00
Jesse van den Kieboom
b57bef989a quartz-dnd: make sure to set source window
https://bugzilla.gnome.org/show_bug.cgi?id=658722
2014-08-27 20:57:17 +02:00
Jesse van den Kieboom
ec17a649ae gdkwindow-quartz: Support native fullscreen mode
This implements native fullscreen mode on OS X >= 10.7. This patch
adds tracking of the fullscreen mode if externally modified, as well
as toggling the native fullscreen mode of the window as needed.
2014-08-25 12:52:47 +02:00
Owen W. Taylor
fc6e2cc4b2 Handle resolution changes in the GDK backend code
gdk_x11_display_set_window_scale() affects the interpretation of the
Xft/DPI XSETTING - it is substituted inside GDK with the value of
Gdk/UnscaledDPI xsetting. However, this change is not propagated to
GTK+ and from GTK+ back to gdk_screen_set_resolution() until the
main loop is run.

Fix this by handling the screen resolution directly in gdk/x11.
This requires duplication of code between GDK and GTK+ since we still
have to handle DPI in GTK+ in the case that GdkSettings:gtk-xft-dpi
is set by the application.

https://bugzilla.gnome.org/show_bug.cgi?id=733076
2014-07-13 15:35:23 -04:00
Jasper St. Pierre
0dfd506b3c gdkwidow: Make queue_antiexpose optional 2014-06-21 18:45:41 -04:00
Jasper St. Pierre
c767d504c5 gdkwindow: Don't bother with a return parameter for queue_antiexpose
Standard refcounting works perfectly well. Don't give us the opportunity
for more memory leaks.
2014-06-21 18:45:39 -04:00
Jasper St. Pierre
be30e440c3 gdkwindow: Remove the ability to call begin_paint_region more than once
Previously, each begin_paint_region added to a stack of current paints,
and when end_paint was called, the paint was popped off of the stack and
the surface was composited into the parent paint surface.

However, the code was broken in the case of a backend like Wayland which
didn't keep track of nested calls and simply wiped and returned the
native impl backing surface every time.

Since this feature is flat out unused by GTK+ and we don't want to
really support tricksy things like these for other clients, just remove
the feature. If somebody does call begin_paint_region more than once,
warn and return without doing anything.
2014-06-20 20:41:55 -04:00
Jasper St. Pierre
d48adf9cee gdkwindow: Remove the internal cairo_surface used for out-of-band painting
Traditionally, the way painting was done in GTK+ was with the
"expose-event" handler, where you'd use GDK methods to do drawing on
your surface. In GTK+ 2.24, we added cairo support with gdk_cairo_create,
so you could paint your graphics with cairo.

Since then, we've added client-side windows, double buffering, the paint
clock, and various other enhancements, and the modern way to do drawing
is to connect to the "draw" signal on GtkWidget, which hands you a
cairo_t. To do double-buffering, the cairo_t we hand you is actually on
a secret surface, not the actual backing store of the window, and when
the draw handler completes we blit it into the main backing store
atomically.

The code to do this is with the APIs gdk_window_begin_paint_region,
which creates the temporary surface, and gdk_window_end_paint which
blits it back into the backing store. GTK+'s implementation of the
"draw" signal uses these APIs.

We've always sort-of supported people calling gdk_cairo_create
"outside" of a begin_paint / end_paint like old times, but then you're
not getting the benefit of double-buffering, and it's harder for GDK to
optimize.

Additionally, newer backends like Mir and Wayland can't actually support
this model, since they're based on double-buffering and swapping buffers
at various points in time. If we hand you a random cairo_t, we have no
idea when is a good time to swap.

Remove support for this.

This is technically a GDK API break: a warning is added in cases where
gdk_cairo_create is called outside of a paint cycle, and the returned
surface is a dummy that won't ever be composited back onto the main
surface. Testing with complex applications like Ardour didn't produce
any warnings.
2014-06-20 20:41:54 -04:00