src/video/x11/SDL_x11window.c


Log

Author Commit Date CI Message
Ryan C. Gordon f5a38f23 2017-08-21T00:42:06 x11: specify event mask for buttons when grabbing pointer (thanks, Stas!). This fixes a strange corner case (notes appended below), and should be safe to do anyhow. Fixes Bugzilla #3674. "I did more tests. It appears the bug only happens if there is another window on the screen that has "always on top" property. For me it is xawtv - it is always opened in a screen corner. Closing xawtv or removing "always on top" property from it makes the problem to go away. Plus, it doesn't appear like the buttons are not delivered at all. It appears that instead the button presses are delivered on some mouse positions, but not delivered when you move the mouse to other part of the window... So this is really weird and is likely somewhere deep in the Xorg. Maybe somehow it happens that the cursor is actually above the xawtv window, but, because my app uses grab, it is not visible there, and in that case the events are not delivered to my app? But with my patch the button events are always delivered flawlessly, it seems. Hmm, and that indeed seems to explain my problem: if the mask is set properly and my app uses grab, then, even if the mouse is above some other window, the events would still be delivered to the grabbing app, which is what actually wanted because my app uses relative mouse mode, so it doesn't know the pointer can cross some other window (my app draws the pointer itself). So my current theory is that my patch only enforces the mouse grab, which otherwise can be tricked by some other window preventing the button events delivery (but motion events are still delivered via xinput2, which makes it all look very obscure)."
Sam Lantinga 362d5496 2017-08-14T10:28:47 Fixed bug 2500 - X11: SDL tries (and fails) to hide foreign windows Alvin I'm interested in this bug as well. I have experienced it when trying to embed an SDL_Window into a FLTK application. To do this, I create a FLTK window (window inside a window - think video player) and then use SDL_CreateWindowFrom() on the inner most window's Xlib Window*. After which, I create a renderer. In my situation I am using the FLTK GUI toolkit. What I have experienced is that the SDL_CreateRender() will recreate the window in order to properly setup OpenGL capability. As part of this process, the window is hidden and a call is executed that waits indefinitely for an acknowledgement that the window was indeed unmapped. This is where my program hangs. Please correct me if I am wrong, but should SDL2 not make Xlib calls that effect the Xlib Window in this situation (e.g. When SDL_CreateWindowFrom() is used)? The toolkit being used typically assumes responsibility and, I presume, tracks all Xlib Windows it creates. On line src/video/SDL_video.c:1372 the comment associated with setting SDL_WINDOW_FOREIGN reads: /* Can't destroy and re-create foreign windows, hrm */ Since I do not know the reason for hiding the window in the first place, the attached patch simply does not wait for a response when X11_XWithdrawWindow() and X11_XMapRaised() are issued by X11_HideWindow() and X11_ShowWindow(), respectively. I presume that the GUI toolkit (GTK, FLTK, etc.) has or will consume the acknowledging event as it is managing the Xlib Window (or it thinks it is). I have tested the patch against hg 5c645d037de2 and I have successfully tested: * Embedding the SDL_Window inside a FLTK application. * Calling SDL_SetWindowSize() when FLTK resizes the window (e.g. dragging cursor on the edge of the window). * Filling the renderer's default target blue and drawing a red fill square at the centre (exciting, I know!) * Calling SDL_Quit() when the application terminates I do not receive any Xlib erorr messages (BadWindow, etc.) in any of those situations.
Sam Lantinga 177f19af 2017-07-20T10:52:43 Fixed bug 3410 - SDL_WINDOW_HIDDEN flag is inaccurate. Jason Wyatt After hiding the window, SDL_WINDOW_HIDDEN/SDL_WINDOW_SHOWN flags on a window are correctly updated. However on the next SDL_PumpEvents, they are set incorrectly. This appears to be because X11_GetNetWMState does not check whether the _NET_WM_STATE property exists (it shouldn't on unmapped windows, see https://specifications.freedesktop.org/wm-spec/wm-spec-1.3.html#idm140130317598336). This results in an empty list of atoms for the state, which would imply that the window is not hidden. (Seen on Fedora 24, Gnome) -- Dan Ginsburg More details on my proposed patch: I am on Kubuntu 16.04.2. I ran into this same bug, but with Jason's patch I found that actualType != None was true so the SDL_WINDOW_HIDDEN would still not be set. My fix instead is to explicitly check for whether the window is unmapped rather than relying on the returned values in XGetWindowProperty.
Ryan C. Gordon c80c3419 2017-07-04T20:44:07 x11: pass a long to XChangeProperty, not an int. The Xlib documentation demands that 32-bit values here be passed in a long, even when long itself isn't a 32-bit value. Otherwise libx11 might read memory incorrectly. Fixes Bugzilla #3692.
Philipp Wiesemann 4b47fa38 2017-06-04T23:15:47 Removed duplicate includes.
Drew Bliss 66555f61 2017-04-06T13:27:48 SDL - attempt to fix https://github.com/ValveSoftware/Dota-2/issues/1199 of mouse not locking in Dota. This fix is proposed by Ryan Gordon (increase timeout in X11_SetWindowGrab from 250ms to 5000ms). I'm going to integrate to source2 and ship it to dota customers. If it works, SamL will upsteam it to SDL.
Philipp Wiesemann 266816b4 2017-03-26T21:00:19 Removed newlines from error messages.
Sam Lantinga a52d48c5 2017-01-10T08:54:33 Fixed bugs 2570, 3145, improved OpenGL ES context support on Windows and X11 Mark Callow The attached patch does the following for the X11 and Windows platforms, the only ones where SDL attempts to use context_create_es_profile: - Adds SDL_HINT_OPENGL_ES_DRIVER by which the application can say to use the OpenGL ES driver & EGL rather than the Open GL driver. (For bug #2570) - Adds code to {WIN,X11}_GL_InitExtensions to determine the maximum OpenGL ES version supported by the OpenGL driver (for bug #3145) - Modifies the test that determines whether to use the OpenGL driver or the real OpenGL ES driver to take into account the hint, the requested and supported ES version and whether ES 1.X is being requested. (For bug #2570 & bug #3145) - Enables the testgles2 test for __WINDOWS__ and __LINUX__ and adds the test to the VisualC projects. With the fix in place I have run testdraw2, testgl and testgles2 without any issues and have run my own apps that use OpenGL, OpenGL ES 3 and OpenGL ES 1.1.
Sam Lantinga 45b774e3 2017-01-01T18:33:28 Updated copyright for 2017
Ryan C. Gordon 7c316366 2016-12-26T23:02:14 x11: Don't loop forever if the X server refuses a pointer grab.
Sam Lantinga 0d24495b 2016-11-15T01:24:58 Removed unused constants Except for SDL_bmp.c where they are historically interesting and I've left them in.
Sam Lantinga 57d01d7d 2016-11-13T22:57:41 Patch from Sylvain to fix clang warnings
Sam Lantinga 27d4f099 2016-10-07T23:40:44 Implemented SDL_GetHintBoolean() to make it easier to check boolean hints
Ryan C. Gordon 4f4c4b62 2016-09-29T22:52:41 Added SDL_SetWindowResizable(). (thanks, Ethan!)
Ryan C. Gordon f647dfe8 2016-03-04T19:41:16 x11: Fix a few more XMoveWindow() calls to adjust for border size. Also, fix my inability to do basic math ('+' should have been '-').
Ryan C. Gordon 02f49fdb 2016-03-04T18:47:19 x11: Deal with window borders better. - Cache the _NET_FRAME_EXTENTS data locally, so we don't have to query the X server for them (instead, we update our cached data when PropertyNotify events alert us to a change). - Use our cached extents for X11_GetWindowBordersSize(), so it's a fast call. - Window position was meant to refer to the client area, not the window decorations, so adjust appropriately when getting/setting the position.
Ryan C. Gordon 2436ca20 2016-02-20T01:03:39 x11: better fix for the previous commit's fullscreen vs maximized issue.
Ryan C. Gordon a4627c5e 2016-02-20T00:44:42 x11: Don't mess with fullscreen vs maximized window state on unmapped windows.
Ryan C. Gordon 45407d0e 2016-02-15T21:49:09 x11: Removed an assert. This assert triggers when run under XMonad. It's safe to pass a zero here anyhow, as this will still work "well enough" and the original problem--GNOME printing a warning message--is still fixed because GNOME's window manager gives us a chance to grab a non-zero user-time value before this code is run.
Ryan C. Gordon 3bdaf4c6 2016-01-05T02:46:10 Added SDL_SetWindowOpacity() and SDL_GetWindowOpacity(). This is currently implemented for X11, Cocoa, Windows, and DirectFB. This patch is based on work in Unreal Engine 4's fork of SDL, compliments of Epic Games.
Ryan C. Gordon f9d478b6 2016-01-05T02:40:14 x11: _NET_WM_PID needs a long, not a pid_t, I think.
Ryan C. Gordon 5696e88e 2016-01-05T02:29:06 Added SDL_GetWindowBordersSize(). This is currently only implemented for X11. This patch is based on work in Unreal Engine 4's fork of SDL, compliments of Epic Games.
Ryan C. Gordon e497e465 2016-01-05T02:28:56 Added SDL_SetWindowInputFocus(). This is currently only implemented for X11. This patch is based on work in Unreal Engine 4's fork of SDL, compliments of Epic Games.
Ryan C. Gordon dc532c70 2016-01-05T02:27:50 Added SDL_WINDOWEVENT_TAKE_FOCUS. This is for corner cases where a multi-window app is activated and wants to make a decision about where focus should go. This patch came from Unreal Engine 4's fork of SDL, compliments of Epic Games.
Ryan C. Gordon f9af0c03 2016-01-05T02:27:26 x11: Put a matching window_group wmhint on every window created. This is useful to the Window Manager, so it can know to associate multiple SDL windows with a single app.
Ryan C. Gordon f2defe5e 2016-01-05T01:30:40 Added special window type flags. Specifically: always on top, skip taskbar, tooltip, utility, and popup menu. This is currently only implemented for X11. This patch is based on work in Unreal Engine 4's fork of SDL, compliments of Epic Games.
Ryan C. Gordon 7678b1db 2016-01-04T16:36:42 Patch to compile on C89 compilers.
Ryan C. Gordon 6df5e1e5 2016-01-04T16:25:27 x11: Support _NET_WM_USER_TIME and give _NET_ACTIVE_WINDOW a valid timestamp. Fixes Bugzilla #3056.
Sam Lantinga 42065e78 2016-01-02T10:10:34 Updated copyright to 2016
Sam Lantinga 38edc177 2015-10-27T11:18:04 Add SDL_HINT_VIDEO_X11_NET_WM_PING to allow disabling _NET_WM_PING protocol handling in CreateWindow if desired.
Ryan C. Gordon da6f2221 2015-08-13T17:37:09 X11: isConfigureNotify() isn't used at the moment, comment it out.
Ryan C. Gordon 8a1fd982 2015-08-13T14:56:16 X11: don't block on a ConfigureNotify event during SDL_SetWindowBordered(). Unity's window manager is (legitimately, since it moves the client window's position) sending one, and SDL was incorrectly trying to mask it out. Other window managers (KWin, apparently) don't move the window and would hang here indefinitely. Fixes Bugzilla #3052.
Sam Lantinga b5c43a88 2015-07-03T09:18:14 Fixed style
Sam Lantinga 35c4468f 2015-07-03T09:17:24 commit a7d7af2a419b453188ffe87386455fc26c1306fa Author: Benoit Pierre <benoit.pierre@gmail.com> Date: Fri Jul 3 02:17:10 2015 +0200 fix 14dd48ae5bc43b61b2a0dd0b3177d22edec707ef regression The window manager detection code in X11_HasWindowManager does not work with Awesome (http://awesome.naquadah.org/). Remove it, and reuse the result of the more correct checks in X11_CheckWindowManager.
Philipp Wiesemann 0e45984f 2015-06-21T17:33:46 Fixed crash if initialization of EGL failed but was tried again later. The internal function SDL_EGL_LoadLibrary() did not delete and remove a mostly uninitialized data structure if loading the library first failed. A later try to use EGL then skipped initialization and assumed it was previously successful because the data structure now already existed. This led to at least one crash in the internal function SDL_EGL_ChooseConfig() because a NULL pointer was dereferenced to make a call to eglBindAPI().
Ryan C. Gordon 141ac2b5 2015-06-07T17:59:31 Backed out changeset c6d43e08be34 This caused Bugzilla #2963, so we'll find a better solution.
Ryan C. Gordon f001a00b 2015-05-29T15:21:47 X11: Force the window focus during ShowWindow if there's no window manager. Fixes Bugzilla #2997.
Sam Lantinga 2c4a6ea0 2015-05-26T06:27:46 Updated the copyright year to 2015
Victor Luchits afc97cbd 2015-05-14T14:40:56 Fix duplicate raw mouse events with XInput2 Make XGrabPointer calls in X11_SetWindowGrab and X11_CaptureMouse consistent by passing False to owner_mask along with proper event_mask.
Ryan C. Gordon 0c0ce209 2015-04-21T10:19:20 Updated comment: this is the correct way to do fullscreen on X11 now.
Ryan C. Gordon 14e00777 2015-04-21T10:14:17 x11: window managers might mark windows as FULLSCREEN _and_ MAXIMIZED. This patch came from Unreal Engine 4's fork of SDL, compliments of Epic Games.
Ryan C. Gordon e0e04542 2015-04-21T09:46:48 Added a few FIXMEs.
Ryan C. Gordon d4aedf99 2015-04-21T09:45:58 Added SDL_SetWindowModalFor(). This is currently only implemented for X11. This patch is based on work in Unreal Engine 4's fork of SDL, compliments of Epic Games.
Ryan C. Gordon 9a752798 2015-04-21T01:22:32 x11: Workaround window managers that mark fullscreen windows as maximized. This patch came from Unreal Engine 4's fork of SDL, compliments of Epic Games.
Ryan C. Gordon b72938c8 2015-04-20T12:22:44 Windows: Always set the system timer resolution to 1ms by default. An existing hint lets apps that don't need the timer resolution changed avoid this, to save battery, etc, but this fixes several problems in timing, audio callbacks not firing fast enough, etc. Fixes Bugzilla #2944.
Alex Szpakowski fe6c797c 2015-04-10T23:30:31 Fixed an iOS view orientation issue when SDL_GL_CreateContext or SDL_CreateRenderer is called.
Ryan C. Gordon a210dbcb 2015-04-08T02:42:29 Removed unused variable.
Ryan C. Gordon 53287ad5 2015-04-08T02:31:54 X11: Removed code to set "icon" title, since it was never used. (Leftover from SDL 1.2, which let you specify this?)
Ryan C. Gordon 6e53bc9b 2015-04-08T02:00:14 SDL_SetWindowTitle() should never set a NULL pointer for the title string. Various backends reacted differently (or not at all) in the presence of a NULL pointer. This simplifies things. Fixes Bugzilla #2902.
Edward Rudd b88ca1b4 2015-02-10T16:28:56 the last parameter of XChangeProperty is the number of elements.. and when the element format is 32.. the element is "long" so we have 5 long elements here. Yes this seems confusing as on mac+linux Long is either 32 or 64bits depending on the architecture, but this is how the X11 protocol is defined. Thus 5 is the correct value for the nelts here. Not 5 or 10 depending on the architecture. More info on the confusion https://bugs.freedesktop.org/show_bug.cgi?id=16802
Philipp Wiesemann b48e54aa 2015-01-26T22:00:29 Fixed bug 2802 - [patch] Fix android build compiling in wrong filesystem implementation Jonas Kulla The configure script didn't differentiate between Linux and Android, unconditionally compiling in the unix implementation of SDL_sysfilesystem.c. I'm probably one of the very few people building SDL for android using classic configure + standalone toolchain, so this has gone undetected all along.
David Ludwig 70438be2 2014-12-03T10:55:23 WinRT: fixed bug whereby SDL would override an app's default orientation WinRT apps can set a default, preferred orientation via a .appxmanifest file. SDL was overriding this on app startup, and making the app use all possible orientations (landscape and portrait). Thanks to Eric Wing for the heads up on this!
Philipp Wiesemann 9c398852 2014-11-22T22:20:40 Corrected header file documentation comment.
Pierre-Loup A. Griffais 24c86b55 2014-09-11T19:24:42 [X11] Reconcile logical keyboard state with physical state on FocusIn since the window system doesn't do it for us like other platforms. This prevents sticky keys and missed keys when going in and out of focus, for example Alt would appear to stick if switching away from an SDL app with Alt-Tab and had to be pressed again. CR: Sam
Sam Lantinga 66a88c6c 2014-08-25T10:55:54 Fixed memory leak getting the X11 window title
Sam Lantinga d44f3922 2014-07-07T10:33:32 Fixed bug 2629 - Mac: crash when calling SDL_DestroyWindow with an active OpenGL context Alex Szpakowski Since this commit https://hg.libsdl.org/SDL/rev/59b543340d63 , calling SDL_DestroyWindow will crash the program if the window has an active OpenGL context. This is because the Cocoa_DestroyWindow code sets the window's driverdata to NULL and then calls [context setWindow:NULL], which tries to access the window's driverdata, resulting in a null pointer dereference. I have attached a patch which fixes the issue by moving the line which sets the driverdata to NULL to after the lines which call functions that use the driverdata pointer.
Ryan C. Gordon b29740b8 2014-06-25T17:06:12 Merged Ryan's SDL-gui-backend branch. Adds three APIs, and implements them on X11, Cocoa, and Windows: - SDL_CaptureMouse() - SDL_GetGlobalMouseState() - SDL_SetWindowHitTest()
Sam Lantinga b7b6d8ab 2014-06-22T02:30:36 Fixed crash initializing OpenGL ES renderer if OpenGL renderer fails
Ryan C. Gordon 98c03f39 2014-05-28T01:22:47 Changed drag area API to a hit-testing API. There were several good arguments for this: it's how Windows works with WM_NCHITTEST, SDL doesn't need to manage a list of rects, it allows more control over the regions (how do you use rects to cleanly surround a circular button?), the callback can be more optimized than a iterating a list of rects, and you don't have to send an updated list of rects whenever the window resizes or layout changes.
Damian Kaczmarek 2744c019 2014-05-27T14:41:16 Initial work on X11 implementation of SDL_SetWindowDragAreas().
Ryan C. Gordon dd5277d6 2014-05-24T21:06:40 Fixed stack overflow in X11_CreateWindow() (thanks, rapha and Brad!). This should be a "long" which on a 64-bit system is likely to be > 32-bits, causing XGetICValues() to write past the end of the variable (and stack). Fixes Bugzilla #2513.
Sam Lantinga 2dacb60b 2014-04-17T20:06:02 Fixed bug 2086 - valgrind memory not released Sylvain Someone provided a patch for this, recently on the mailing list : ----- Hi, it is possible to skip the bug in libX11 by using the defaults for XNResourceName and XNResourceClass in `XCreateIC' (the table for the "Input Context Values" [1] in libX11-doc shows that a default is provided if it is not set). diff -ur SDL2-2.0.3~/src/video/x11/SDL_x11window.c SDL2-2.0.3/src/video/x11/SDL_x11window.c --- SDL2-2.0.3~/src/video/x11/SDL_x11window.c 2014-04-04 17:09:40.764307181 +0200 +++ SDL2-2.0.3/src/video/x11/SDL_x11window.c 2014-04-04 17:10:23.887765046 +0200 @@ -239,8 +239,7 @@ data->ic = X11_XCreateIC(videodata->im, XNClientWindow, w, XNFocusWindow, w, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, - XNResourceName, videodata->classname, XNResourceClass, - videodata->classname, NULL); + NULL); } #endif data->created = created; Tito Latini [1] http://www.x.org/releases/X11R7.7-RC1/doc/libX11/libX11/libX11.html#Input_Context_Values
David Ludwig 3dcb451f 2014-04-09T21:29:19 Added a README file regarding WinRT support To note, this file is currently formatted with CRLF line endings, rather than LF, to allow the file to be viewed with Notepad.
Sam Lantinga 58edac3e 2014-02-02T00:53:27 Fixed bug 2374 - Update copyright for 2014... Is it that time already??
Gabriel Jacobo f848adff 2013-11-29T10:06:08 Improve Android pause/resume behavior.
Ryan C. Gordon 7e1289af 2013-11-24T23:56:17 Make internal SDL sources include SDL_internal.h instead of SDL_config.h The new header will include SDL_config.h, but allows for other global stuff.
Gabriel Jacobo 819148a8 2013-11-11T19:17:32 [X11] Fix up compilation when EGL headers are not present.
Sam Lantinga f5fa492e 2013-10-20T20:42:55 Added a macro SDL_TICKS_PASSED() to correctly compare two 32-bit tick values. Went through the code and used the macro and fixed a couple places that were using incorrect timestamp comparisons.
Ryan C. Gordon a2bd8970 2013-10-18T01:36:41 Don't supply duplicate X11 symbols inside SDL. Fixes static linking when something else also uses X11.
Gabriel Jacobo 074a1c4c 2013-10-12T16:29:34 Fixes X11 video backend compilation when no GL is available For example, in our Raspberry Pi sysroot.
Sam Lantinga 8b6ad7ff 2013-09-27T23:47:57 Fixed bug 2101 - CWBackPixel causes weird window flickering on window resize aBothe I tried to experiment a bit with SDL2 and OpenGL today and noticed that something caused some weird flickering when resizing my nicely drawn SDL2/OpenGL window: Just after resizing, the background went black and I had to let my OpenGL code redraw the contents.. However, after some hours spent with googling I found out that in OpenGL examples where this CWBackPixel flag was not used when creating X windows, there was no flickering while resizing the window. See http://www.sbin.org/doc/Xlib/chapt_04.html @ "The Window Background" for more info.
Sam Lantinga 49d64d52 2013-09-13T17:42:38 Fix X11_RestoreWindow() and X11_RaiseWindow() to properly do window activation. X11_RestoreWindow() had a call ordering problem that prevented activation, and X11_RaiseWindow() wasn't attempting activation. Windows and OS X both activate in these cases. CR: saml
pgriffais a9166450 2013-09-10T18:25:13 [SDL] X11+GL: Allow Visual override for GL windows. SDL provides an SDL_VIDEO_X11_VISUALID environment variable that lets you override window visuals, but it wasn't being checked for OpenGL windows. CR: Sam.
Gabriel Jacobo ace1e98a 2013-08-29T15:02:32 Fixes bug #2040, prepare SDL_GL_CONTEXT_EGL for deprecation on v2.1 SDL_GL_CONTEXT_EGL = 1 is now internally treated as profile_mask = SDL_GL_CONTEXT_PROFILE_ES
Sam Lantinga 3d217ed7 2013-08-21T10:07:48 Fixed crash if the IC isn't set up for some reason (bad X11 locale?)
Gabriel Jacobo 1e49b1ed 2013-08-21T09:47:10 OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo 695344d1 2013-08-21T09:43:09 OCD fixes: Adds a space before */
Gabriel Jacobo 0eeb76d8 2013-08-19T16:29:46 Fixes bug #2037, common EGL code for Android and X11
Gabriel Jacobo dad42067 2013-08-12T11:13:50 Fixes #2022, do not resume on Android when surfaceChanged If the app is in landscape mode and the user presses the power button, a pause is followed immediately by a surfaceChanged event because the lock screen is shown in portrait mode. This triggers a "false" resume. So, we just pause and resume following the onWindowFocusChanged events. Also, wait for SDL_APP_WILLENTERBACKGROUND and SDL_APP_DIDENTERBACKGROUND before blocking the event pump.
Sam Lantinga 1ad936eb 2013-08-11T19:56:43 Fixed bug 2027 - Full-screen appears to be broken - hang in SDL_DestroyWindow() Rainer Deyke I'm running Linux Mint 15 with the Cinnamon window manager. SDL_DestroyWindow consistently locks up for me when the window if fullscreen.
Sam Lantinga e14e0ef9 1970-01-01T04:04:21 Fixed crash if the OpenGL library hasn't been loaded yet