2006-10-24 15:26:33 +02:00
|
|
|
/*
|
2012-12-17 01:06:52 +01:00
|
|
|
* MACDRV initialization code
|
2006-10-24 15:26:33 +02:00
|
|
|
*
|
|
|
|
* Copyright 1998 Patrik Stridvall
|
|
|
|
* Copyright 2000 Alexandre Julliard
|
2013-01-07 21:44:36 +01:00
|
|
|
* Copyright 2011, 2012, 2013 Ken Thomases for CodeWeavers Inc.
|
2006-10-24 15:26:33 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
|
2013-03-04 21:46:46 +01:00
|
|
|
#include <Security/AuthSession.h>
|
2013-01-28 20:32:21 +01:00
|
|
|
#include <IOKit/pwr_mgt/IOPMLib.h>
|
2013-03-04 21:46:46 +01:00
|
|
|
|
2013-01-07 21:44:36 +01:00
|
|
|
#include "macdrv.h"
|
2013-01-28 20:32:21 +01:00
|
|
|
#include "winuser.h"
|
2013-05-29 16:21:25 +02:00
|
|
|
#include "winreg.h"
|
2013-01-21 07:07:58 +01:00
|
|
|
#include "wine/server.h"
|
2013-01-07 21:44:36 +01:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(macdrv);
|
2006-10-24 15:26:33 +02:00
|
|
|
|
2013-01-28 20:32:21 +01:00
|
|
|
#ifndef kIOPMAssertionTypePreventUserIdleDisplaySleep
|
|
|
|
#define kIOPMAssertionTypePreventUserIdleDisplaySleep CFSTR("PreventUserIdleDisplaySleep")
|
|
|
|
#endif
|
|
|
|
#ifndef kCFCoreFoundationVersionNumber10_7
|
|
|
|
#define kCFCoreFoundationVersionNumber10_7 635.00
|
|
|
|
#endif
|
2006-10-24 15:26:33 +02:00
|
|
|
|
2013-06-07 00:43:06 +02:00
|
|
|
#define IS_OPTION_TRUE(ch) \
|
|
|
|
((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1')
|
|
|
|
|
2013-05-04 06:05:08 +02:00
|
|
|
C_ASSERT(NUM_EVENT_TYPES <= sizeof(macdrv_event_mask) * 8);
|
|
|
|
|
2013-01-21 07:07:58 +01:00
|
|
|
DWORD thread_data_tls_index = TLS_OUT_OF_INDEXES;
|
|
|
|
|
2013-05-29 16:21:25 +02:00
|
|
|
int topmost_float_inactive = TOPMOST_FLOAT_INACTIVE_NONFULLSCREEN;
|
2013-06-07 00:43:06 +02:00
|
|
|
int capture_displays_for_fullscreen = 0;
|
2013-07-02 08:25:32 +02:00
|
|
|
BOOL skip_single_buffer_flushes = FALSE;
|
2013-07-02 08:25:50 +02:00
|
|
|
BOOL allow_vsync = TRUE;
|
2013-07-09 00:36:49 +02:00
|
|
|
BOOL allow_set_gamma = TRUE;
|
2013-10-09 23:30:59 +02:00
|
|
|
int left_option_is_alt = 0;
|
|
|
|
int right_option_is_alt = 0;
|
2018-09-12 11:35:30 +02:00
|
|
|
int left_command_is_ctrl = 0;
|
|
|
|
int right_command_is_ctrl = 0;
|
2013-10-21 23:37:05 +02:00
|
|
|
BOOL allow_software_rendering = FALSE;
|
2013-11-21 21:47:57 +01:00
|
|
|
BOOL disable_window_decorations = FALSE;
|
2013-12-30 04:33:30 +01:00
|
|
|
int allow_immovable_windows = TRUE;
|
2014-04-28 22:09:28 +02:00
|
|
|
int cursor_clipping_locks_windows = TRUE;
|
2014-05-15 03:15:35 +02:00
|
|
|
int use_precise_scrolling = TRUE;
|
winemac: Add a new registry setting, OpenGLSurfaceMode, to control how GL surfaces relate to the window.
The default behavior is that GL surfaces are on top of all non-GL content in
the window. This maximizes the performance for the common case of games, but
clipping by parents, siblings, and child windows isn't respected.
Setting OpenGLSurfaceMode to "behind" pushes the GL surface to be behind the
Mac window. The window has transparent holes punched through it so that the GL
surface shows through. USER32 and the wineserver take care of making sure the
holes are only where the GL windows would be unclipped and unoccluded. Because
the OS X window server has to composite the GL surface with the window, this
limits the framerate.
Since the Mac driver has no server-side rendering path, GDI rendering to a
window which has a GL surface doesn't work. As a partial workaround, mostly
for cases where a GL surface is created but never used, setting
OpenGLSurfaceMode to "transparent" allows the GDI rendering to show through the
transparent parts of the GL surface. The GDI rendering is drawn to the
top-level window's surface as normal. (The behavior of user32 to exclude the
portion covered by a GL window from GDI rendering is disabled.) The GL surface
is in front of the window but potentially wholly or partially transparent. It
is composited with the window behind it.
The GL surface is initially cleared to be completely transparent. So, if
no GL rendering is done, the window will appear as though the GL surface didn't
exist.
2015-09-15 03:35:25 +02:00
|
|
|
int gl_surface_mode = GL_SURFACE_IN_FRONT_OPAQUE;
|
2016-05-05 20:53:36 +02:00
|
|
|
int retina_enabled = FALSE;
|
2013-10-21 11:31:10 +02:00
|
|
|
HMODULE macdrv_module = 0;
|
2018-07-16 05:54:15 +02:00
|
|
|
int enable_app_nap = FALSE;
|
2013-05-29 16:21:25 +02:00
|
|
|
|
2015-11-17 05:10:21 +01:00
|
|
|
CFDictionaryRef localized_strings;
|
|
|
|
|
2013-01-21 07:07:58 +01:00
|
|
|
|
2013-02-25 05:53:21 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* debugstr_cf
|
|
|
|
*/
|
|
|
|
const char* debugstr_cf(CFTypeRef t)
|
|
|
|
{
|
|
|
|
CFStringRef s;
|
|
|
|
const char* ret;
|
|
|
|
|
|
|
|
if (!t) return "(null)";
|
|
|
|
|
|
|
|
if (CFGetTypeID(t) == CFStringGetTypeID())
|
|
|
|
s = t;
|
|
|
|
else
|
|
|
|
s = CFCopyDescription(t);
|
|
|
|
ret = CFStringGetCStringPtr(s, kCFStringEncodingUTF8);
|
|
|
|
if (ret) ret = debugstr_a(ret);
|
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
const UniChar* u = CFStringGetCharactersPtr(s);
|
|
|
|
if (u)
|
|
|
|
ret = debugstr_wn((const WCHAR*)u, CFStringGetLength(s));
|
|
|
|
}
|
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
UniChar buf[200];
|
2018-08-15 23:26:24 +02:00
|
|
|
int len = min(CFStringGetLength(s), ARRAY_SIZE(buf));
|
2013-02-25 05:53:21 +01:00
|
|
|
CFStringGetCharacters(s, CFRangeMake(0, len), buf);
|
|
|
|
ret = debugstr_wn(buf, len);
|
|
|
|
}
|
|
|
|
if (s != t) CFRelease(s);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-29 16:21:25 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* get_config_key
|
|
|
|
*
|
|
|
|
* Get a config key from either the app-specific or the default config
|
|
|
|
*/
|
|
|
|
static inline DWORD get_config_key(HKEY defkey, HKEY appkey, const char *name,
|
|
|
|
char *buffer, DWORD size)
|
|
|
|
{
|
|
|
|
if (appkey && !RegQueryValueExA(appkey, name, 0, NULL, (LPBYTE)buffer, &size)) return 0;
|
|
|
|
if (defkey && !RegQueryValueExA(defkey, name, 0, NULL, (LPBYTE)buffer, &size)) return 0;
|
|
|
|
return ERROR_FILE_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* setup_options
|
|
|
|
*
|
|
|
|
* Set up the Mac driver options.
|
|
|
|
*/
|
|
|
|
static void setup_options(void)
|
|
|
|
{
|
|
|
|
char buffer[MAX_PATH + 16];
|
|
|
|
HKEY hkey, appkey = 0;
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
/* @@ Wine registry key: HKCU\Software\Wine\Mac Driver */
|
|
|
|
if (RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Mac Driver", &hkey)) hkey = 0;
|
|
|
|
|
|
|
|
/* open the app-specific key */
|
|
|
|
|
|
|
|
len = GetModuleFileNameA(0, buffer, MAX_PATH);
|
|
|
|
if (len && len < MAX_PATH)
|
|
|
|
{
|
|
|
|
HKEY tmpkey;
|
|
|
|
char *p, *appname = buffer;
|
|
|
|
if ((p = strrchr(appname, '/'))) appname = p + 1;
|
|
|
|
if ((p = strrchr(appname, '\\'))) appname = p + 1;
|
|
|
|
strcat(appname, "\\Mac Driver");
|
|
|
|
/* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\Mac Driver */
|
|
|
|
if (!RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\AppDefaults", &tmpkey))
|
|
|
|
{
|
|
|
|
if (RegOpenKeyA(tmpkey, appname, &appkey)) appkey = 0;
|
|
|
|
RegCloseKey(tmpkey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!get_config_key(hkey, appkey, "WindowsFloatWhenInactive", buffer, sizeof(buffer)))
|
|
|
|
{
|
|
|
|
if (!strcmp(buffer, "none"))
|
|
|
|
topmost_float_inactive = TOPMOST_FLOAT_INACTIVE_NONE;
|
|
|
|
else if (!strcmp(buffer, "all"))
|
|
|
|
topmost_float_inactive = TOPMOST_FLOAT_INACTIVE_ALL;
|
|
|
|
else
|
|
|
|
topmost_float_inactive = TOPMOST_FLOAT_INACTIVE_NONFULLSCREEN;
|
|
|
|
}
|
|
|
|
|
2013-06-07 00:43:06 +02:00
|
|
|
if (!get_config_key(hkey, appkey, "CaptureDisplaysForFullscreen", buffer, sizeof(buffer)))
|
|
|
|
capture_displays_for_fullscreen = IS_OPTION_TRUE(buffer[0]);
|
|
|
|
|
2013-07-02 08:25:32 +02:00
|
|
|
if (!get_config_key(hkey, appkey, "SkipSingleBufferFlushes", buffer, sizeof(buffer)))
|
|
|
|
skip_single_buffer_flushes = IS_OPTION_TRUE(buffer[0]);
|
|
|
|
|
2013-07-02 08:25:50 +02:00
|
|
|
if (!get_config_key(hkey, appkey, "AllowVerticalSync", buffer, sizeof(buffer)))
|
|
|
|
allow_vsync = IS_OPTION_TRUE(buffer[0]);
|
|
|
|
|
2013-07-09 00:36:49 +02:00
|
|
|
if (!get_config_key(hkey, appkey, "AllowSetGamma", buffer, sizeof(buffer)))
|
|
|
|
allow_set_gamma = IS_OPTION_TRUE(buffer[0]);
|
|
|
|
|
2013-10-09 23:30:59 +02:00
|
|
|
if (!get_config_key(hkey, appkey, "LeftOptionIsAlt", buffer, sizeof(buffer)))
|
|
|
|
left_option_is_alt = IS_OPTION_TRUE(buffer[0]);
|
|
|
|
if (!get_config_key(hkey, appkey, "RightOptionIsAlt", buffer, sizeof(buffer)))
|
|
|
|
right_option_is_alt = IS_OPTION_TRUE(buffer[0]);
|
|
|
|
|
2018-09-12 11:35:30 +02:00
|
|
|
if (!get_config_key(hkey, appkey, "LeftCommandIsCtrl", buffer, sizeof(buffer)))
|
|
|
|
left_command_is_ctrl = IS_OPTION_TRUE(buffer[0]);
|
|
|
|
if (!get_config_key(hkey, appkey, "RightCommandIsCtrl", buffer, sizeof(buffer)))
|
|
|
|
right_command_is_ctrl = IS_OPTION_TRUE(buffer[0]);
|
|
|
|
|
|
|
|
if (left_command_is_ctrl && right_command_is_ctrl && !left_option_is_alt && !right_option_is_alt)
|
|
|
|
WARN("Both Command keys have been mapped to Control. There is no way to "
|
|
|
|
"send an Alt key to Windows applications. Consider enabling "
|
|
|
|
"LeftOptionIsAlt or RightOptionIsAlt.\n");
|
|
|
|
|
2013-10-21 23:37:05 +02:00
|
|
|
if (!get_config_key(hkey, appkey, "AllowSoftwareRendering", buffer, sizeof(buffer)))
|
|
|
|
allow_software_rendering = IS_OPTION_TRUE(buffer[0]);
|
|
|
|
|
2013-11-21 21:47:57 +01:00
|
|
|
/* Value name chosen to match what's used in the X11 driver. */
|
|
|
|
if (!get_config_key(hkey, appkey, "Decorated", buffer, sizeof(buffer)))
|
|
|
|
disable_window_decorations = !IS_OPTION_TRUE(buffer[0]);
|
|
|
|
|
2013-12-30 04:33:30 +01:00
|
|
|
if (!get_config_key(hkey, appkey, "AllowImmovableWindows", buffer, sizeof(buffer)))
|
|
|
|
allow_immovable_windows = IS_OPTION_TRUE(buffer[0]);
|
|
|
|
|
2014-04-28 22:09:28 +02:00
|
|
|
if (!get_config_key(hkey, appkey, "CursorClippingLocksWindows", buffer, sizeof(buffer)))
|
|
|
|
cursor_clipping_locks_windows = IS_OPTION_TRUE(buffer[0]);
|
|
|
|
|
2014-05-15 03:15:35 +02:00
|
|
|
if (!get_config_key(hkey, appkey, "UsePreciseScrolling", buffer, sizeof(buffer)))
|
|
|
|
use_precise_scrolling = IS_OPTION_TRUE(buffer[0]);
|
|
|
|
|
winemac: Add a new registry setting, OpenGLSurfaceMode, to control how GL surfaces relate to the window.
The default behavior is that GL surfaces are on top of all non-GL content in
the window. This maximizes the performance for the common case of games, but
clipping by parents, siblings, and child windows isn't respected.
Setting OpenGLSurfaceMode to "behind" pushes the GL surface to be behind the
Mac window. The window has transparent holes punched through it so that the GL
surface shows through. USER32 and the wineserver take care of making sure the
holes are only where the GL windows would be unclipped and unoccluded. Because
the OS X window server has to composite the GL surface with the window, this
limits the framerate.
Since the Mac driver has no server-side rendering path, GDI rendering to a
window which has a GL surface doesn't work. As a partial workaround, mostly
for cases where a GL surface is created but never used, setting
OpenGLSurfaceMode to "transparent" allows the GDI rendering to show through the
transparent parts of the GL surface. The GDI rendering is drawn to the
top-level window's surface as normal. (The behavior of user32 to exclude the
portion covered by a GL window from GDI rendering is disabled.) The GL surface
is in front of the window but potentially wholly or partially transparent. It
is composited with the window behind it.
The GL surface is initially cleared to be completely transparent. So, if
no GL rendering is done, the window will appear as though the GL surface didn't
exist.
2015-09-15 03:35:25 +02:00
|
|
|
if (!get_config_key(hkey, appkey, "OpenGLSurfaceMode", buffer, sizeof(buffer)))
|
|
|
|
{
|
|
|
|
if (!strcmp(buffer, "transparent"))
|
|
|
|
gl_surface_mode = GL_SURFACE_IN_FRONT_TRANSPARENT;
|
|
|
|
else if (!strcmp(buffer, "behind"))
|
|
|
|
gl_surface_mode = GL_SURFACE_BEHIND;
|
|
|
|
else
|
|
|
|
gl_surface_mode = GL_SURFACE_IN_FRONT_OPAQUE;
|
|
|
|
}
|
|
|
|
|
2018-07-16 05:54:15 +02:00
|
|
|
if (!get_config_key(hkey, appkey, "EnableAppNap", buffer, sizeof(buffer)))
|
|
|
|
enable_app_nap = IS_OPTION_TRUE(buffer[0]);
|
|
|
|
|
2016-05-05 20:53:36 +02:00
|
|
|
/* Don't use appkey. The DPI and monitor sizes should be consistent for all
|
|
|
|
processes in the prefix. */
|
|
|
|
if (!get_config_key(hkey, NULL, "RetinaMode", buffer, sizeof(buffer)))
|
|
|
|
retina_enabled = IS_OPTION_TRUE(buffer[0]);
|
|
|
|
|
2013-05-29 16:21:25 +02:00
|
|
|
if (appkey) RegCloseKey(appkey);
|
|
|
|
if (hkey) RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-17 05:10:21 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* load_strings
|
|
|
|
*/
|
|
|
|
static void load_strings(HINSTANCE instance)
|
|
|
|
{
|
|
|
|
static const unsigned int ids[] = {
|
|
|
|
STRING_MENU_WINE,
|
|
|
|
STRING_MENU_ITEM_HIDE_APPNAME,
|
|
|
|
STRING_MENU_ITEM_HIDE,
|
|
|
|
STRING_MENU_ITEM_HIDE_OTHERS,
|
|
|
|
STRING_MENU_ITEM_SHOW_ALL,
|
|
|
|
STRING_MENU_ITEM_QUIT_APPNAME,
|
|
|
|
STRING_MENU_ITEM_QUIT,
|
|
|
|
|
|
|
|
STRING_MENU_WINDOW,
|
|
|
|
STRING_MENU_ITEM_MINIMIZE,
|
|
|
|
STRING_MENU_ITEM_ZOOM,
|
|
|
|
STRING_MENU_ITEM_ENTER_FULL_SCREEN,
|
|
|
|
STRING_MENU_ITEM_BRING_ALL_TO_FRONT,
|
|
|
|
};
|
|
|
|
CFMutableDictionaryRef dict;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
dict = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks,
|
|
|
|
&kCFTypeDictionaryValueCallBacks);
|
|
|
|
if (!dict)
|
|
|
|
{
|
|
|
|
ERR("Failed to create localized strings dictionary\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-08-15 23:26:24 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(ids); i++)
|
2015-11-17 05:10:21 +01:00
|
|
|
{
|
|
|
|
LPCWSTR str;
|
|
|
|
int len = LoadStringW(instance, ids[i], (LPWSTR)&str, 0);
|
|
|
|
if (str && len)
|
|
|
|
{
|
|
|
|
CFNumberRef key = CFNumberCreate(NULL, kCFNumberIntType, &ids[i]);
|
|
|
|
CFStringRef value = CFStringCreateWithCharacters(NULL, (UniChar*)str, len);
|
|
|
|
if (key && value)
|
|
|
|
CFDictionarySetValue(dict, key, value);
|
|
|
|
else
|
|
|
|
ERR("Failed to add string ID 0x%04x %s\n", ids[i], debugstr_wn(str, len));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ERR("Failed to load string ID 0x%04x\n", ids[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
localized_strings = dict;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-21 07:07:58 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* process_attach
|
|
|
|
*/
|
2013-10-21 11:31:10 +02:00
|
|
|
static BOOL process_attach(void)
|
2013-01-21 07:07:58 +01:00
|
|
|
{
|
2013-03-04 21:46:46 +01:00
|
|
|
SessionAttributeBits attributes;
|
|
|
|
OSStatus status;
|
|
|
|
|
|
|
|
status = SessionGetInfo(callerSecuritySession, NULL, &attributes);
|
|
|
|
if (status != noErr || !(attributes & sessionHasGraphicAccess))
|
|
|
|
return FALSE;
|
|
|
|
|
2013-05-29 16:21:25 +02:00
|
|
|
setup_options();
|
2015-11-17 05:10:21 +01:00
|
|
|
load_strings(macdrv_module);
|
2013-05-29 16:21:25 +02:00
|
|
|
|
2013-01-21 07:07:58 +01:00
|
|
|
if ((thread_data_tls_index = TlsAlloc()) == TLS_OUT_OF_INDEXES) return FALSE;
|
|
|
|
|
|
|
|
macdrv_err_on = ERR_ON(macdrv);
|
2013-01-27 23:19:33 +01:00
|
|
|
if (macdrv_start_cocoa_app(GetTickCount64()))
|
2013-01-21 07:07:58 +01:00
|
|
|
{
|
|
|
|
ERR("Failed to start Cocoa app main loop\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2016-08-25 14:36:54 +02:00
|
|
|
* ThreadDetach (MACDRV.@)
|
2013-01-21 07:07:58 +01:00
|
|
|
*/
|
2016-08-25 14:36:54 +02:00
|
|
|
void CDECL macdrv_ThreadDetach(void)
|
2013-01-21 07:07:58 +01:00
|
|
|
{
|
|
|
|
struct macdrv_thread_data *data = macdrv_thread_data();
|
|
|
|
|
|
|
|
if (data)
|
|
|
|
{
|
|
|
|
macdrv_destroy_event_queue(data->queue);
|
2013-02-04 00:20:11 +01:00
|
|
|
if (data->keyboard_layout_uchr)
|
|
|
|
CFRelease(data->keyboard_layout_uchr);
|
2013-01-21 07:07:58 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, data);
|
2013-10-16 20:48:49 +02:00
|
|
|
/* clear data in case we get re-entered from user32 before the thread is truly dead */
|
|
|
|
TlsSetValue(thread_data_tls_index, NULL);
|
2013-01-21 07:07:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-24 15:26:33 +02:00
|
|
|
/***********************************************************************
|
2013-01-21 07:07:58 +01:00
|
|
|
* set_queue_display_fd
|
|
|
|
*
|
|
|
|
* Store the event queue fd into the message queue
|
2006-10-24 15:26:33 +02:00
|
|
|
*/
|
2013-01-21 07:07:58 +01:00
|
|
|
static void set_queue_display_fd(int fd)
|
|
|
|
{
|
|
|
|
HANDLE handle;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (wine_server_fd_to_handle(fd, GENERIC_READ | SYNCHRONIZE, 0, &handle))
|
|
|
|
{
|
|
|
|
MESSAGE("macdrv: Can't allocate handle for event queue fd\n");
|
|
|
|
ExitProcess(1);
|
|
|
|
}
|
|
|
|
SERVER_START_REQ(set_queue_fd)
|
|
|
|
{
|
|
|
|
req->handle = wine_server_obj_handle(handle);
|
|
|
|
ret = wine_server_call(req);
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
MESSAGE("macdrv: Can't store handle for event queue fd\n");
|
|
|
|
ExitProcess(1);
|
|
|
|
}
|
|
|
|
CloseHandle(handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* macdrv_init_thread_data
|
|
|
|
*/
|
|
|
|
struct macdrv_thread_data *macdrv_init_thread_data(void)
|
|
|
|
{
|
|
|
|
struct macdrv_thread_data *data = macdrv_thread_data();
|
2013-11-20 16:30:36 +01:00
|
|
|
TISInputSourceRef input_source;
|
2013-01-21 07:07:58 +01:00
|
|
|
|
|
|
|
if (data) return data;
|
|
|
|
|
|
|
|
if (!(data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data))))
|
|
|
|
{
|
|
|
|
ERR("could not create data\n");
|
|
|
|
ExitProcess(1);
|
|
|
|
}
|
|
|
|
|
2013-03-11 04:58:26 +01:00
|
|
|
if (!(data->queue = macdrv_create_event_queue(macdrv_handle_event)))
|
2013-01-21 07:07:58 +01:00
|
|
|
{
|
|
|
|
ERR("macdrv: Can't create event queue.\n");
|
|
|
|
ExitProcess(1);
|
|
|
|
}
|
|
|
|
|
2013-11-20 16:30:36 +01:00
|
|
|
macdrv_get_input_source_info(&data->keyboard_layout_uchr, &data->keyboard_type, &data->iso_keyboard, &input_source);
|
|
|
|
data->active_keyboard_layout = macdrv_get_hkl_from_source(input_source);
|
|
|
|
CFRelease(input_source);
|
2013-02-04 00:20:11 +01:00
|
|
|
macdrv_compute_keyboard_layout(data);
|
|
|
|
|
2013-01-21 07:07:58 +01:00
|
|
|
set_queue_display_fd(macdrv_get_event_queue_fd(data->queue));
|
|
|
|
TlsSetValue(thread_data_tls_index, data);
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllMain
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved)
|
2006-10-24 15:26:33 +02:00
|
|
|
{
|
|
|
|
BOOL ret = TRUE;
|
|
|
|
|
|
|
|
switch(reason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
2016-08-25 14:36:54 +02:00
|
|
|
DisableThreadLibraryCalls( hinst );
|
2013-10-21 11:31:10 +02:00
|
|
|
macdrv_module = hinst;
|
|
|
|
ret = process_attach();
|
2006-10-24 15:26:33 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2013-01-28 20:32:21 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SystemParametersInfo (MACDRV.@)
|
|
|
|
*/
|
|
|
|
BOOL CDECL macdrv_SystemParametersInfo( UINT action, UINT int_param, void *ptr_param, UINT flags )
|
|
|
|
{
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case SPI_GETSCREENSAVEACTIVE:
|
|
|
|
if (ptr_param)
|
|
|
|
{
|
|
|
|
CFDictionaryRef assertionStates;
|
|
|
|
IOReturn status = IOPMCopyAssertionsStatus(&assertionStates);
|
|
|
|
if (status == kIOReturnSuccess)
|
|
|
|
{
|
|
|
|
CFNumberRef count = CFDictionaryGetValue(assertionStates, kIOPMAssertionTypeNoDisplaySleep);
|
|
|
|
CFNumberRef count2 = CFDictionaryGetValue(assertionStates, kIOPMAssertionTypePreventUserIdleDisplaySleep);
|
|
|
|
long longCount = 0, longCount2 = 0;
|
|
|
|
|
|
|
|
if (count)
|
|
|
|
CFNumberGetValue(count, kCFNumberLongType, &longCount);
|
|
|
|
if (count2)
|
|
|
|
CFNumberGetValue(count2, kCFNumberLongType, &longCount2);
|
|
|
|
|
|
|
|
*(BOOL *)ptr_param = !longCount && !longCount2;
|
|
|
|
CFRelease(assertionStates);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WARN("Could not determine screen saver state, error code %d\n", status);
|
|
|
|
*(BOOL *)ptr_param = TRUE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SPI_SETSCREENSAVEACTIVE:
|
|
|
|
{
|
|
|
|
static IOPMAssertionID powerAssertion = kIOPMNullAssertionID;
|
|
|
|
if (int_param)
|
|
|
|
{
|
|
|
|
if (powerAssertion != kIOPMNullAssertionID)
|
|
|
|
{
|
|
|
|
IOPMAssertionRelease(powerAssertion);
|
|
|
|
powerAssertion = kIOPMNullAssertionID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (powerAssertion == kIOPMNullAssertionID)
|
|
|
|
{
|
|
|
|
CFStringRef assertName;
|
|
|
|
/*Are we running Lion or later?*/
|
|
|
|
if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber10_7)
|
|
|
|
assertName = kIOPMAssertionTypePreventUserIdleDisplaySleep;
|
|
|
|
else
|
|
|
|
assertName = kIOPMAssertionTypeNoDisplaySleep;
|
|
|
|
IOPMAssertionCreateWithName( assertName, kIOPMAssertionLevelOn,
|
|
|
|
CFSTR("Wine Process requesting no screen saver"),
|
|
|
|
&powerAssertion);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|