Allow passing a string to the window property server requests instead

of an atom to avoid redundant server round-trips.
This commit is contained in:
Alexandre Julliard 2005-05-11 19:01:10 +00:00
parent 4bef6770b6
commit 9e73cdde39
5 changed files with 64 additions and 73 deletions

View File

@ -28,6 +28,7 @@
#include "winbase.h"
#include "wingdi.h"
#include "wownt32.h"
#include "wine/unicode.h"
#include "wine/winuser16.h"
#include "wine/server.h"
@ -117,20 +118,11 @@ INT WINAPI EnumPropsW( HWND hwnd, PROPENUMPROCW func )
*/
HANDLE WINAPI GetPropA( HWND hwnd, LPCSTR str )
{
ATOM atom;
HANDLE ret = 0;
WCHAR buffer[ATOM_BUFFER_SIZE];
if (!HIWORD(str)) atom = LOWORD(str);
else if (!(atom = GlobalFindAtomA( str ))) return 0;
SERVER_START_REQ( get_window_property )
{
req->window = hwnd;
req->atom = atom;
if (!wine_server_call_err( req )) ret = reply->handle;
}
SERVER_END_REQ;
return ret;
if (!HIWORD(str)) return GetPropW( hwnd, (LPCWSTR)str );
if (!MultiByteToWideChar( CP_ACP, 0, str, -1, buffer, ATOM_BUFFER_SIZE )) return 0;
return GetPropW( hwnd, buffer );
}
@ -139,16 +131,13 @@ HANDLE WINAPI GetPropA( HWND hwnd, LPCSTR str )
*/
HANDLE WINAPI GetPropW( HWND hwnd, LPCWSTR str )
{
ATOM atom;
HANDLE ret = 0;
if (!HIWORD(str)) atom = LOWORD(str);
else if (!(atom = GlobalFindAtomW( str ))) return 0;
SERVER_START_REQ( get_window_property )
{
req->window = hwnd;
req->atom = atom;
if (!HIWORD(str)) req->atom = LOWORD(str);
else wine_server_add_data( req, str, strlenW(str) * sizeof(WCHAR) );
if (!wine_server_call_err( req )) ret = reply->handle;
}
SERVER_END_REQ;
@ -161,24 +150,11 @@ HANDLE WINAPI GetPropW( HWND hwnd, LPCWSTR str )
*/
BOOL WINAPI SetPropA( HWND hwnd, LPCSTR str, HANDLE handle )
{
ATOM atom;
BOOL ret;
WCHAR buffer[ATOM_BUFFER_SIZE];
if (!HIWORD(str)) atom = LOWORD(str);
else if (!(atom = GlobalAddAtomA( str ))) return FALSE;
SERVER_START_REQ( set_window_property )
{
req->window = hwnd;
req->atom = atom;
req->string = (HIWORD(str) != 0);
req->handle = handle;
ret = !wine_server_call_err( req );
}
SERVER_END_REQ;
if (HIWORD(str)) GlobalDeleteAtom( atom );
return ret;
if (!HIWORD(str)) return SetPropW( hwnd, (LPCWSTR)str, handle );
if (!MultiByteToWideChar( CP_ACP, 0, str, -1, buffer, ATOM_BUFFER_SIZE )) return FALSE;
return SetPropW( hwnd, buffer, handle );
}
@ -187,23 +163,17 @@ BOOL WINAPI SetPropA( HWND hwnd, LPCSTR str, HANDLE handle )
*/
BOOL WINAPI SetPropW( HWND hwnd, LPCWSTR str, HANDLE handle )
{
ATOM atom;
BOOL ret;
if (!HIWORD(str)) atom = LOWORD(str);
else if (!(atom = GlobalAddAtomW( str ))) return FALSE;
SERVER_START_REQ( set_window_property )
{
req->window = hwnd;
req->atom = atom;
req->string = (HIWORD(str) != 0);
req->handle = handle;
if (!HIWORD(str)) req->atom = LOWORD(str);
else wine_server_add_data( req, str, strlenW(str) * sizeof(WCHAR) );
ret = !wine_server_call_err( req );
}
SERVER_END_REQ;
if (HIWORD(str)) GlobalDeleteAtom( atom );
return ret;
}
@ -213,17 +183,11 @@ BOOL WINAPI SetPropW( HWND hwnd, LPCWSTR str, HANDLE handle )
*/
HANDLE WINAPI RemovePropA( HWND hwnd, LPCSTR str )
{
ATOM atom;
HANDLE ret = 0;
WCHAR buffer[ATOM_BUFFER_SIZE];
if (!HIWORD(str)) return RemovePropW( hwnd, MAKEINTATOMW(LOWORD(str)) );
if ((atom = GlobalAddAtomA( str )))
{
ret = RemovePropW( hwnd, MAKEINTATOMW(atom) );
GlobalDeleteAtom( atom );
}
return ret;
if (!HIWORD(str)) return RemovePropW( hwnd, (LPCWSTR)str );
if (!MultiByteToWideChar( CP_ACP, 0, str, -1, buffer, ATOM_BUFFER_SIZE )) return 0;
return RemovePropW( hwnd, buffer );
}
@ -232,21 +196,17 @@ HANDLE WINAPI RemovePropA( HWND hwnd, LPCSTR str )
*/
HANDLE WINAPI RemovePropW( HWND hwnd, LPCWSTR str )
{
ATOM atom;
HANDLE ret = 0;
if (!HIWORD(str)) atom = LOWORD(str);
else if (!(atom = GlobalAddAtomW( str ))) return 0;
SERVER_START_REQ( remove_window_property )
{
req->window = hwnd;
req->atom = atom;
if (!HIWORD(str)) req->atom = LOWORD(str);
else wine_server_add_data( req, str, strlenW(str) * sizeof(WCHAR) );
if (!wine_server_call_err( req )) ret = reply->handle;
}
SERVER_END_REQ;
if (HIWORD(str)) GlobalDeleteAtom( atom );
return ret;
}

View File

@ -2807,8 +2807,8 @@ struct set_window_property_request
struct request_header __header;
user_handle_t window;
atom_t atom;
int string;
obj_handle_t handle;
/* VARARG(name,unicode_str); */
};
struct set_window_property_reply
{
@ -2822,6 +2822,7 @@ struct remove_window_property_request
struct request_header __header;
user_handle_t window;
atom_t atom;
/* VARARG(name,unicode_str); */
};
struct remove_window_property_reply
{
@ -2836,6 +2837,7 @@ struct get_window_property_request
struct request_header __header;
user_handle_t window;
atom_t atom;
/* VARARG(name,unicode_str); */
};
struct get_window_property_reply
{
@ -3958,6 +3960,6 @@ union generic_reply
struct set_mailslot_info_reply set_mailslot_info_reply;
};
#define SERVER_PROTOCOL_VERSION 174
#define SERVER_PROTOCOL_VERSION 175
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */

View File

@ -1972,16 +1972,17 @@ enum message_type
/* Set a window property */
@REQ(set_window_property)
user_handle_t window; /* handle to the window */
atom_t atom; /* property atom (high-word set if it was a string) */
int string; /* was atom a string originally? */
atom_t atom; /* property atom (if no name specified) */
obj_handle_t handle; /* handle to store */
VARARG(name,unicode_str); /* property name */
@END
/* Remove a window property */
@REQ(remove_window_property)
user_handle_t window; /* handle to the window */
atom_t atom; /* property atom */
atom_t atom; /* property atom (if no name specified) */
VARARG(name,unicode_str); /* property name */
@REPLY
obj_handle_t handle; /* handle stored in property */
@END
@ -1990,7 +1991,8 @@ enum message_type
/* Get a window property */
@REQ(get_window_property)
user_handle_t window; /* handle to the window */
atom_t atom; /* property atom */
atom_t atom; /* property atom (if no name specified) */
VARARG(name,unicode_str); /* property name */
@REPLY
obj_handle_t handle; /* handle stored in property */
@END

View File

@ -2354,14 +2354,17 @@ static void dump_set_window_property_request( const struct set_window_property_r
{
fprintf( stderr, " window=%p,", req->window );
fprintf( stderr, " atom=%04x,", req->atom );
fprintf( stderr, " string=%d,", req->string );
fprintf( stderr, " handle=%p", req->handle );
fprintf( stderr, " handle=%p,", req->handle );
fprintf( stderr, " name=" );
dump_varargs_unicode_str( cur_size );
}
static void dump_remove_window_property_request( const struct remove_window_property_request *req )
{
fprintf( stderr, " window=%p,", req->window );
fprintf( stderr, " atom=%04x", req->atom );
fprintf( stderr, " atom=%04x,", req->atom );
fprintf( stderr, " name=" );
dump_varargs_unicode_str( cur_size );
}
static void dump_remove_window_property_reply( const struct remove_window_property_reply *req )
@ -2372,7 +2375,9 @@ static void dump_remove_window_property_reply( const struct remove_window_proper
static void dump_get_window_property_request( const struct get_window_property_request *req )
{
fprintf( stderr, " window=%p,", req->window );
fprintf( stderr, " atom=%04x", req->atom );
fprintf( stderr, " atom=%04x,", req->atom );
fprintf( stderr, " name=" );
dump_varargs_unicode_str( cur_size );
}
static void dump_get_window_property_reply( const struct get_window_property_reply *req )

View File

@ -1764,8 +1764,18 @@ DECL_HANDLER(set_window_property)
{
struct window *win = get_window( req->window );
if (win) set_property( win, req->atom, req->handle,
req->string ? PROP_TYPE_STRING : PROP_TYPE_ATOM );
if (!win) return;
if (get_req_data_size())
{
atom_t atom = add_global_atom( get_req_data(), get_req_data_size() / sizeof(WCHAR) );
if (atom)
{
set_property( win, atom, req->handle, PROP_TYPE_STRING );
release_global_atom( atom );
}
}
else set_property( win, req->atom, req->handle, PROP_TYPE_ATOM );
}
@ -1774,7 +1784,13 @@ DECL_HANDLER(remove_window_property)
{
struct window *win = get_window( req->window );
reply->handle = 0;
if (win) reply->handle = remove_property( win, req->atom );
if (win)
{
atom_t atom = req->atom;
if (get_req_data_size()) atom = find_global_atom( get_req_data(),
get_req_data_size() / sizeof(WCHAR) );
if (atom) reply->handle = remove_property( win, atom );
}
}
@ -1783,7 +1799,13 @@ DECL_HANDLER(get_window_property)
{
struct window *win = get_window( req->window );
reply->handle = 0;
if (win) reply->handle = get_property( win, req->atom );
if (win)
{
atom_t atom = req->atom;
if (get_req_data_size()) atom = find_global_atom( get_req_data(),
get_req_data_size() / sizeof(WCHAR) );
if (atom) reply->handle = get_property( win, atom );
}
}