Commit b3eb5522 authored by Anton Baskanov's avatar Anton Baskanov Committed by Alexandre Julliard

winex11.drv: Process RRNotify events in xrandr14_get_id.

We have to invalidate the current mode cache if there are pending RRNotify events. The performance hit on EnumDisplaySettingsExW is around 7%. Also call X11DRV_DisplayDevices_RegisterEventHandlers in x11drv_init. Otherwise, RRNotify events will only be handled in the explorer process.
parent 30c3d0a3
......@@ -1258,7 +1258,7 @@ static void test_ChangeDisplaySettingsEx(int argc, char **argv)
dm.dmPelsWidth = 640;
dm.dmPelsHeight = 480;
expect_dm(&dm, devices[0].name, 0, TRUE);
expect_dm(&dm, devices[0].name, 0, FALSE);
SetEvent(exit_event1);
wait_result = WaitForSingleObject(process1, 5000);
......@@ -1300,7 +1300,7 @@ static void test_ChangeDisplaySettingsEx(int argc, char **argv)
dm.dmPelsWidth = 640;
dm.dmPelsHeight = 480;
expect_dm(&dm, devices[0].name, 0, TRUE);
expect_dm(&dm, devices[0].name, 0, FALSE);
SetEvent(exit_event1);
wait_result = WaitForSingleObject(process1, 5000);
......@@ -1310,7 +1310,7 @@ static void test_ChangeDisplaySettingsEx(int argc, char **argv)
dm.dmPelsWidth = 640;
dm.dmPelsHeight = 480;
expect_dm(&dm, devices[0].name, 0, TRUE);
expect_dm(&dm, devices[0].name, 0, FALSE);
CloseHandle(process1);
CloseHandle(process0);
......@@ -1328,7 +1328,7 @@ static void test_ChangeDisplaySettingsEx(int argc, char **argv)
dm.dmPelsWidth = 640;
dm.dmPelsHeight = 480;
expect_dm(&dm, devices[0].name, 0, TRUE);
expect_dm(&dm, devices[0].name, 0, FALSE);
SetEvent(exit_event0);
wait_result = WaitForSingleObject(process0, 5000);
......@@ -1338,7 +1338,7 @@ static void test_ChangeDisplaySettingsEx(int argc, char **argv)
dm.dmPelsWidth = 640;
dm.dmPelsHeight = 480;
expect_dm(&dm, devices[0].name, 0, TRUE);
expect_dm(&dm, devices[0].name, 0, FALSE);
CloseHandle(process1);
CloseHandle(process0);
......
......@@ -405,7 +405,7 @@ static inline BOOL call_event_handler( Display *display, XEvent *event )
/***********************************************************************
* process_events
*/
static BOOL process_events( Display *display, Bool (*filter)(Display*, XEvent*,XPointer), ULONG_PTR arg )
BOOL process_events( Display *display, Bool (*filter)(Display*, XEvent*,XPointer), ULONG_PTR arg )
{
XEvent event, prev_event;
int count = 0;
......
......@@ -2093,7 +2093,6 @@ BOOL X11DRV_CreateWindow( HWND hwnd )
CWOverrideRedirect | CWEventMask, &attr );
XFlush( data->display );
NtUserSetProp( hwnd, clip_window_prop, (HANDLE)data->clip_window );
X11DRV_DisplayDevices_RegisterEventHandlers();
}
return TRUE;
}
......
......@@ -679,6 +679,7 @@ extern void retry_grab_clipping_window(void);
extern void ungrab_clipping_window(void);
extern void move_resize_window( HWND hwnd, int dir );
extern void X11DRV_InitKeyboard( Display *display );
extern BOOL process_events( Display *display, Bool (*filter)(Display*, XEvent*, XPointer), ULONG_PTR arg );
extern BOOL X11DRV_ProcessEvents( DWORD mask );
extern HWND *build_hwnd_list(void);
......
......@@ -683,6 +683,7 @@ static NTSTATUS x11drv_init( void *arg )
init_user_driver();
X11DRV_DisplayDevices_Init(FALSE);
X11DRV_DisplayDevices_RegisterEventHandlers();
return STATUS_SUCCESS;
}
......
......@@ -1220,6 +1220,32 @@ static void xrandr14_register_event_handlers(void)
"XRandR ProviderChange" );
}
static Bool filter_rrnotify_event( Display *display, XEvent *event, char *arg )
{
ULONG_PTR event_base = (ULONG_PTR)arg;
if (event->type == event_base + RRNotify_CrtcChange
|| event->type == event_base + RRNotify_OutputChange
|| event->type == event_base + RRNotify_ProviderChange)
return 1;
return 0;
}
static void process_rrnotify_events(void)
{
struct x11drv_thread_data *data = x11drv_thread_data();
int event_base, error_base;
if (!data) return;
if (data->current_event) return; /* don't process nested events */
if (!pXRRQueryExtension( data->display, &event_base, &error_base ))
return;
process_events( data->display, filter_rrnotify_event, event_base );
}
/* XRandR 1.4 display settings handler */
static BOOL xrandr14_get_id( const WCHAR *device_name, BOOL is_primary, x11drv_settings_id *id )
{
......@@ -1235,6 +1261,8 @@ static BOOL xrandr14_get_id( const WCHAR *device_name, BOOL is_primary, x11drv_s
if (*end)
return FALSE;
process_rrnotify_events();
/* Update cache */
pthread_mutex_lock( &xrandr_mutex );
if (!current_modes)
......
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