mirror of
https://github.com/gnustep/libs-back.git
synced 2025-02-23 20:01:22 +00:00
back/win32: horizontal mousewheel support
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@29933 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1e8806424e
commit
36260d2295
3 changed files with 44 additions and 23 deletions
|
@ -1,5 +1,11 @@
|
||||||
2010-03-13 Eric Wasylishen <ewasylishen@gmail.com>
|
2010-03-13 Eric Wasylishen <ewasylishen@gmail.com>
|
||||||
|
|
||||||
|
* Headers/win32/WIN32Server.h:
|
||||||
|
* Source/win32/WIN32Server.m: Add support for horizontal
|
||||||
|
mousewheel scrolling
|
||||||
|
|
||||||
|
010-03-13 Eric Wasylishen <ewasylishen@gmail.com>
|
||||||
|
|
||||||
* Source/win32/WIN32Server.m: Fix handling of mousewheel events.
|
* Source/win32/WIN32Server.m: Fix handling of mousewheel events.
|
||||||
The WM_MOUSEWHEEL message uses screen coordinates, so convert
|
The WM_MOUSEWHEEL message uses screen coordinates, so convert
|
||||||
them to client coordinates.
|
them to client coordinates.
|
||||||
|
|
|
@ -67,6 +67,11 @@
|
||||||
#define GET_Y_LPARAM(p) ((int)(short)HIWORD(p))
|
#define GET_Y_LPARAM(p) ((int)(short)HIWORD(p))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// The horizontal mousehweel message is missing in MinGW
|
||||||
|
#ifndef WM_MOUSEHWHEEL
|
||||||
|
#define WM_MOUSEHWHEEL 0x020E
|
||||||
|
#endif
|
||||||
|
|
||||||
#define EVENT_WINDOW(lp) (GSWindowWithNumber((int)lp))
|
#define EVENT_WINDOW(lp) (GSWindowWithNumber((int)lp))
|
||||||
|
|
||||||
DWORD windowStyleForGSStyle(unsigned int style);
|
DWORD windowStyleForGSStyle(unsigned int style);
|
||||||
|
|
|
@ -67,7 +67,8 @@ static NSEvent *process_key_event(WIN32Server *svr,
|
||||||
LPARAM lParam, NSEventType eventType);
|
LPARAM lParam, NSEventType eventType);
|
||||||
static NSEvent *process_mouse_event(WIN32Server *svr,
|
static NSEvent *process_mouse_event(WIN32Server *svr,
|
||||||
HWND hwnd, WPARAM wParam,
|
HWND hwnd, WPARAM wParam,
|
||||||
LPARAM lParam, NSEventType eventType);
|
LPARAM lParam, NSEventType eventType,
|
||||||
|
UINT uMsg);
|
||||||
|
|
||||||
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg,
|
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg,
|
||||||
WPARAM wParam, LPARAM lParam);
|
WPARAM wParam, LPARAM lParam);
|
||||||
|
@ -704,45 +705,50 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg,
|
||||||
break;
|
break;
|
||||||
case WM_MOUSEMOVE: //MOUSE
|
case WM_MOUSEMOVE: //MOUSE
|
||||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MOUSEMOVE", hwnd);
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MOUSEMOVE", hwnd);
|
||||||
ev = process_mouse_event(self, hwnd, wParam, lParam, NSMouseMoved);
|
ev = process_mouse_event(self, hwnd, wParam, lParam, NSMouseMoved, uMsg);
|
||||||
break;
|
break;
|
||||||
case WM_LBUTTONDOWN: //MOUSE
|
case WM_LBUTTONDOWN: //MOUSE
|
||||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "LBUTTONDOWN", hwnd);
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "LBUTTONDOWN", hwnd);
|
||||||
//[self decodeWM_LBUTTONDOWNParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd];
|
//[self decodeWM_LBUTTONDOWNParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd];
|
||||||
ev = process_mouse_event(self, hwnd, wParam, lParam, NSLeftMouseDown);
|
ev = process_mouse_event(self, hwnd, wParam, lParam, NSLeftMouseDown, uMsg);
|
||||||
break;
|
break;
|
||||||
case WM_LBUTTONUP: //MOUSE
|
case WM_LBUTTONUP: //MOUSE
|
||||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "LBUTTONUP", hwnd);
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "LBUTTONUP", hwnd);
|
||||||
ev = process_mouse_event(self, hwnd, wParam, lParam, NSLeftMouseUp);
|
ev = process_mouse_event(self, hwnd, wParam, lParam, NSLeftMouseUp, uMsg);
|
||||||
break;
|
break;
|
||||||
case WM_LBUTTONDBLCLK: //MOUSE
|
case WM_LBUTTONDBLCLK: //MOUSE
|
||||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "LBUTTONDBLCLK", hwnd);
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "LBUTTONDBLCLK", hwnd);
|
||||||
break;
|
break;
|
||||||
case WM_MBUTTONDOWN: //MOUSE
|
case WM_MBUTTONDOWN: //MOUSE
|
||||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MBUTTONDOWN", hwnd);
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MBUTTONDOWN", hwnd);
|
||||||
ev = process_mouse_event(self, hwnd, wParam, lParam, NSOtherMouseDown);
|
ev = process_mouse_event(self, hwnd, wParam, lParam, NSOtherMouseDown, uMsg);
|
||||||
break;
|
break;
|
||||||
case WM_MBUTTONUP: //MOUSE
|
case WM_MBUTTONUP: //MOUSE
|
||||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MBUTTONUP", hwnd);
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MBUTTONUP", hwnd);
|
||||||
ev = process_mouse_event(self, hwnd, wParam, lParam, NSOtherMouseUp);
|
ev = process_mouse_event(self, hwnd, wParam, lParam, NSOtherMouseUp, uMsg);
|
||||||
break;
|
break;
|
||||||
case WM_MBUTTONDBLCLK: //MOUSE
|
case WM_MBUTTONDBLCLK: //MOUSE
|
||||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MBUTTONDBLCLK", hwnd);
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MBUTTONDBLCLK", hwnd);
|
||||||
break;
|
break;
|
||||||
case WM_RBUTTONDOWN: //MOUSE
|
case WM_RBUTTONDOWN: //MOUSE
|
||||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "RBUTTONDOWN", hwnd);
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "RBUTTONDOWN", hwnd);
|
||||||
ev = process_mouse_event(self, hwnd, wParam, lParam, NSRightMouseDown);
|
ev = process_mouse_event(self, hwnd, wParam, lParam, NSRightMouseDown, uMsg);
|
||||||
break;
|
break;
|
||||||
case WM_RBUTTONUP: //MOUSE
|
case WM_RBUTTONUP: //MOUSE
|
||||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "RBUTTONUP", hwnd);
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "RBUTTONUP", hwnd);
|
||||||
ev = process_mouse_event(self, hwnd, wParam, lParam, NSRightMouseUp);
|
ev = process_mouse_event(self, hwnd, wParam, lParam, NSRightMouseUp, uMsg);
|
||||||
break;
|
break;
|
||||||
case WM_RBUTTONDBLCLK: //MOUSE
|
case WM_RBUTTONDBLCLK: //MOUSE
|
||||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "RBUTTONDBLCLK", hwnd);
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "RBUTTONDBLCLK", hwnd);
|
||||||
break;
|
break;
|
||||||
|
case WM_MOUSEHWHEEL: //MOUSE
|
||||||
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MOUSEHWHEEL", hwnd);
|
||||||
|
ev = process_mouse_event(self, hwnd, wParam, lParam, NSScrollWheel, uMsg);
|
||||||
|
break;
|
||||||
|
|
||||||
case WM_MOUSEWHEEL: //MOUSE
|
case WM_MOUSEWHEEL: //MOUSE
|
||||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MOUSEWHEEL", hwnd);
|
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MOUSEWHEEL", hwnd);
|
||||||
ev = process_mouse_event(self, hwnd, wParam, lParam, NSScrollWheel);
|
ev = process_mouse_event(self, hwnd, wParam, lParam, NSScrollWheel, uMsg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_KEYDOWN: //KEYBOARD
|
case WM_KEYDOWN: //KEYBOARD
|
||||||
|
@ -1827,7 +1833,7 @@ process_key_event(WIN32Server *svr, HWND hwnd, WPARAM wParam, LPARAM lParam,
|
||||||
|
|
||||||
static NSEvent*
|
static NSEvent*
|
||||||
process_mouse_event(WIN32Server *svr, HWND hwnd, WPARAM wParam, LPARAM lParam,
|
process_mouse_event(WIN32Server *svr, HWND hwnd, WPARAM wParam, LPARAM lParam,
|
||||||
NSEventType eventType)
|
NSEventType eventType, UINT uMsg)
|
||||||
{
|
{
|
||||||
NSEvent *event;
|
NSEvent *event;
|
||||||
NSPoint eventLocation;
|
NSPoint eventLocation;
|
||||||
|
@ -1836,7 +1842,7 @@ process_mouse_event(WIN32Server *svr, HWND hwnd, WPARAM wParam, LPARAM lParam,
|
||||||
LONG ltime;
|
LONG ltime;
|
||||||
DWORD tick;
|
DWORD tick;
|
||||||
NSGraphicsContext *gcontext;
|
NSGraphicsContext *gcontext;
|
||||||
short deltaY = 0;
|
float deltaX = 0.0, deltaY = 0.0;
|
||||||
static int clickCount = 1;
|
static int clickCount = 1;
|
||||||
static LONG lastTime = 0;
|
static LONG lastTime = 0;
|
||||||
int clientX, clientY;
|
int clientX, clientY;
|
||||||
|
@ -1895,8 +1901,12 @@ process_mouse_event(WIN32Server *svr, HWND hwnd, WPARAM wParam, LPARAM lParam,
|
||||||
|
|
||||||
if (eventType == NSScrollWheel)
|
if (eventType == NSScrollWheel)
|
||||||
{
|
{
|
||||||
deltaY = GET_WHEEL_DELTA_WPARAM(wParam) / 120;
|
float delta = GET_WHEEL_DELTA_WPARAM(wParam) / 120.0;
|
||||||
//NSLog(@"Scroll event with delat %d", deltaY);
|
if (uMsg == WM_MOUSEWHEEL)
|
||||||
|
deltaY = delta;
|
||||||
|
else
|
||||||
|
deltaX = delta;
|
||||||
|
//NSLog(@"Scroll event with deltaX %f deltaY %f", deltaX, deltaY);
|
||||||
}
|
}
|
||||||
else if (eventType == NSMouseMoved)
|
else if (eventType == NSMouseMoved)
|
||||||
{
|
{
|
||||||
|
@ -1907,7 +1917,7 @@ process_mouse_event(WIN32Server *svr, HWND hwnd, WPARAM wParam, LPARAM lParam,
|
||||||
if (lDown == NO)
|
if (lDown == NO)
|
||||||
{
|
{
|
||||||
e = process_mouse_event(svr, hwnd, wParam, lParam,
|
e = process_mouse_event(svr, hwnd, wParam, lParam,
|
||||||
NSLeftMouseDown);
|
NSLeftMouseDown, uMsg);
|
||||||
[GSCurrentServer() postEvent: e atStart: NO];
|
[GSCurrentServer() postEvent: e atStart: NO];
|
||||||
}
|
}
|
||||||
eventType = NSLeftMouseDragged;
|
eventType = NSLeftMouseDragged;
|
||||||
|
@ -1917,13 +1927,13 @@ process_mouse_event(WIN32Server *svr, HWND hwnd, WPARAM wParam, LPARAM lParam,
|
||||||
if (lDown == YES)
|
if (lDown == YES)
|
||||||
{
|
{
|
||||||
e = process_mouse_event(svr, hwnd, wParam, lParam,
|
e = process_mouse_event(svr, hwnd, wParam, lParam,
|
||||||
NSLeftMouseUp);
|
NSLeftMouseUp, uMsg);
|
||||||
[GSCurrentServer() postEvent: e atStart: NO];
|
[GSCurrentServer() postEvent: e atStart: NO];
|
||||||
}
|
}
|
||||||
if (rDown == NO)
|
if (rDown == NO)
|
||||||
{
|
{
|
||||||
e = process_mouse_event(svr, hwnd, wParam, lParam,
|
e = process_mouse_event(svr, hwnd, wParam, lParam,
|
||||||
NSRightMouseDown);
|
NSRightMouseDown, uMsg);
|
||||||
[GSCurrentServer() postEvent: e atStart: NO];
|
[GSCurrentServer() postEvent: e atStart: NO];
|
||||||
}
|
}
|
||||||
eventType = NSRightMouseDragged;
|
eventType = NSRightMouseDragged;
|
||||||
|
@ -1933,19 +1943,19 @@ process_mouse_event(WIN32Server *svr, HWND hwnd, WPARAM wParam, LPARAM lParam,
|
||||||
if (lDown == YES)
|
if (lDown == YES)
|
||||||
{
|
{
|
||||||
e = process_mouse_event(svr, hwnd, wParam, lParam,
|
e = process_mouse_event(svr, hwnd, wParam, lParam,
|
||||||
NSLeftMouseUp);
|
NSLeftMouseUp, uMsg);
|
||||||
[GSCurrentServer() postEvent: e atStart: NO];
|
[GSCurrentServer() postEvent: e atStart: NO];
|
||||||
}
|
}
|
||||||
if (rDown == YES)
|
if (rDown == YES)
|
||||||
{
|
{
|
||||||
e = process_mouse_event(svr, hwnd, wParam, lParam,
|
e = process_mouse_event(svr, hwnd, wParam, lParam,
|
||||||
NSRightMouseUp);
|
NSRightMouseUp, uMsg);
|
||||||
[GSCurrentServer() postEvent: e atStart: NO];
|
[GSCurrentServer() postEvent: e atStart: NO];
|
||||||
}
|
}
|
||||||
if (oDown == NO)
|
if (oDown == NO)
|
||||||
{
|
{
|
||||||
e = process_mouse_event(svr, hwnd, wParam, lParam,
|
e = process_mouse_event(svr, hwnd, wParam, lParam,
|
||||||
NSOtherMouseDown);
|
NSOtherMouseDown, uMsg);
|
||||||
[GSCurrentServer() postEvent: e atStart: NO];
|
[GSCurrentServer() postEvent: e atStart: NO];
|
||||||
}
|
}
|
||||||
eventType = NSOtherMouseDragged;
|
eventType = NSOtherMouseDragged;
|
||||||
|
@ -1955,19 +1965,19 @@ process_mouse_event(WIN32Server *svr, HWND hwnd, WPARAM wParam, LPARAM lParam,
|
||||||
if (lDown == YES)
|
if (lDown == YES)
|
||||||
{
|
{
|
||||||
e = process_mouse_event(svr, hwnd, wParam, lParam,
|
e = process_mouse_event(svr, hwnd, wParam, lParam,
|
||||||
NSLeftMouseUp);
|
NSLeftMouseUp, uMsg);
|
||||||
[GSCurrentServer() postEvent: e atStart: NO];
|
[GSCurrentServer() postEvent: e atStart: NO];
|
||||||
}
|
}
|
||||||
if (rDown == YES)
|
if (rDown == YES)
|
||||||
{
|
{
|
||||||
e = process_mouse_event(svr, hwnd, wParam, lParam,
|
e = process_mouse_event(svr, hwnd, wParam, lParam,
|
||||||
NSRightMouseUp);
|
NSRightMouseUp, uMsg);
|
||||||
[GSCurrentServer() postEvent: e atStart: NO];
|
[GSCurrentServer() postEvent: e atStart: NO];
|
||||||
}
|
}
|
||||||
if (oDown == YES)
|
if (oDown == YES)
|
||||||
{
|
{
|
||||||
e = process_mouse_event(svr, hwnd, wParam, lParam,
|
e = process_mouse_event(svr, hwnd, wParam, lParam,
|
||||||
NSOtherMouseUp);
|
NSOtherMouseUp, uMsg);
|
||||||
[GSCurrentServer() postEvent: e atStart: NO];
|
[GSCurrentServer() postEvent: e atStart: NO];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2022,7 +2032,7 @@ process_mouse_event(WIN32Server *svr, HWND hwnd, WPARAM wParam, LPARAM lParam,
|
||||||
clickCount: clickCount
|
clickCount: clickCount
|
||||||
pressure: 1.0
|
pressure: 1.0
|
||||||
buttonNumber: 0 /* FIXME */
|
buttonNumber: 0 /* FIXME */
|
||||||
deltaX: 0.
|
deltaX: deltaX
|
||||||
deltaY: deltaY
|
deltaY: deltaY
|
||||||
deltaZ: 0.];
|
deltaZ: 0.];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue