By reverting gdk_drag_find_window_for_screen logic to what it was
before eb21a7df29.
The old logic knew how to ignore drag_window when searching
for dest_window, but that code was removed (I guess by accident).
https://bugzilla.gnome.org/show_bug.cgi?id=616544
Commit 5ebb32d1ff didn't add the correct
code to find the toplevel window. The WindowFromPoint() function does
not return the toplevel window in the hierarchy, it returns the deepest
non-disabled, non-invisible child. As we don't use invisible or disabled
windows, we don't actually need to use the ChildWindowFromPoint walk for
the non get_toplevel case, so we can remove that code path.
To find a toplevel, we need to start from the desktop and work up, using
ChildWindowFromPointEx (to ignore invisible and disabled windows). If we
don't ignore invisible and disabled windows (as is the case with the
ChildWindowFromPoint call, we are liable to get returns of hidden or
disabled children of the desktop which don't belong to us, but notionally
occupy the same area under the pointer.
An alternative might be to start our walk with one of the children of the
desktop owned by our process and thread - which we can enumerate using,
the EnumThreadWindows call, or (presumably) determine internally. This
would not work when we are inside a GtkSocket though, as the children of
the desktop would belong to the process owning the GtkPlug - we would
have to rely on our own list of windows.
For correctness, this commit adds tests to ensure that we don't try to
return either x or y window coordinates if that corresponding pointer is
NULL.
https://bugzilla.gnome.org/show_bug.cgi?id=658842
The button highlighting in testgtk works again, even with
GDK_NATIVE_WINDOWS. Unfortunately testgtk:menus still does
not work for the forced-native-window-case.
In _gdk_window_move_resize_child it tries to decide whether to pass
SWP_NOSIZE and SWP_NOMOVE based on whether the new size and position
is different from the window's existing position. However it seems
that GDK now ends up updating the window's position before calling
_gdk_window_move_resize_child so this would mean it would think the
window never changes size or position so SWP_NOSIZE|SWP_NOMOVE would
always be set. This causes child windows to never be resized.
This patch changes it so that it never passes either flag to
SetWindowPos. I don't know whether this will cause any side effects
but you'd think it shouldn't do any harm to reassert the current size.
https://bugzilla.gnome.org/show_bug.cgi?id=628049
Signed-off-by: Hans Breuer <hans@breuer.org>
In 2.x, the !HAVE_XCONVERTCASE fallback of keyval_convert_case() was
implicitly used as implementation for all !X11 backends.
In 3.x, when this function was virtualized in GdkDisplayManager,
this fallback was moved to the X11 backend and the other backends
"equipped" with /* FIXME implement */ implementations of
keyval_convert_case() which don't convert anything.
Move the fallback code back to gdk/ as default implementation
of GdkDisplayManager::keyval_convert_case() and remove its
implementations is all backends but X11. Also remove the
implementation in Wayland which was a plain copy of what
is now the default implementation.
(cherry picked from commit f46c1b76d8)
_gdk_device_get_axis_use() dates back to pre-sealing, when the
xi2 work began, this remaining can be gone with a public
gdk_device_get_axis_use() function already in place.
GDK_NATIVE_WINDOWS was a way to keep some old apps running that did weird
things in gtk2. We should not have to carry this forwards in gtk 3.x.
We do however keep a g_warning() call reminding people of this fact to
ease debugging when they try to port their applications.
https://bugzilla.gnome.org/show_bug.cgi?id=644119
- replace GdkNativeWindow with HWND, remove type casts
- no more GdkDisplayClass::get_drag_protocol but GdkWindowImpl::get_drag_protocol
- remove *_client_message*()
There are sure regressions but basic stuff seems to be working
again after all the API breakage done with comments like
"Win32 and Quartz need to be ported still."
This commit hides the GdkDisplayManager instance and class structs,
adds vfuncs for listing displays, opening displays, and getting and
setting the default display. The X11 backend has a derived
GdkDisplayManagerX11.
The gdk_display_manager_get() function is responsible for deciding on
which of the compiled in backends to use. Currently, it consults the
GDK_BACKEND environment variable and falls back to x11.
This commit hides GdkDragContext and GdkDragContextClass, adds
vfuncs for most drag context functionality, and turns the X11 DND
implementation into GdkDragContextX11. We also add vfuncs to
GdkDisplay for gdk_drag_get_protocol and to GdkWindow for
gdk_drag_begin, and implemenet them for X11.
Other backends need similar treatment and are broken now.
Add a GdkDisplay::get_app_launch_context vfunc, and a
gdk_display_get_app_launch_context that for X11 returns a subclass.
For win32 and quartz, the implementations were trivial, so we
just return a new GdkAppLaunchContext without subclassing. Since
the type of the context now depends on the display,
gdk_app_launch_context_set_display is deprecated.
One less magic function. Also refactored it to make it easier to
implement. It now returns TRUE if it beeped and FALSE if it failed to do
so. A default implementation exists that just returns FALSE for all the
backends that can't beep windows (read: everything but X11 with XKB -
and why on earth do keyboard libs implement beeping?)
Trying to get rid of all the _gdk_windowing_something() functions that
we expect backends to magically know about and instead put them in a
proper interface (mostly GdkWindowImplClass).
An event filter may add or remove filters itself. This patch does
two things to address this case. The first is to take a temporary
reference to the filter while it is being used. The second is
to wait until after the filter function is run before determining
the next node in the list to process. This guards against
changes to the next node. It also does not run functions
that have been marked as removed. Though I'm not sure if this
case can arise.
https://bugzilla.gnome.org/show_bug.cgi?id=635380
In particular, the following functions are gone:
- gdk_screen_get_default_colormap()
- gdk_screen_set_default_colormap()
- gdk_screen_get_system_colormap()
- gdk_screen_get_rgba_colormap()
Now the window background is a cairo_pattern_t. The backends will try to
set this as good as they can on the windowing system, but no guarantees
are made on wether the windowing system supports the pattern.
Also gets rid of GDK_NO_BG as undefined behavior is not a good idea to
support, and GDK_NO_BG effectively made the window's contents undefined.
It wasn't effectively used in GTK anyway.
* add per-display gdk_x11_display_error_trap_push()
(X11-specific because gdk_error_trap_push() probably
should have been)
* make gdk_error_trap_push() handle only GDK displays
not displays opened without a GDK wrapper
* make gdk_error_trap_pop() and gdk_x11_display_error_trap_pop()
automatically sync only if needed, so manual gdk_flush() is not
required
* add gdk_error_trap_pop_ignored() which just asynchronously
ignores errors, so never needs to sync
* add G_GNUC_WARN_UNUSED_RESULT to plain pop(), because
if you use plain pop() and don't need the return value,
the async gdk_error_trap_pop_ignored() should be used
instead. This results in lots of warnings to clean
up in a later patch.
The main objective here was to avoid the need to sync just
to ignore an error. Now, syncing is automatic, and only
happens when we need to know the error code.
https://bugzilla.gnome.org/show_bug.cgi?id=629608
TrackMouseEvent is present in user32.dll in all Windows versions we
support. No need to look it up dynamically. No need to fallback to
_TrackMouseEvent from comctrl32.dll.
While X11 surfaces can be resized, this is not the case for Quartz
surfaces. Instead of resizing we will invalidate the surface instead.
By giving _gdk_windowing_set_cairo_surface_size() a boolean return
value, we can signal back whether or not resizing was possible. If not
possible, we invalidate the surface.
The window move code needs special attention for multiple reasons:
- invalid areas for expose events need to be modified
- self-copy is not supported by Cairo
- in X11, copying from an overlapped Window might cause unexposed areas
to be copied in, spo expose events for those need to be generated.
This was all special cased in various parts of the code. By making it an
explicit vfunc, we can work around it.
Includes fixing all callers to use the cairo region API instead. This is
usually just replacing the function names, the only difference is
gdk_region_get_rectangles() being replaced by
cairo_region_num_rectangles() and cairo_region_get_rectangle() which
required a bit more work.
https://bugzilla.gnome.org/show_bug.cgi?id=613284
This function makes a better replacement for
gdk_display_get_core_pointer(), wherever it might yet be needed, for
XI2 resorts to XIGetClientPointer(), for the others return the only
core pointer.
https://bugzilla.gnome.org/show_bug.cgi?id=621685
WM_KILLFOCUS means that a keyboard grab (not a pointer grab), if any,
has been broken. I don't think this bug has matterd much as gtk
generates a grab-broken-event signal for both keybord and pointer
grabs being broken anyway.
It turns out that my attempt at handling Super, Hyper and Meta better
is causing problems, mostly because Alt and Meta are commonly colocated
in the modmap, and apps do a check for the Alt modifier regularly.
See e.g bug 607697.
Intermediate commit of work in progress on integrating the old code
for OLE2-based generic drag and drop from Arhaeopteryx Software, from
a long time ago in the GTK+ 1.3 timeframe. Does still not work and is
as before not compiled in unless OLE2_DND is defined in
gdkdnd-win32.c. (Thus, for inter-process DND, still only WM_DROPFILES
style dropping of files on GTK+ apps works.)
Related slight refactoring of other code that shouldn't change how it
works. Add more global variables for run-time constants (once
initialized) representing well-known GdkAtoms and registered Windows
clipboard formats, as they with the generic DND code will be needed in
several source files. Some improved debugging output.
Bypassed with #if 0 because it is an awful hack and not really
acceptable from a privacy point of view for instance. It prevents
Firefox from deleting temporary files containing images being dragged,
so they stay on disk. Bug #561973.
Either g_type_register_static_simple (used by G_DEFINE_TYPE_EXTENDED)
and G_IMPLEMENT_INTERFACE use automatic variables for GTypeInfo and
GInterfaceInfo structs, while tutorials and source code often use
static variables. This commit consistently adopts the former method.
https://bugzilla.gnome.org/show_bug.cgi?id=600158
The root window width and height have already been correctly
initialised in _gdk_root_window_size_init() to cover all monitors, so
don't incorrectly re-initialise using GetSystemMetrics(SM_C[XY]SCREEN)
which only gives the size of the primary monitor anyway. (See MSDN.)
This fixes at least gdk_screen_get_{width,height}() which indirectly
affects at least the positioning of combo box pop-up menus on multiple
monitors.
This has two advantages:
1) In many backends, this is faster as we can terminate the window
hierarchy traversal earlier
2) When used in gdkdisplay.c::get_current_toplevel() to get the
current toplevel that has the pointer we now correctly return
a toplevel with the pointer in it where the pointer is inside
some foreign subwindow of a toplevel window.
The second advantage fixes some bugs in client side event generation
when the pointer is inside such a foreign child window.
Set the input_window_destroy and input_window_crossing methods of the
GdkWindowImplIface on Windows. Add implementation of
_gdk_input_crossing_event that is mostly dummy, though.
The X11 queue_translation operation uses NextRequest to get the serial
of the XCopyArea operation where the translation should end. However,
if the gc passed to gdk_draw_drawable has a non-flushed clip region
(which it commonly has now for the window clipping) then the next
operation will be the GC flush, not the XCopyArea.
To handle this right we now pass in the GC to be used to
queue_translation and ensure that it is flushed before calling
NextRequest().
Implement _gdk_win32_window_destroy() by just renaming
_gdk_windowing_window_destroy(), removed superfuous stub.
Also cleaned up implementations of gdk_win32_window_set_background()
and gdk_win32_window_set_back_pixmap() - removed stuff now done at the
respective gdk_window_*() function.
Resurrcetion and adaption of find_window_for_mouse_event(). The window
receiving the WM_MOUSEMOVE, WM_?BUTTONDOWN is not necessarily the one
interested in GDK_(ENTER|MOTION|LEAVE)_NOTIFY
http://bugzilla.gnome.org/show_bug.cgi?id=588373
Also added some more more TODO_CSW and disabled print_event(): it can not
cope with the new _gdk_windowing_got_event() eating/morphing events.
Turns out pygtk build broke due to the argument addition to draw_drawable.
So, we now add a new vfunc for the new draw_drawable and are thus
backwards compat.
2009-03-17 Tor Lillqvist <tml@novell.com>
Bug 575700 - Crash when moving a GtkWindow
* gdk/win32/gdkevents-win32.c (gdk_event_translate): Fix
embarrassing crasher bug introduced on 2009-03-11. A variable was
assigned a value only inside a GDK_NOTE but still used outside
that.
svn path=/trunk/; revision=22568
2009-03-11 Tor Lillqvist <tml@iki.fi>
Bug 573067 - Intra-app dnd of text behavior on Windows is wrong
* gdk/win32/gdkdnd-win32.c (local_send_motion) (gdk_drag_motion):
The default action should be move, not copy. Tweak how the
GdkDragAction fields in GdkDragContexts are changed. Seems to help
the problem.
Add more debugging printout for --gdk-debug=dnd to many functions.
* gdk/win32/gdkmain-win32.c
* gdk/win32/gdkprivate-win32.h: (_gdk_win32_drag_protocol_to_string)
(_gdk_win32_drag_action_to_string): New functions for use in
debugging printouts.
svn path=/trunk/; revision=22522
2009-03-11 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdnd-win32.c: Use G_DEFINE_TYPE. Some debugging
printout changes. Hacking on the OLE2_DND code, which still
doesn't work, though, and is not normally compiled.
svn path=/trunk/; revision=22517
2009-03-11 Tor Lillqvist <tml@iki.fi>
Bug 570896 - gdkevents-win32.c(2947) : error C4053: one void
operand for '?:'
* gdk/win32/gdkevents-win32.c (gdk_event_translate): Fix
compilation error with MSVC. While at it add clarifying comments
and fix a typo in the debugging output.
svn path=/trunk/; revision=22515
2009-03-11 Tor Lillqvist <tml@iki.fi>
Bug 574794 - Can not resize shaped windows on Windows
* gdk/win32/gdkevents-win32.c (gdk_event_translate): On handling
WM_WINDOWPOSCHANGED, don't do anything if the position and size
hasn't changed. I am not exactly sure I understand why this helps
this particular bug.
svn path=/trunk/; revision=22511
2009-02-09 Cody Russell <bratsche@gnome.org>
* gdk/win32/gdkwin32.h: Add potentially missing #defines for
XBUTTON1, etc. Fixes the build that was broken in r21746.
svn path=/trunk/; revision=22297
2009-01-29 Tor Lillqvist <tml@novell.com>
Bug 559408 - Transparency lost when images are copied between GTK+
and the clipboard on Windows
The code in gdkselection-win32.c is simplified quite a lot. When
an image is stored on the clipboard from GTK+, only the "PNG" and
CF_DIB formats are advertised. PNG is our preferred format because
it can losslessly represent any image that gdk-pixbuf can handle,
even with alpha, unambiguously. CF_DIB is also advertised because
of its ubiquitous support in Windows software.
Delayed rendering is used as before, so for other data than text
nothing is actually stored on the clipboard until some app asks
for it.
It's pointless to advertise images formats like "image/png" or
"image/x-MS-bmp" that no other Windows application is going to
look for anyway. Likewise it's pointless to store text under
formats like "text/plain" or "UTF8_STRING". Just store
CF_UNICODETEXT. CF_TEXT will be available as a synthesized format
anyways.
Office 2007 offers and asks for images in PNG format using the
registered clipboard format name "PNG", so we do likewise. If the
"PNG" format is available that is preferred when copying to GTK+
from the clipboard.
Unfortunately Word 2007 still uses CF_DIB without handling
alpha. But PowerPoint 2007 uses PNG if available and handles alpha
correctly. Both Word and Powerpoint offer PNG with alpha nicely.
Firefox and IE7 offer images that contain alpha as 32-bit version
3 BI_RGB DIBs with the undocumented "extra" bytes actually being
alpha. Also, alpha is premultiplied into the RGB bytes, presumably
because that is how AlphaBlend() wants such DIBs. That is also
taken care of. At least for Firefox it easy to be sure that a
CF_DIB on the clipboard is from Firefox.
Also some general stylistic cleanup, comment improvements, and
improvements of debugging printout especially in the clipboard
handling. Those are not detailled below.
* gdk/win32/gdkprivate-win32.h
* gdk/win32/gdkglobals-win32.c
* gdk/win32/gdkgmain-win32.c: Move some globals that were used
only in gdkselection-win32.c to be local to that file.
* gdk/win32/gdkproperty-win32.c (gdk_property_change): Don't
bother checking if text to be placed on the clipboard consists of
only ASCII.
* gdk/win32/gdkselection-win32.c: Add static variables for a list
of GdkPixbuf-supported formats, well-known registered clipboard
formats for images, and for GdkAtoms for well-known image and text
formats.
(_gdk_win32_selection_init): Initialize above static variables.
(selection_property_store) (gdk_selection_property_get)
(_gdk_selection_property_delete): Don't use a FIFO of GdkSelProps
for a window after all, it breaks testtext. See bug #163844.
(gdk_selection_convert): When converting to the TARGETS format,
i.e. when the caller wants to know what clipboard formats are
available, if PNG is available we report just that and skip
CF_DIB, JPEG and GIF even if advertised.
If CF_UNICODETEXT is available, report only UTF8_STRING.
When converting to the UTF8_STRING format, i.e. when the caller
wants text from the clipboard, try just CF_UNICODETEXT. There is
no point in trying CF_TEXT as Windows will synthesize
CF_UNICODETEXT from CF_TEXT anyway, if some app has stored just
CF_TEXT.
When converting to the image/bmp format, i.e. when the caller
wants an CF_DIB image from the clipboard, we check if the DIB is a
version 3 32-bit BI_RGB one that is likely to actually contain
alpha in the "extra" bytes. Such a DIB is likely to have
premultiplied alpha even, at least in the case of Firefox 3 and
IE7. We then edit the DIB in-place into a version 5 one in
BI_BITFIELDS format and undo the alpha premultiplication.
In any case, prepend a BMP file header before letting go of the
data which will be fed to the gdk-pixbuf bmp loader by upper
levels.
(gdk_win32_selection_add_targets): If some kind of pixmap image
format is being added, actually advertise just PNG and
CF_DIB. Note that alpha won't be stored on the clipboard through
CF_DIB. This is because gdk-pixbuf's bmp loader doesn't save
alpha. Furthermore, few if any non-GTK+ Windows apps seem to
understand a version 5 DIB with proper alpha anyway.
(_gdk_win32_selection_convert_to_dib): Simplified muchly.
svn path=/trunk/; revision=22255
2009-01-21 Tor Lillqvist <tml@novell.com>
* gdk/win32/gdkcursor-win32.c: Rename static local functions and
variables to not have any unnecessary _ or _gdk_win32 prefix.
* gdk/win32/gdkcursor-win32.c (hcursor_from_type): Implement
creating a GDK_BLANK_CURSOR.
svn path=/trunk/; revision=22165
2009-01-11 Tor Lillqvist <tml@iki.fi>
Bug 523554 - Copy from GIMP to Word broken
* gdk/win32/gdkselection-win32.c
(_gdk_win32_selection_convert_to_dib): The DIB stored in the
Windows Clipboard was for some unknown reason truncated by one
byte. Don't do that.
svn path=/trunk/; revision=22086
2009-01-05 Tor Lillqvist <tml@novell.com>
Bug 566628 - gdk_display_close always asserts on win32
* gdk/win32/gdkdisplay-win32.c
(_gdk_windowing_set_default_display): Allow also a NULL parameter
in the g_assert(). Still don't actually do anything in this
function, though.
svn path=/trunk/; revision=22068
2008-11-04 Tor Lillqvist <tml@novell.com>
Bug 557212 - Problem with which window gains focus and is visible
* gdk/win32/gdkevents-win32.c (ensure_stacking_on_activate_app):
Only do the restacking for the active window of the
application. Seems to fix the problem.
(gdk_event_translate): Only call ensure_stacking_on_activate_app()
when the application is being activated, not deactivated.
svn path=/trunk/; revision=21756