Commit Graph

343 Commits

Author SHA1 Message Date
Руслан Ижбулатов
77eebbda5c GDK W32: Erase hidden layered windows before showing them
If a layered window was hidden and is made visible, erase its
contents before showing it. GDK will schedule a redraw, but until
then we generally don't want to show old contents.

https://bugzilla.gnome.org/show_bug.cgi?id=763783
2016-03-29 14:30:19 +00:00
Руслан Ижбулатов
cea8c29a26 GDK W32: Implement show_window_menu()
This is achieved by sending undocumented message WM_SYSMENU
to the window.
Before doing that, the window is given WS_SYSMENU style
(to enable window menu) and some combination of
WS_MAXIMIZEBOX (for "Mazimize" item)
WS_MINIMIZEBOX (for "Minimize" item)
WS_SIZEBOX (for "Size" item)
depending on which operations are currently permissible.

WM_SYSMENU is processed by DefWindowProc(), which results
in showing the window menu. We remove extra styles
at the first opportunity (WM_INITMENU message), as they
alter the way our window is rendered.

https://bugzilla.gnome.org/show_bug.cgi?id=763851
2016-03-29 13:47:49 +00:00
Руслан Ижбулатов
7d2a7a5626 GDK W32: Don't move iconic windows
Using UpdateLayeredWindow() on iconic windows brings them *back* from
their iconic (minimized) state. That is bad.
As a precaution, also don't use SetWindowPos() on iconic windows.
This means that iconic windows can't be moved. That is fixable
by using SetWindowPlacement(), but there is no pressing need to do so,
as there are very few cases when windows need to be moved while minimized.

https://bugzilla.gnome.org/show_bug.cgi?id=763835
2016-03-18 07:49:39 +00:00
Руслан Ижбулатов
5ac848d229 GDK W32: Fix shown window position calculation for dialogs and splashes
Two errors here:
1) A typo in splashscreen rectangle calculation - sets right twice
   instead of setting top
2) Centering for dialogs is off because it doesn't convert
   GDK virtual desktop coordinates to Windows WM virtual desktop
   coordinates by adding _gdk_offset_*

https://bugzilla.gnome.org/show_bug.cgi?id=763628
2016-03-14 16:31:14 +00:00
Руслан Ижбулатов
ab16b19a0a GDK W32: Fix pointer-under-window code for custom resize
This code:
>  gdk_window_get_root_origin (window, &x, &y);
>  x -= root_x;
>  y -= root_y;
>  pointer_window = gdk_device_get_window_at_position (device, &x, &y);
was meant to find the child gdk window at coordinates root_x and root_y.

These 4 lines had 2 bugs:
1) x = x - root_x (same for y) is wrong, it should be x = root_x - x
2) gdk_device_get_window_at_position() does not give you the window
   at position x and y. It gives you the window under the device
   (mouse pointer) and the returns the device coordinates in x and y.

https://bugzilla.gnome.org/show_bug.cgi?id=763533
2016-03-14 15:06:51 +00:00
Руслан Ижбулатов
a97e8fd078 GDK W32: Fix a typo 2016-03-12 12:14:04 +00:00
Руслан Ижбулатов
65ea6f8736 GDK W32: Partially rollback the custom resize for GL windows
If a window is being drawn by OpenGL, we need to apply any
pending resizes to it *before* we paint.

https://bugzilla.gnome.org/show_bug.cgi?id=763287
2016-03-10 13:09:32 +00:00
Chun-wei Fan
15c9b3e692 GDK-Win32: Make update_stye_bits() available within the backend
Other portions of the GDK-Win32 backend make use of this function as
layered windows need to be disabled for GL windows and possibly other
parts, so make this function a private function that is available within
the backend.

https://bugzilla.gnome.org/show_bug.cgi?id=763285
2016-03-08 13:26:59 +08:00
Chun-wei Fan
3f190e0fa6 Win32: Disable layered windows for GL
Layered windows and GL do not work well together, so disable layered
windows when initiating a GdkGLContext, so that GtkGLArea programs can run
properly.

Also based on patch by LRN to address the issue.

https://bugzilla.gnome.org/show_bug.cgi?id=763080
2016-03-08 12:16:37 +08:00
Руслан Ижбулатов
a55f1113f5 Remove unused variable 2016-03-03 18:00:44 +00:00
Руслан Ижбулатов
95fe3ec0c9 GDK W32: Fix redrawing during drag-move with no composition 2016-03-03 18:00:43 +00:00
Руслан Ижбулатов
ba89fbd72d GDK W32: Set default cursor from our own theme right away
Otherwise WM-dependent default cursor is used, which does not
match our theme. Worse, later GDK will realize that we have
our own left_ptr cursor and will apply it after all, making
the discrepancy even more noticeable.

https://bugzilla.gnome.org/show_bug.cgi?id=762902
2016-03-03 07:20:02 +00:00
Руслан Ижбулатов
84ddc6aab1 GDK W32: Force correct mouse cursor for custom resize/move
* Explicitly grab the device, setting appropriate cursor on it.
* Fix gdk_device_virtual_set_window_cursor() to just set the
  cursor, without trying to check that mouse is over the given
  window. Also prevent it from immediately resetting cursor.
* Alse take into account things that happen in other parts of
  GDK - don't look for replacement cursor, GDK already did that,
  and don't create a default arrow cursor instead of NULL,
  GDK-W32 already did that up the stack as well.
  Warn about inappropriate cursor == NULL argument instead.

https://bugzilla.gnome.org/show_bug.cgi?id=762711
2016-03-03 07:17:46 +00:00
Руслан Ижбулатов
c05f254a6e GDK W32: Use layered windows
Toplevels are now true layered windows that are moved,
resized and repainted via UpdateLayeredWindow() API call.
This achieves transparency without any extra effort,
and prevents window size and window contents desychronization
(bug 761629).

This also changes the way CSD windows are detected. We now
use window decorations to detect CSDiness of a window,
and to decide whether a window should be layered (CSD windows should
be) or not.

Decorations are now stored in the window implementation,
not as a quark-based property of the window-as-gobject.

https://bugzilla.gnome.org/show_bug.cgi?id=748872
2016-03-02 21:42:50 +00:00
Руслан Ижбулатов
e03946bd28 GDK W32: custom (non-WM) drag-move and drag-resize code
Normally works only on CSD windows, non-CSD windows continue
to use WM modal loop for drag-resizing and drag-moving. However,
if it is activated on non-CSD windows, it does work.

Has the advantage of being completely immune to AeroSnap.
AeroSnap only worked partially on CSD windows, with the only part
that worked being "don't let users drag window titlebar outside of
the desktop". Now AeroSnap doesn't work on windows moved by
this code at all, which is good, since they currently don't work
well with it due to the way shadows are drawn.

It's possible to also re-implement AeroSnap (or something similar),
but that is a story for another commit.

This code was originally intended to fix the problem of window
size and window contents desynchronization, but failed to achieve
that result in the end. Nevertheless, it serves as a foundation for
other changes to the way window resizing works.

https://bugzilla.gnome.org/show_bug.cgi?id=761629
2016-03-02 21:39:32 +00:00
Paolo Borelli
bc3c855e35 wip _gdk_display 2016-02-22 21:45:08 +01:00
Benjamin Otte
788951c543 win32: Fix empty body warning 2016-02-11 03:44:46 +01:00
Ignacio Casal Quinteiro
eb555979db win32: properly handle show and focus
The first time a window is shown we should always call SW_SHOWNORMAL.
Understand whether to call SW_SHOW or SW_SHOWNORMAL and the specific
ones for the temporary windows depending on IsWindowVisible.
This also fixes the problem when calling gtk_window_present and
the window is snapped to the left or right of the screen.

This patch is based on the patches provided by Yevgen Muntyan
and Aleksander Morgado.

https://bugzilla.gnome.org/show_bug.cgi?id=698652
2016-02-08 13:25:01 +01:00
Yevgen Muntyan
07a994c89f win32: on focus restore the window if iconified
If the window is iconified we want to restore the window
to get the proper size instead of showing it normal which
would change the size of the window.

