Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
3db619d4
Commit
3db619d4
authored
Jun 11, 2020
by
Zhiyi Zhang
Committed by
Alexandre Julliard
Jun 11, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winex11.drv: Support multiple adapter display settings in registry.
Signed-off-by:
Zhiyi Zhang
<
zzhang@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
b5d58ff6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
37 deletions
+70
-37
display.c
dlls/winex11.drv/display.c
+2
-2
settings.c
dlls/winex11.drv/settings.c
+66
-35
x11drv.h
dlls/winex11.drv/x11drv.h
+2
-0
No files found.
dlls/winex11.drv/display.c
View file @
3db619d4
...
...
@@ -124,7 +124,7 @@ static CRITICAL_SECTION_DEBUG screen_critsect_debug =
};
static
CRITICAL_SECTION
screen_section
=
{
&
screen_critsect_debug
,
-
1
,
0
,
0
,
0
,
0
};
static
HANDLE
get_display_device_init_mutex
(
void
)
HANDLE
get_display_device_init_mutex
(
void
)
{
static
const
WCHAR
init_mutexW
[]
=
{
'd'
,
'i'
,
's'
,
'p'
,
'l'
,
'a'
,
'y'
,
'_'
,
'd'
,
'e'
,
'v'
,
'i'
,
'c'
,
'e'
,
'_'
,
'i'
,
'n'
,
'i'
,
't'
,
0
};
HANDLE
mutex
=
CreateMutexW
(
NULL
,
FALSE
,
init_mutexW
);
...
...
@@ -133,7 +133,7 @@ static HANDLE get_display_device_init_mutex(void)
return
mutex
;
}
static
void
release_display_device_init_mutex
(
HANDLE
mutex
)
void
release_display_device_init_mutex
(
HANDLE
mutex
)
{
ReleaseMutex
(
mutex
);
CloseHandle
(
mutex
);
...
...
dlls/winex11.drv/settings.c
View file @
3db619d4
...
...
@@ -19,9 +19,6 @@
*/
#include "config.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
...
...
@@ -32,6 +29,7 @@
#include "winreg.h"
#include "wingdi.h"
#include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
x11settings
);
...
...
@@ -154,43 +152,63 @@ void X11DRV_Settings_Init(void)
X11DRV_Settings_AddOneMode
(
primary
.
right
-
primary
.
left
,
primary
.
bottom
-
primary
.
top
,
0
,
60
);
}
static
BOOL
get_display_device_reg_key
(
c
har
*
key
,
unsigned
len
)
static
BOOL
get_display_device_reg_key
(
c
onst
WCHAR
*
device_name
,
WCHAR
*
key
,
unsigned
len
)
{
static
const
char
display_device_guid_prop
[]
=
"__wine_display_device_guid"
;
static
const
char
video_path
[]
=
"System
\\
CurrentControlSet
\\
Control
\\
Video
\\
{"
;
static
const
char
display0
[]
=
"}
\\
0000"
;
ATOM
guid_atom
;
assert
(
len
>=
sizeof
(
video_path
)
+
sizeof
(
display0
)
+
40
);
guid_atom
=
HandleToULong
(
GetPropA
(
GetDesktopWindow
(),
display_device_guid_prop
));
if
(
!
guid_atom
)
return
FALSE
;
static
const
WCHAR
display
[]
=
{
'\\'
,
'\\'
,
'.'
,
'\\'
,
'D'
,
'I'
,
'S'
,
'P'
,
'L'
,
'A'
,
'Y'
};
static
const
WCHAR
video_value_fmt
[]
=
{
'\\'
,
'D'
,
'e'
,
'v'
,
'i'
,
'c'
,
'e'
,
'\\'
,
'V'
,
'i'
,
'd'
,
'e'
,
'o'
,
'%'
,
'd'
,
0
};
static
const
WCHAR
video_key
[]
=
{
'H'
,
'A'
,
'R'
,
'D'
,
'W'
,
'A'
,
'R'
,
'E'
,
'\\'
,
'D'
,
'E'
,
'V'
,
'I'
,
'C'
,
'E'
,
'M'
,
'A'
,
'P'
,
'\\'
,
'V'
,
'I'
,
'D'
,
'E'
,
'O'
,
'\\'
,
0
};
WCHAR
value_name
[
MAX_PATH
],
buffer
[
MAX_PATH
],
*
end_ptr
;
DWORD
adapter_index
,
size
;
/* Device name has to be \\.\DISPLAY%d */
if
(
strncmpiW
(
device_name
,
display
,
ARRAY_SIZE
(
display
)))
return
FALSE
;
memcpy
(
key
,
video_path
,
sizeof
(
video_path
));
/* Parse \\.\DISPLAY* */
adapter_index
=
strtolW
(
device_name
+
ARRAY_SIZE
(
display
),
&
end_ptr
,
10
)
-
1
;
if
(
*
end_ptr
)
return
FALSE
;
if
(
!
GlobalGetAtomNameA
(
guid_atom
,
key
+
strlen
(
key
),
40
))
/* Open \Device\Video* in HKLM\HARDWARE\DEVICEMAP\VIDEO\ */
sprintfW
(
value_name
,
video_value_fmt
,
adapter_index
);
size
=
sizeof
(
buffer
);
if
(
RegGetValueW
(
HKEY_LOCAL_MACHINE
,
video_key
,
value_name
,
RRF_RT_REG_SZ
,
NULL
,
buffer
,
&
size
))
return
FALSE
;
strcat
(
key
,
display0
);
if
(
len
<
lstrlenW
(
buffer
+
18
)
+
1
)
return
FALSE
;
TRACE
(
"display device key %s
\n
"
,
wine_dbgstr_a
(
key
));
/* Skip \Registry\Machine\ prefix */
lstrcpyW
(
key
,
buffer
+
18
);
TRACE
(
"display device %s registry settings key %s.
\n
"
,
wine_dbgstr_w
(
device_name
),
wine_dbgstr_w
(
key
));
return
TRUE
;
}
static
BOOL
read_registry_settings
(
DEVMODEW
*
dm
)
static
BOOL
read_registry_settings
(
const
WCHAR
*
device_name
,
DEVMODEW
*
dm
)
{
char
wine_x11_reg_key
[
128
];
WCHAR
wine_x11_reg_key
[
MAX_PATH
];
HANDLE
mutex
;
HKEY
hkey
;
DWORD
type
,
size
;
BOOL
ret
=
TRUE
;
dm
->
dmFields
=
0
;
if
(
!
get_display_device_reg_key
(
wine_x11_reg_key
,
sizeof
(
wine_x11_reg_key
)))
mutex
=
get_display_device_init_mutex
();
if
(
!
get_display_device_reg_key
(
device_name
,
wine_x11_reg_key
,
ARRAY_SIZE
(
wine_x11_reg_key
)))
{
release_display_device_init_mutex
(
mutex
);
return
FALSE
;
}
if
(
RegOpenKeyExA
(
HKEY_CURRENT_CONFIG
,
wine_x11_reg_key
,
0
,
KEY_READ
,
&
hkey
))
if
(
RegOpenKeyExW
(
HKEY_CURRENT_CONFIG
,
wine_x11_reg_key
,
0
,
KEY_READ
,
&
hkey
))
{
release_display_device_init_mutex
(
mutex
);
return
FALSE
;
}
#define query_value(name, data) \
size = sizeof(DWORD); \
...
...
@@ -218,21 +236,30 @@ static BOOL read_registry_settings(DEVMODEW *dm)
#undef query_value
RegCloseKey
(
hkey
);
release_display_device_init_mutex
(
mutex
);
return
ret
;
}
static
BOOL
write_registry_settings
(
const
DEVMODEW
*
dm
)
static
BOOL
write_registry_settings
(
const
WCHAR
*
device_name
,
const
DEVMODEW
*
dm
)
{
char
wine_x11_reg_key
[
128
];
WCHAR
wine_x11_reg_key
[
MAX_PATH
];
HANDLE
mutex
;
HKEY
hkey
;
BOOL
ret
=
TRUE
;
if
(
!
get_display_device_reg_key
(
wine_x11_reg_key
,
sizeof
(
wine_x11_reg_key
)))
mutex
=
get_display_device_init_mutex
();
if
(
!
get_display_device_reg_key
(
device_name
,
wine_x11_reg_key
,
ARRAY_SIZE
(
wine_x11_reg_key
)))
{
release_display_device_init_mutex
(
mutex
);
return
FALSE
;
}
if
(
RegCreateKeyEx
A
(
HKEY_CURRENT_CONFIG
,
wine_x11_reg_key
,
0
,
NULL
,
if
(
RegCreateKeyEx
W
(
HKEY_CURRENT_CONFIG
,
wine_x11_reg_key
,
0
,
NULL
,
REG_OPTION_VOLATILE
,
KEY_WRITE
,
NULL
,
&
hkey
,
NULL
))
{
release_display_device_init_mutex
(
mutex
);
return
FALSE
;
}
#define set_value(name, data) \
if (RegSetValueExA(hkey, name, 0, REG_DWORD, (const BYTE*)(data), sizeof(DWORD))) \
...
...
@@ -251,6 +278,7 @@ static BOOL write_registry_settings(const DEVMODEW *dm)
#undef set_value
RegCloseKey
(
hkey
);
release_display_device_init_mutex
(
mutex
);
return
ret
;
}
...
...
@@ -301,7 +329,7 @@ BOOL CDECL X11DRV_EnumDisplaySettingsEx( LPCWSTR name, DWORD n, LPDEVMODEW devmo
if
(
n
==
ENUM_REGISTRY_SETTINGS
)
{
TRACE
(
"mode %d (registry) -- getting default mode (%s)
\n
"
,
n
,
handler_name
);
return
read_registry_settings
(
devmode
);
return
read_registry_settings
(
name
,
devmode
);
}
if
(
n
<
dd_mode_count
)
{
...
...
@@ -368,13 +396,6 @@ LONG CDECL X11DRV_ChangeDisplaySettingsEx( LPCWSTR devname, LPDEVMODEW devmode,
devmode
=
&
default_mode
;
}
if
(
lstrcmpiW
(
primary_adapter
,
devname
))
{
FIXME
(
"Changing non-primary adapter %s settings is currently unsupported.
\n
"
,
wine_dbgstr_w
(
devname
));
return
DISP_CHANGE_SUCCESSFUL
;
}
if
(
is_detached_mode
(
devmode
))
{
FIXME
(
"Detaching adapters is currently unsupported.
\n
"
);
...
...
@@ -407,8 +428,18 @@ LONG CDECL X11DRV_ChangeDisplaySettingsEx( LPCWSTR devname, LPDEVMODEW devmode,
/* we have a valid mode */
TRACE
(
"Requested display settings match mode %d (%s)
\n
"
,
i
,
handler_name
);
if
(
flags
&
CDS_UPDATEREGISTRY
)
write_registry_settings
(
devmode
);
if
(
flags
&
CDS_UPDATEREGISTRY
&&
!
write_registry_settings
(
devname
,
devmode
))
{
ERR
(
"Failed to write %s display settings to registry.
\n
"
,
wine_dbgstr_w
(
devname
));
return
DISP_CHANGE_NOTUPDATED
;
}
if
(
lstrcmpiW
(
primary_adapter
,
devname
))
{
FIXME
(
"Changing non-primary adapter %s settings is currently unsupported.
\n
"
,
wine_dbgstr_w
(
devname
));
return
DISP_CHANGE_SUCCESSFUL
;
}
if
(
!
(
flags
&
(
CDS_TEST
|
CDS_NORESET
)))
return
pSetCurrentMode
(
i
);
...
...
dlls/winex11.drv/x11drv.h
View file @
3db619d4
...
...
@@ -754,6 +754,8 @@ struct x11drv_display_device_handler
void
(
*
register_event_handlers
)(
void
);
};
extern
HANDLE
get_display_device_init_mutex
(
void
)
DECLSPEC_HIDDEN
;
extern
void
release_display_device_init_mutex
(
HANDLE
)
DECLSPEC_HIDDEN
;
extern
void
X11DRV_DisplayDevices_SetHandler
(
const
struct
x11drv_display_device_handler
*
handler
)
DECLSPEC_HIDDEN
;
extern
void
X11DRV_DisplayDevices_Init
(
BOOL
force
)
DECLSPEC_HIDDEN
;
extern
void
X11DRV_DisplayDevices_RegisterEventHandlers
(
void
)
DECLSPEC_HIDDEN
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment