From e9461b4567935c75ab1d6d48358de9dd06df85f0 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 26 Sep 2016 20:16:06 +0900 Subject: [PATCH] winex11: Add a helper function to register builtin clipboard formats. Signed-off-by: Alexandre Julliard --- dlls/winex11.drv/clipboard.c | 47 +++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c index cc4f92f819b..602a69a0bf0 100644 --- a/dlls/winex11.drv/clipboard.c +++ b/dlls/winex11.drv/clipboard.c @@ -341,6 +341,31 @@ static struct clipboard_format *find_x11_format( Atom atom ) } +/************************************************************************** + * register_builtin_formats + */ +static void register_builtin_formats(void) +{ + struct clipboard_format *formats; + unsigned int i; + + if (!(formats = HeapAlloc( GetProcessHeap(), 0, NB_BUILTIN_FORMATS * sizeof(*formats)))) return; + + for (i = 0; i < NB_BUILTIN_FORMATS; i++) + { + if (builtin_formats[i].name) + formats[i].id = RegisterClipboardFormatW( builtin_formats[i].name ); + else + formats[i].id = builtin_formats[i].id; + + formats[i].atom = GET_ATOM(builtin_formats[i].data); + formats[i].import = builtin_formats[i].import; + formats[i].export = builtin_formats[i].export; + list_add_tail( &format_list, &formats[i].entry ); + } +} + + /************************************************************************** * register_formats */ @@ -376,6 +401,8 @@ static void register_win32_formats( const UINT *ids, UINT size ) Atom atoms[256]; WCHAR buffer[256]; + if (list_empty( &format_list)) register_builtin_formats(); + while (size) { for (count = 0; count < 256 && size; ids++, size--) @@ -410,6 +437,8 @@ static void register_x11_formats( const Atom *atoms, UINT size ) Atom new_atoms[256]; WCHAR buffer[256]; + if (list_empty( &format_list)) register_builtin_formats(); + while (size) { for (count = 0; count < 256 && size; atoms++, size--) @@ -442,23 +471,7 @@ static void register_x11_formats( const Atom *atoms, UINT size ) */ void X11DRV_InitClipboard(void) { - struct clipboard_format *formats; - UINT i; - - if (!(formats = HeapAlloc( GetProcessHeap(), 0, NB_BUILTIN_FORMATS * sizeof(*formats)))) return; - - for (i = 0; i < NB_BUILTIN_FORMATS; i++) - { - if (builtin_formats[i].name) - formats[i].id = RegisterClipboardFormatW( builtin_formats[i].name ); - else - formats[i].id = builtin_formats[i].id; - - formats[i].atom = GET_ATOM(builtin_formats[i].data); - formats[i].import = builtin_formats[i].import; - formats[i].export = builtin_formats[i].export; - list_add_tail( &format_list, &formats[i].entry ); - } + register_builtin_formats(); }