https://bugzilla.gnome.org/show_bug.cgi?id=698652
2016-02-08 12:58:58 +01:00
Ignacio Casal Quinteiro
f6cc3be118 win32: get rid of _gdk_screen global variable
The screen is part of the display so it should be belong to it.
2016-01-15 12:35:31 +01:00
Руслан Ижбулатов
37bd22c3d9 GDK W32: Don't use WM-drawn shadow for tooltips
This prevents WM from drawing shadows around tooltip windows,
which, in Adwaita, should have no shadow and are CSD-ish (which means
that tooltip window is larger than it looks, and WM draws the shadow
only on the outside, leaving a gap between the visible tooltip edge and
the shadow).

https://bugzilla.gnome.org/show_bug.cgi?id=759898
2016-01-14 14:53:15 +00:00
Paolo Borelli
3cd79c11fc win32: remove _gdk_root global variable 2016-01-14 14:30:37 +01:00
Руслан Ижбулатов
3701a60401 GDK W32: Add a comment for clarity
This is a copy of a similar comment in another place, which explains
why WS_EX_TRANSPARENT windows get a special treatment.

https://bugzilla.gnome.org/show_bug.cgi?id=758484
2015-11-26 17:58:47 +00:00
Руслан Ижбулатов
8b7783ce21 GDK W32: Clarify the use of the second argument to SetWindowPos()
https://bugzilla.gnome.org/show_bug.cgi?id=758484
2015-11-26 17:58:46 +00:00
Руслан Ижбулатов
db1b24233e GDK W32: Don't use SetWindowLong() to set/unset WS_EX_TOPMOST
While searching for the cause of bug 746745 it was discovered that one could
not set WS_EX_TOPMOST extended window style with SetWindowLong(),
but must use SetWindowPos() for that purpose.

This was never a problem most likely because it is highly unlikely for windows
to acquire/lose WS_EX_TOPMOST after they are created, by means other
than SetWindowPos() (which GTK does use to raise/lower windows and
set/remove keep_above), and because trying to set/unset WS_EX_TOPMOST with
SetWindowLong() results in WS_EX_TOPMOST merely not being set/unset (that is,
other styles are still set/unset within the same call and no error is
signalled).

https://bugzilla.gnome.org/show_bug.cgi?id=758483
2015-11-26 16:26:32 +00:00
Matthias Clasen
364d1a574b Don't use g_slist_next in the windows backend
We generally use ->next directly.
2015-10-20 06:14:57 -04:00
Alexander Larsson
9bda0532f8 gdk: Finish conversion to in-struct GdkWindow list nodes 2015-09-21 16:59:51 +02:00
Руслан Ижбулатов
26c24328d5 GDK: Add cursor theme support to W32 backend
Load themed cursors from the same places they are loaded on freedesktop systems,
but use W32 API functions to do so (works for .cur/.ani cursors instead of X
cursors).

Refactor the code for cursor handling. Prefer loading cursors by name.

Do not load actual cursors when loading the theme. Find the files and remember
the arguments/calls for loading them instead. Keeping HCURSOR instance in the
hashmap would result in multiple GdkCursors using the same HCURSOR. Given that
we use DestroyCursor() to off them, this would cause problems (at the very
least - DestroyCursor() would fail).

Store GdkCursor instances in a cache. Update cached cursors when theme changes.

Recognize "system" theme as a special (and default) case. When it is set,
prefer system cursors and fall back to Adwaita cursors and (as a last resort)
built-in X cursors. Otherwise prefer theme cursors and fall back to system and
X cursors.

Force GTK to use "left_ptr" cursor when no cursor is set. Using NULL makes
it use the system default "arrow", which is not the intended behaviour when
a non-system theme is selected.

Ignore cursor size setting and query the OS for the required cursor size, as
Windows (almost) does not allow setting cursors of arbitrary size.

https://bugzilla.gnome.org/show_bug.cgi?id=749287
2015-05-20 08:42:24 +00:00
Руслан Ижбулатов
641fbd86d7 GDK: Use GdkCursor objects to keep track of W32 cursors, not HCURSOR
In particular this means that cursors are disposed of by the way of
g_object_unref(), not DestroyCursor (which is documented to not to be
used on certain kinds of cursors, and we can't tell which is which).

It should also alleviate any concerns about destroying cursors that
are still in use by other windows, except for cases where we would
somehow get our hands on a HCURSOR that someone else is using and we
make a GdkCursor out of it and later unref and finalize it while it
is still in use.

It also removes the need to call CopyCursor(), which makes animated
cursors into non-animated ones as a side-effect (supposed to be a bug,
but try explaining that to MS). Now cursors should be animated (if
the are set up as such in the OS).

https://bugzilla.gnome.org/show_bug.cgi?id=697477
2015-05-20 08:40:43 +00:00
Руслан Ижбулатов
cd54a54346 GDK-W32: remove trailing whitespace everywhere 2015-04-29 21:12:14 +00:00
Руслан Ижбулатов
d44921a152 Enable RGBA windows on W32
Requires Vista and newer.

* Create surfaces with cairo_win32_surface_create_with_format
* Provide an rgba visual that can be distinguished from the system visual
* Make rgba visual the best available visual
* Enable alpha-transparency for all windows that we control
* Check for appropriate cairo capabilities at configure time
  (W32 - 1.14.3 newer than 2015-04-14; others - 1.14.0)

* Check for composition support before enabling CSDs
* Re-enable transparency on WM_DWMCOMPOSITIONCHANGED
Windows that were created while composition was enabled and that were CSDed
as a result and will look ugly (thick black borders or no borders at all) once
composition is disabled.
If composition is enabled afterwards, they will return back to normal.
This happens, for example, when RDP session is opened to a desktop where a GTK
application is running. For W7/Vista windows will only re-gain transparency after
the RDP session is closed. For W8 transparency will only be gone momentarily.

Windows that were created while composition was disabled will not be CSDed
automatically and will use SSD (WM decorations), while windows that are CSDed
manually will get a thin square border.
If composition is enabled afterwards, these windows will not change.
This is most noticeable for system menus (popup menus are often generated
on the fly, system menus are created once) and some dialogues (About dialogue,
for example).

https://bugzilla.gnome.org/show_bug.cgi?id=727316
2015-04-29 21:12:13 +00:00
Chun-wei Fan
bbac0eb3b9 gdk-win32: Clean Up A Bit
As GLib dropped Windows 2000 support some time ago [1][2], and the current
git master already depends on a GLib release that is well after it dropped
Windows 2000 support, clean up the code a bit as we are assured that the
code will run on XP and later, plus, we have dropped XP support during
this cycle with commit b85f0cc.

https://bugzilla.gnome.org/show_bug.cgi?id=741849

[1]: https://git.gnome.org/browse/glib/commit/?id=80c24d36f2525d83e458ebbdf62fdbd085945a02
[2]: https://git.gnome.org/browse/glib/commit/?id=731b46990896665a8107535080bb075a6e18b6f7
2015-04-17 11:32:16 +08:00
Chun-wei Fan
c6a8ead931 Revert "gdk-win32: Clean Up A Bit"
This reverts commit 24d3f3fcb2.

Sorry, I am going to re-commit this very shortly with a new
commit message, as I found the commit message to be quite
wrong and misleading.
2015-04-17 11:29:07 +08:00
Chun-wei Fan
24d3f3fcb2 gdk-win32: Clean Up A Bit
As GLib dropped XP support some time ago [1][2], and the current git master already
depends on a GLib release that is well after it dropped XP support, clean
up the code a bit as we are assured that the code will run on XP and later,
plus, we are dropping XP support during this cycle (i.e. very soon).

https://bugzilla.gnome.org/show_bug.cgi?id=741849

[1]: https://git.gnome.org/browse/glib/commit/?id=80c24d36f2525d83e458ebbdf62fdbd085945a02
[2]: https://git.gnome.org/browse/glib/commit/?id=731b46990896665a8107535080bb075a6e18b6f7
2015-04-17 11:23:39 +08:00
Chun-wei Fan
536fa88cd8 Add OpenGL Support for the GDK Windows Backend
This adds support for OpenGL to the GDK Windows backend using the WGL API
calls, which enables programs that uses the GTK+ GLArea widgets to work on
Windows as well.

This also adds a simple utility function to query for the version of OpenGL
that is supported by the Windows system, like the one provided by the X11
backend.

Many thanks to Alex (and Emmanuele, who started the OpenGL integration in
GTK+) who offered advice and help along the way, as well as the X11 and
Wayland backend for this work to refer to and to model upon.

https://bugzilla.gnome.org/show_bug.cgi?id=740795
2014-12-17 16:07:02 +08: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
Руслан Ижбулатов
a8915b89d7 Initialize impl_window for foreign W32 windows
https://bugzilla.gnome.org/show_bug.cgi?id=736269
2014-09-08 15:50:32 +00:00
Chun-wei Fan
781846e564 gdkwindow-win32.c: Fix build on Visual C++
Since MSVC is more strict about the types that we try to do a compare, cast
old_ptr as HWND, as we know that it is a pointer...

https://bugzilla.gnome.org/show_bug.cgi?id=733768
2014-08-06 15:13:09 +08:00
Руслан Ижбулатов
31d08bd85e When wrapping a foreign W32 window, don't forget to store its HWND
When that window is later used as a parent for a GDK child, the call to
CreateWindow*() will fail, because its HWND is 0.

https://bugzilla.gnome.org/show_bug.cgi?id=733768
2014-08-05 06:37:24 +00:00
Руслан Ижбулатов
d43fb29c5a Suppress a warning from SetWindowLongPtr()
https://bugzilla.gnome.org/show_bug.cgi?id=726224
2014-08-04 13:55:11 +00:00
Руслан Ижбулатов
6dede1a0b7 W32: Don't crash when opacity is set for non-toplevel
X11 backend doesn't, and for good reason - main code body does not check
that the window it sets opacity for is, in fact, toplevel.
Just silently fail to do anything for non-toplevel windows.

https://bugzilla.gnome.org/show_bug.cgi?id=733769
2014-08-02 14:22:22 +00:00
Руслан Ижбулатов
a23c29c0fb W32: Implement rudimentary WM_NCHITTEST handling
Use (cairo) input shape of the window to check whether a point is inside or not
inside the window.
If it is, let the default window procedure do its thing (which seems to be
working all right in all known cases).
If it isn't, override the default window procedure and tell WM what we think.

Don't do any of the above if the window has CSD-incompatible styles (WS_BORDER
or WS_THICKFRAME).

This is a crude kind of substitute for window input shape support (which W32
does not seem to have). Still probably enough to be positive about input shapes
support.

https://bugzilla.gnome.org/show_bug.cgi?id=733679
2014-07-29 01:31:49 +00:00
Руслан Ижбулатов
9e11bb3335 Remove gdk_win32_input_shape_combine_region()
This function currently calls gdk_win32_window_shape_combine_region(),
which is wrong, because it leads to SetWindowRgn() being called with
non-NULL region, which makes W32 disable theming (particularly - decoration
theming), which makes decorations revert back to old GDI-drawn Windows 2000
variant, which looks out of place and interacts *badly* with alpha channel
(because GDI).

https://bugzilla.gnome.org/show_bug.cgi?id=733671
2014-07-24 16:01:06 +00:00
Ignacio Casal Quinteiro
b553ce2b2f win32: remove set but not used variables 2014-07-23 23:37:52 +02:00
Jasper St. Pierre
58715796d2 gdkwindow: Provide a default implementation of process_updates_recurse
As a quick code cleanup.
2014-06-22 10:20:50 -04:00
Jasper St. Pierre
0dfd506b3c gdkwidow: Make queue_antiexpose optional 2014-06-21 18:45:41 -04:00
Jasper St. Pierre
8ae546857c gdkwindow-win32: Remove queue_antiexpose implementation
Since the Win32 code never actually called InvalidateRgn or used the
Win32 update area at all, that meant the only thing that could possibly
invalidate the window was the Win32 window manager as part of scrolling
or resizing, which would also send it a WM_PAINT message.

But the WM_PAINT handling called BeginPaint / EndPaint, which clears the
update area completely! We also draw out-of-band, not directly when
handling WM_PAINT, so there's no way that the update area inside the
Win32 WM would match our local one.

There is no possible way that this queue_antiexpose implementation could
do anything. Remove it.
2014-06-21 18:45:40 -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
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
Руслан Ижбулатов
b1012256f2 Revert "W32: RGBA GDK backend (broken)"
This reverts commit f89d38bc2d.

Pushed by accident.
2014-04-10 17:59:48 +00:00