Commit 1d56578e authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

winemac: Move DllMain to separated file.

parent 834ade75
......@@ -9,6 +9,7 @@ EXTRADLLFLAGS = -mcygwin
C_SRCS = \
clipboard.c \
display.c \
dllmain.c \
dragdrop.c \
event.c \
gdi.c \
......
/*
* winemac.drv entry points
*
* Copyright 2022 Jacek Caban for CodeWeavers
*
* 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"
#include <stdarg.h>
#include "macdrv.h"
HMODULE macdrv_module = 0;
static BOOL process_attach(void)
{
struct init_params params;
struct localized_string *str;
struct localized_string strings[] = {
{ .id = STRING_MENU_WINE },
{ .id = STRING_MENU_ITEM_HIDE_APPNAME },
{ .id = STRING_MENU_ITEM_HIDE },
{ .id = STRING_MENU_ITEM_HIDE_OTHERS },
{ .id = STRING_MENU_ITEM_SHOW_ALL },
{ .id = STRING_MENU_ITEM_QUIT_APPNAME },
{ .id = STRING_MENU_ITEM_QUIT },
{ .id = STRING_MENU_WINDOW },
{ .id = STRING_MENU_ITEM_MINIMIZE },
{ .id = STRING_MENU_ITEM_ZOOM },
{ .id = STRING_MENU_ITEM_ENTER_FULL_SCREEN },
{ .id = STRING_MENU_ITEM_BRING_ALL_TO_FRONT },
{ .id = 0 }
};
for (str = strings; str->id; str++)
str->len = LoadStringW(macdrv_module, str->id, (WCHAR *)&str->str, 0);
params.strings = strings;
return !MACDRV_CALL(init, &params);
}
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
{
if (reason != DLL_PROCESS_ATTACH) return TRUE;
DisableThreadLibraryCalls(instance);
macdrv_module = instance;
return process_attach();
}
......@@ -33,6 +33,7 @@
#include "ntgdi.h"
#include "wine/debug.h"
#include "wine/gdi_driver.h"
#include "unixlib.h"
extern BOOL skip_single_buffer_flushes DECLSPEC_HIDDEN;
......@@ -280,6 +281,7 @@ extern void macdrv_status_item_mouse_move(const macdrv_event *event) DECLSPEC_HI
extern void check_retina_status(void) DECLSPEC_HIDDEN;
extern void macdrv_init_display_devices(BOOL force) DECLSPEC_HIDDEN;
extern void init_user_driver(void) DECLSPEC_HIDDEN;
extern NTSTATUS macdrv_init(void *arg) DECLSPEC_HIDDEN;
/**************************************************************************
* Mac IME driver
......
......@@ -63,7 +63,6 @@ int cursor_clipping_locks_windows = TRUE;
int use_precise_scrolling = TRUE;
int gl_surface_mode = GL_SURFACE_IN_FRONT_OPAQUE;
int retina_enabled = FALSE;
HMODULE macdrv_module = 0;
int enable_app_nap = FALSE;
CFDictionaryRef localized_strings;
......@@ -396,25 +395,9 @@ static void setup_options(void)
/***********************************************************************
* load_strings
*/
static void load_strings(HINSTANCE instance)
static void load_strings(struct localized_string *str)
{
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);
......@@ -424,21 +407,20 @@ static void load_strings(HINSTANCE instance)
return;
}
for (i = 0; i < ARRAY_SIZE(ids); i++)
while (str->id)
{
LPCWSTR str;
int len = LoadStringW(instance, ids[i], (LPWSTR)&str, 0);
if (str && len)
if (str->str && str->len)
{
CFNumberRef key = CFNumberCreate(NULL, kCFNumberIntType, &ids[i]);
CFStringRef value = CFStringCreateWithCharacters(NULL, (UniChar*)str, len);
CFNumberRef key = CFNumberCreate(NULL, kCFNumberIntType, &str->id);
CFStringRef value = CFStringCreateWithCharacters(NULL, (UniChar*)str->str, 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));
ERR("Failed to add string ID 0x%04x %s\n", str->id, debugstr_wn(str->str, str->len));
}
else
ERR("Failed to load string ID 0x%04x\n", ids[i]);
ERR("Failed to load string ID 0x%04x\n", str->id);
str++;
}
localized_strings = dict;
......@@ -446,32 +428,33 @@ static void load_strings(HINSTANCE instance)
/***********************************************************************
* process_attach
* macdrv_init
*/
static BOOL process_attach(void)
NTSTATUS macdrv_init(void *arg)
{
struct init_params *params = arg;
SessionAttributeBits attributes;
OSStatus status;
status = SessionGetInfo(callerSecuritySession, NULL, &attributes);
if (status != noErr || !(attributes & sessionHasGraphicAccess))
return FALSE;
return STATUS_UNSUCCESSFUL;
init_win_context();
setup_options();
load_strings(macdrv_module);
load_strings(params->strings);
macdrv_err_on = ERR_ON(macdrv);
if (macdrv_start_cocoa_app(GetTickCount64()))
if (macdrv_start_cocoa_app(NtGetTickCount()))
{
ERR("Failed to start Cocoa app main loop\n");
return FALSE;
return STATUS_UNSUCCESSFUL;
}
init_user_driver();
macdrv_init_display_devices(FALSE);
return TRUE;
return STATUS_SUCCESS;
}
......@@ -560,24 +543,6 @@ struct macdrv_thread_data *macdrv_init_thread_data(void)
/***********************************************************************
* DllMain
*/
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved)
{
BOOL ret = TRUE;
switch(reason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls( hinst );
macdrv_module = hinst;
ret = process_attach();
break;
}
return ret;
}
/***********************************************************************
* SystemParametersInfo (MACDRV.@)
*/
BOOL macdrv_SystemParametersInfo( UINT action, UINT int_param, void *ptr_param, UINT flags )
......@@ -640,3 +605,18 @@ BOOL macdrv_SystemParametersInfo( UINT action, UINT int_param, void *ptr_param,
}
return FALSE;
}
const unixlib_entry_t __wine_unix_call_funcs[] =
{
macdrv_init,
};
C_ASSERT( ARRAYSIZE(__wine_unix_call_funcs) == unix_funcs_count );
/* FIXME: Use __wine_unix_call instead */
NTSTATUS unix_call(enum macdrv_funcs code, void *params)
{
return __wine_unix_call_funcs[code]( params );
}
/*
* Copyright 2022 Jacek Caban for CodeWeavers
*
* 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 "ntuser.h"
#include "wine/unixlib.h"
enum macdrv_funcs
{
unix_init,
unix_funcs_count
};
/* FIXME: Use __wine_unix_call when the rest of the stack is ready */
extern NTSTATUS unix_call(enum macdrv_funcs code, void *params) DECLSPEC_HIDDEN;
#define MACDRV_CALL(func, params) unix_call( unix_ ## func, params )
/* macdrv_init params */
struct localized_string
{
UINT id;
UINT len;
const WCHAR *str;
};
struct init_params
{
struct localized_string *strings;
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment