summaryrefslogtreecommitdiffstats
path: root/video/out/w32_common.c
Commit message (Collapse)AuthorAgeFilesLines
* w32_common: add more rounded-down frame ratesJames Ross-Gowan2015-04-251-0/+4
| | | | | Suggested by avih. This handles x/1.001 frame rates for all multiples of 24 and 30 under 144.
* w32_common: use the current monitor's refresh rateJames Ross-Gowan2015-04-251-9/+10
|
* w32_common: prevent system sleepJames Ross-Gowan2015-04-201-1/+2
| | | | | | This prevents the machine from going to sleep while a video-only stream is playing. When audio is playing, the audio stack should make this request for us.
* Update license headersMarcin Kurczewski2015-04-131-5/+4
| | | | Signed-off-by: wm4 <wm4@nowhere>
* win32: support get display fpsAvi Halachmi (:avih)2015-03-131-0/+54
|
* w32_common: don't hide cursor when the menu is openJames Ross-Gowan2015-03-131-8/+8
| | | | | | | | | | | | Previously, mpv would hide the cursor when the autohide timer expired, even if the window menu was open. This made it difficult to use the menu with the mouse. When handling VOCTRL_SET_CURSOR_VISIBILITY, instead of determining whether to call SetCursor by checking if the cursor is in the client area, call it based on the parameters to the last WM_SETCURSOR message. When the window enters "menu mode," it gets a WM_SETCURSOR message with HIWORD(lParam) set to 0 to indicate that the cursor shouldn't be set.
* w32_common: remove redundant is_maximized functionJames Ross-Gowan2015-03-091-8/+1
| | | | This already exists as IsMaximized in the Windows API.
* w32_common: support the "window-minimized" propertyJames Ross-Gowan2015-03-091-0/+6
|
* win32: fix some more -Wparentheses warningswm42015-03-041-1/+1
| | | | | | | Stupid compiler. For decode_surrogate_pair(), I changed the order of evaluation; it shouldn't matter, but this order is more readable in my opinion.
* input: add MOUSE_ENTER keybinding.torque2015-02-181-1/+3
| | | | Signed-off-by: wm4 <wm4@nowhere>
* win32: don't resize when window is minimizedwm42015-02-021-5/+6
| | | | | | | | At least the opengl-hq VO allocates additional resources when downscaling a lot, which is just a waste. Also see #1547 (although I doubt that this is the cause; if it is, a real fix will be required).
* command: unify handling of fullscreen and other VO flagswm42015-01-161-0/+1
| | | | | | | | The "ontop" and "border" properties already used a common mp_property_vo_flag() function, and the corresponding VOCTRLs used the same conventions. "fullscreen" is pretty similar, but was handled slightly similar. Change how VOCTRL_FULLSCREEN behaves, and use the same helper function for "fullscreen" as the other flags.
* win32: minor simplificationwm42015-01-081-3/+2
| | | | The events parameter is not needed here and won't ever be.
* win32: request UTF-16 API variants, Vista+ APIs, and COM C macroswm42015-01-071-2/+0
| | | | | Put the Vista+ (_WIN32_WINNT) and the COM C (COBJMACROS) defines into the build system, instead of defining them over and over in the code.
* w32_common: allow window resizing with --no-borderJames Ross-Gowan2014-12-291-0/+58
|
* Revert "vo/w32_common: use local definition of IID_ITaskbarList2"Kevin Mitchell2014-12-161-7/+1
| | | | | | This reverts commit 17067343eb10293beb61d3811680b9c59f4db311. Embarassingly, this turned out not to be necessary.
* vo/w32_common: use local definition of IID_ITaskbarList2Kevin Mitchell2014-12-151-1/+7
| | | | It is not defined in the current cygwin release.
* w32: copy WinID optionwm42014-12-091-14/+14
| | | | See previous and next commit.
* w32_common: fix GUID linking in CygwinJames Ross-Gowan2014-12-091-0/+1
|
* w32_common: ensure taskbar is hidden when fullscreenJames Ross-Gowan2014-12-081-2/+28
| | | | | | | | | | | | | | | Windows uses a heuristic to determine if a window should appear fullscreen. If the active window's client area covers the whole screen, the taskbar should move to the bottom of the Z-order, allowing the window to show through. Unfortunately, sometimes it doesn't work and the taskbar stays on top of the "fullscreen" window. ITaskbarList2->MarkFullscreenWindow explicitly tells the shell that a window wants to be fullscreen, so the taskbar is always at the bottom of the Z-order while the marked window is active. This might help with #999. Firefox also uses this interface to fix fullscreen issues.
* win32: add screen offset when handling overlarge windowswm42014-11-281-2/+2
| | | | | | | | | | | MS Windows doesn't allow windows larger than the screen, so we include a hack to make the window smaller. This hack recenters the window (what else would it do?). It didn't account for the virtual offset of the current screen, and it was reported that it forces the window to the first screen. Should fix #1292.
* w32_common: open window menu on Alt+SpaceJames Ross-Gowan2014-11-081-0/+10
| | | | | | Since mpv doesn't call TranslateMessage, this must be done manually. Should fix #1254
* Revert "w32_common: don't override alt+space"wm42014-11-081-16/+8
| | | | | | | | This reverts commit d859549424174179768fcd0310c75823a5ff7cb1. Going to apply the alternative fix through PR #1256, which came just some seconds after pushing the reverted commit. The reverted commit was reported as not actually working.
* w32_common: don't override alt+spacewm42014-11-081-8/+16
| | | | | | Apparently, stealing this from the WM is bad form, just like with F10. Fixes #1254.
* Set thread name for debuggingwm42014-10-191-0/+3
| | | | | | | | | | Especially with other components (libavcodec, OSX stuff), the thread list can get quite populated. Setting the thread name helps when debugging. Since this is not portable, we check the OS variants in waf configure. old-configure just gets a special-case for glibc, since doing a full check here would probably be a waste of effort.
* win32: clear window handle on destructionwm42014-10-171-0/+1
| | | | | | As I understand, otherwise, the code will try to destroy the same window again in the cleanup part of the gui_thread(), which makes no sense and is potentially dangerous.
* options: add --no-keepaspect-windowwm42014-10-041-2/+2
| | | | Seems silly, but was requested.
* w32_common: quit event loop on destroyJames Ross-Gowan2014-09-301-6/+11
| | | | | | | | | | | | When embedding, if the parent window is destroyed, it will cause mpv's window to be destroyed as well. Since WM_USER wakeups are sent to the window, destroying the window will prevent wakeups and cause uninit to hang. Fix this by quitting the event loop on WM_DESTROY. Events should only be processed for the lifetime of the window, from CreateWindowEx to WM_DESTROY. After the event loop is finished, mp_dispatch_queue_process can handle any remaining requests.
* win32: don't request window size larger than the screenwm42014-09-101-3/+34
| | | | | | | | | | | | | | | | | An attempt at fixing #1070. Apparently something goes wrong if the video size is equal to the screen size. Since the window decorations add to the window size, it must actually be larger than the screen. Actually I don't know what exactly is going wrong, but since this commit also slightly improves the behavior otherwise, it's a win anyway. Try to keep the window size strictly below screen size, even accounting for window decorations. Size it down and center the window so that it fits (by either touching the left/right or top/bottom screen borders). I haven't found any information on what is the maximum allowed size and position of a window so that it doesn't collide with the task bar, so assume that we can use the entire screen, minus 1 pixel to avoid triggering fullscreen semantics (if that is even possible).
* win32: copy event flags after running VOCTRLswm42014-09-071-5/+2
| | | | | | | | | reinit_window_state() will set VO_EVENT_RESIZE when it runs, so we don't need to set it manually depending on the VOCTRL. Probably avoids duplicated resize events. I don't expect this actually fixes anything, but might help spotting other bugs easier (if there are any).
* video: rename VOCTRL_GET_WINDOW_SIZEwm42014-09-051-2/+2
| | | | Make it clear that this accesses the un-fullscreened window size.
* video: move display and timing to a separate threadwm42014-08-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The VO is run inside its own thread. It also does most of video timing. The playloop hands the image data and a realtime timestamp to the VO, and the VO does the rest. In particular, this allows the playloop to do other things, instead of blocking for video redraw. But if anything accesses the VO during video timing, it will block. This also fixes vo_sdl.c event handling; but that is only a side-effect, since reimplementing the broken way would require more effort. Also drop --softsleep. In theory, this option helps if the kernel's sleeping mechanism is too inaccurate for video timing. In practice, I haven't ever encountered a situation where it helps, and it just burns CPU cycles. On the other hand it's probably actively harmful, because it prevents the libavcodec decoder threads from doing real work. Side note: Originally, I intended that multiple frames can be queued to the VO. But this is not done, due to problems with OSD and other certain features. OSD in particular is simply designed in a way that it can be neither timed nor copied, so you do have to render it into the video frame before you can draw the next frame. (Subtitles have no such restriction. sd_lavc was even updated to fix this.) It seems the right solution to queuing multiple VO frames is rendering on VO-backed framebuffers, like vo_vdpau.c does. This requires VO driver support, and is out of scope of this commit. As consequence, the VO has a queue size of 1. The existing video queue is just needed to compute frame duration, and will be moved out in the next commit.
* win32: never call GetClientRect(0, ...)wm42014-08-061-1/+4
| | | | | | | | | | | | | | | | | Sometimes GetClientRect() appeared to fail during init, and since we don't check GetClientRect() calls (because they're on our own window, and logically can never fail), bogus resizes were triggered. This could cause vo_direct3d to fail initialization. The reason was that w32->window was set to 0 during early window initialization: CreateWindow*() can send messages to the new window, even though it hasn't returned yet. This means w32->window is not yet set to our window handle, and functions in WndProc may accidentally pass hwnd=0 to win32 API functions. Fix it by initializing w32->window on opportunity. This also means we always strictly expect that the WndProc is used with our own window only.
* win32: create OpenGL context on the GUI threadwm42014-08-051-0/+6
| | | | | | | | | | | | | | | | This fixes the fullscreen issues on Intel for me. I'm baffled by it and don't understand why this suddenly works. Intel drivers being shit? Windows being shit? HWND or HDC being only 97% thread-safe instead of 98%? Me missing something subtle that is not documented anywhere? Who knows. Now instead of creating the HDC and OpenGL context on the renderer thread, they're created on the GUI thread. The renderer thread will then only call wglMakeCurrent, SwapBuffers, and OpenGL standard functions. Probably fixes github issue #968.
* vo: remove vo_mouse_movement() wrapperwm42014-07-271-2/+2
| | | | So that VO backends don't have to access the VO just for that.
* win32: remove minor non-sensewm42014-07-261-1/+0
| | | | This is done in the wrong thread. Was harmless and had no effect at all.
* win32: move window handling to a separate threadwm42014-07-261-60/+174
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The windows message loop now runs in a separate thread. Rendering, such as with Direct3D or OpenGL, still happens in the main thread. In particular, this should prevent the video from freezing if the window is dragged. (The reason was that the message dispatcher won't return while the dragging is active, so mpv couldn't update the video at all.) This is pretty "rough" and just hacked in, and there's no API yet to make this easier for other backends. It will be cleaned up later once we're sure that it works, or when we know how exactly it should work. One oddity is that OpenGL is actually completely managed in the renderer thread, while e.g. Cocoa (which has its own threading code) creates the context in the GUI thread, and then lets the renderer thread access it. One strange issue is that we now have to stop WM_CLOSE from actually closing the window. Instead, we wait until the playloop handles the close command, and requests the VO to shutdown. This is done mainly because closing the window apparently destroys it, and then WM_USER can't be handled anymore - which means the playloop has no way to wakeup the GUI thread. It seems you can't really win here... maybe there's a better way to have a thread receive messages with and without a window, but I didn't find one yet. Dragging the window (by clicking into the middle of it) behaves strangely in wine, but didn't before the change. Reason unknown.
* win32: use gcc TLS instead of WM_NCCREATE tricks for window contextwm42014-07-261-10/+9
| | | | | | | | | | | | win32 does not provide a proper per-window context pointer. Although it does allow passing a user-chosen value to WM_CREATE/WM_NCCREATE, this is not enough - the first message doesn't even have to be WM_NCCREATE. This gets us in trouble later on, so go the easy route and just use a TLS variable. __thread is gcc specific, but Windows is a very "special" platform anyway. We support only MinGW and Cygwin on it, so who cares. (C11 standardizes __thread as _Thread_local; we can use that later.)
* win32: make a flag explicitwm42014-07-261-1/+1
| | | | | | | | This shouldn't change anything. But it's worth making this explicit, since it's very subtle and unintuitive: if the X parameter is the magic value CW_USEDEFAULT, then the Y parameter is used as nCmdShow parameter to ShowWindow(). And in our case, this is SW_HIDE (0), because we want to create a hidden window.
* win32: simplify some --wid embedding codewm42014-07-261-26/+9
| | | | | | | | | | | This looked a bit overcomplicated. We don't care about the window position (it should always be 0/0, unless the parent program moved it, which it shouldn't). We don't care about the global on-screen position. Also, we will just retrieve a WM_SIZE message if our window is resized, and we don't need to update it manually. The only thing we have to do is making sure our window fills the parent window completely.
* win32: don't use CS_OWNDCwm42014-07-261-26/+1
| | | | | | | | | | | | | CS_OWNDC will make GetDC() always return the same HDC. This might become a problem when OpenGL rendering and window management are on different threads. Although I'm not too sure about this; our code never requests a HDC outside of the OpenGL backend, and it depends on whether win32 will internally request DCs. But in any case, this seems to be cleaner. Move the GL pixelformat setup code to gl_w32.c, where it's actually needed. This also fixes that SetPixelFormat() should be called only once, and not every time video params change.
* win32: remove worthless doxygen commentswm42014-07-261-39/+4
| | | | | | These mostly describe self-explanatory things, and fail to explain actually tricky things. Which means you just waste your time reading this, and have to figure it out from the code anyway.
* win32: make private struct private, refactorwm42014-07-261-172/+192
| | | | | | | | | | | | | | | | Preparation for moving win32 windowing to a separate thread. The codesize is reduced a bit, because some small functions are inlined, which reduces noise. The main change is that now most functions use the private struct directly, instead of accessing it indirectly through vo->w32. Accesses to vo are minimalized. The final goal is adding some sort of new windowing backend API. It would be cleaner to use that as context pointer for all functions (like struct vo was previously used), but since this is work in progress, we just go with this commit.
* w32_common: fix typowm42014-05-101-2/+3
| | | | Also, reset rc completely, instead of assuming things.
* win32: don't use VOCTRL_UPDATE_SCREENINFOwm42014-05-061-67/+38
| | | | Not very tested. At least it compiles.
* w32_common: use ToUnicode to translate key inputJames Ross-Gowan2014-04-171-50/+181
| | | | | | | | | | | | | | | | This replaces translate_key_input with a solution that gives mpv more control over how keyboard input is converted to unicode. As a result: - Key up/down events are generated the same way for all keys. - Dead keys generate their base character instead of being combined with the following character. - Many Ctrl and Ctrl+Alt key combinations that were previously broken are fixed, since it's possible to discover the base keys. - AltGr doesn't produce special characters when mp_input_use_alt_gr is false. This also fixes some logic to do with detecting AltGr and adds proper UTF-16 decoding.
* w32_common: prevent MOUSE_BTN0 sticking after dragJames Ross-Gowan2014-03-121-0/+2
| | | | | | The window doesn't recieve a WM_LBUTTONUP message after it's dragged, probably because it's swallowed by the modal loop. To stop the button from sticking, release it manually when the drag is complete.
* w32_common: capture mouse inputJames Ross-Gowan2014-03-121-0/+5
| | | | | | Mouse buttons can get stuck down if the button is pressed inside the video window and released outside. Avoid this by capturing mouse input when a button is pressed.
* w32_common: don't set small iconJames Ross-Gowan2014-02-171-4/+1
| | | | | Windows will automatically choose the correct icon size if this field is unset.
* w32_common: Fix extended keysJames Ross-Gowan2014-01-211-1/+1
| | | | The KF_* flags work on the HIWORD of lParam. Whoops
* w32: use the w32_common keymap in terminal-win tooJames Ross-Gowan2014-01-191-58/+5
|
* w32_common: add extended keysJames Ross-Gowan2014-01-151-23/+54
| | | | Also VK_APPS/MP_KEY_MENU was missing.
* w32_common: prevent decoding certain keys twiceJames Ross-Gowan2014-01-151-12/+34
| | | | | | | | This is a bit of a hack, but in order to prevent TranslateMessage from seeing WM_KEYDOWN messages that we already know how to decode, move the decoding logic to the event loop. This should fix #476, since it stops the generation of extraneous WM_CHAR messages that were triggering more than one action on keydown.
* video/out: simplify monitor aspect handlingwm42014-01-111-2/+0
| | | | | | | | For some reason, this made all VO backends both set the screen resolution in opts->screenwidth/height, and call aspect_save_screenres(). Remove the latter. Move the code to calculate the PAR-corrected window size from aspect.c to vo.c, and make it so that the monitor PAR is recalculated when it makes sense.
* w32_common: reformat yet againMartin Herkt2014-01-061-208/+208
| | | | | I've been told mpv prefers switch/case on the same indent level. Sorry about the noise :P
* w32_common: don't force topmost on fullscreenMartin Herkt2014-01-061-1/+2
| | | | Fixes #457, #444.
* w32_common: reformat slightlyMartin Herkt2014-01-061-68/+99
| | | | This really needs more whitespace.
* w32_common: use OLE DnD for text/uri-list supportxnoreq2014-01-061-39/+203
| | | | Signed-off-by: Martin Herkt <lachs0r@srsfckn.biz>
* w32_common: support file drag and dropMartin Herkt2013-12-201-0/+38
|
* w32_common: fix mouse clicksMartin Herkt2013-12-191-12/+17
| | | | | | | | | | | | | | Apparently this has been broken for a year or so. The were three reasons for the breakage here: 1. The window dragging hack prevented any DOWN event from passing through since it always returned before we even got the button. 2. The window style had CS_DBLCLKS in its flags, so we did not get any DOWN events when the OS had detected a double click (instead expecting us to handle a DBL event). 3. We never sent any mouse buttons when mouse movement handling was disabled.
*