4 * Copyright 1998 Ulrich Weigand
5 * Copyright 2007 Henri Verbeet
6 * Copyright 2011, 2012, 2013 Ken Thomases for CodeWeavers Inc.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/server.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(cursor
);
32 /***********************************************************************
35 * Update the various window states on a mouse event.
37 static void send_mouse_input(HWND hwnd
, UINT flags
, int x
, int y
,
38 DWORD mouse_data
, unsigned long time
)
43 top_level_hwnd
= GetAncestor(hwnd
, GA_ROOT
);
45 if ((flags
& MOUSEEVENTF_MOVE
) && (flags
& MOUSEEVENTF_ABSOLUTE
))
49 /* update the wine server Z-order */
50 SetRect(&rect
, x
, y
, x
+ 1, y
+ 1);
51 MapWindowPoints(0, top_level_hwnd
, (POINT
*)&rect
, 2);
53 SERVER_START_REQ(update_window_zorder
)
55 req
->window
= wine_server_user_handle(top_level_hwnd
);
56 req
->rect
.left
= rect
.left
;
57 req
->rect
.top
= rect
.top
;
58 req
->rect
.right
= rect
.right
;
59 req
->rect
.bottom
= rect
.bottom
;
60 wine_server_call(req
);
65 input
.type
= INPUT_MOUSE
;
68 input
.mi
.mouseData
= mouse_data
;
69 input
.mi
.dwFlags
= flags
;
71 input
.mi
.dwExtraInfo
= 0;
73 __wine_send_input(top_level_hwnd
, &input
);
77 /***********************************************************************
80 * Handler for MOUSE_BUTTON events.
82 void macdrv_mouse_button(HWND hwnd
, const macdrv_event
*event
)
87 TRACE("win %p button %d %s at (%d,%d) time %lu (%lu ticks ago)\n", hwnd
, event
->mouse_button
.button
,
88 (event
->mouse_button
.pressed
? "pressed" : "released"),
89 event
->mouse_button
.x
, event
->mouse_button
.y
,
90 event
->mouse_button
.time_ms
, (GetTickCount() - event
->mouse_button
.time_ms
));
92 if (event
->mouse_button
.pressed
)
94 switch (event
->mouse_button
.button
)
96 case 0: flags
|= MOUSEEVENTF_LEFTDOWN
; break;
97 case 1: flags
|= MOUSEEVENTF_RIGHTDOWN
; break;
98 case 2: flags
|= MOUSEEVENTF_MIDDLEDOWN
; break;
100 flags
|= MOUSEEVENTF_XDOWN
;
101 data
= 1 << (event
->mouse_button
.button
- 3);
107 switch (event
->mouse_button
.button
)
109 case 0: flags
|= MOUSEEVENTF_LEFTUP
; break;
110 case 1: flags
|= MOUSEEVENTF_RIGHTUP
; break;
111 case 2: flags
|= MOUSEEVENTF_MIDDLEUP
; break;
113 flags
|= MOUSEEVENTF_XUP
;
114 data
= 1 << (event
->mouse_button
.button
- 3);
119 send_mouse_input(hwnd
, flags
| MOUSEEVENTF_ABSOLUTE
| MOUSEEVENTF_MOVE
,
120 event
->mouse_button
.x
, event
->mouse_button
.y
,
121 data
, event
->mouse_button
.time_ms
);