Author: gnorton
Date: 2007-12-07 10:12:07 -0500 (Fri, 07 Dec 2007)
New Revision: 90938
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/ControlHandler.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/EventHandler.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/KeyboardHandler.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/MouseHandler.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/WindowHandler.cs
Log:
2007-12-07 Geoff Norton <[EMAIL PROTECTED]>
* ControlHandler.cs: Properly update our invalidated information when
Quartz asks us to redraw. This helps fix TabControl but introduces
over-zealous drawing causing our flicker. Implement visibility tracking
to generate out WM_SHOWWINDOW calls. Refactor mouse tracking to live
entirely in MouseHandler.
* EventHandler.cs: Unregister some events we no longer handle. Register
the new MouseEvents that we do handle.
* KeyboardHandler.cs: Implement some more key translations.
* MouseHandler.cs: Handle all mouse events at the application level now
This allows us to paint while dragging the mouse, and handle double
click events properly.
* WindowHandler.cs: Properly generate WM_SHOWWINDOW messages when
our application window is exposed.
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/ChangeLog
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/ChangeLog
2007-12-07 15:06:03 UTC (rev 90937)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/ChangeLog
2007-12-07 15:12:07 UTC (rev 90938)
@@ -1,3 +1,19 @@
+2007-12-07 Geoff Norton <[EMAIL PROTECTED]>
+
+ * ControlHandler.cs: Properly update our invalidated information when
+ Quartz asks us to redraw. This helps fix TabControl but introduces
+ over-zealous drawing causing our flicker. Implement visibility tracking
+ to generate out WM_SHOWWINDOW calls. Refactor mouse tracking to live
+ entirely in MouseHandler.
+ * EventHandler.cs: Unregister some events we no longer handle. Register
+ the new MouseEvents that we do handle.
+ * KeyboardHandler.cs: Implement some more key translations.
+ * MouseHandler.cs: Handle all mouse events at the application level now
+ This allows us to paint while dragging the mouse, and handle double
+ click events properly.
+ * WindowHandler.cs: Properly generate WM_SHOWWINDOW messages when
+ our application window is exposed.
+
2007-11-21 Geoff Norton <[EMAIL PROTECTED]>
* ControlHandler.cs: Allow custom HIView to get keyboard focus.
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/ControlHandler.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/ControlHandler.cs
2007-12-07 15:06:03 UTC (rev 90937)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/ControlHandler.cs
2007-12-07 15:12:07 UTC (rev 90938)
@@ -85,12 +85,9 @@
internal const uint kEventParamCGContextRef = 1668183160;
internal const uint kEventParamDirectObject = 757935405;
- internal const uint kEventParamMouseButton = 1835168878;
- internal const uint kEventParamMouseLocation = 1835822947;
internal const uint kEventParamControlPart = 1668313716;
internal const uint typeControlRef = 1668575852;
internal const uint typeCGContextRef = 1668183160;
- internal const uint typeMouseButton = 1835168878;
internal const uint typeQDPoint = 1363439732;
internal const uint typeControlPartCode = 1668313716;
@@ -111,16 +108,55 @@
switch (kind) {
case kEventControlDraw: {
- HIRect view_bounds = new HIRect ();
+ //FIXME: This is a hack which masks our
over-redraw-expose problem
+ if (client) {
+ HIRect bounds = new HIRect ();
+ HIViewGetBounds (handle, ref
bounds);
+ Driver.AddExpose (hwnd, client,
bounds);
+ }
- HIViewGetBounds (handle, ref
view_bounds);
- Driver.AddExpose (hwnd, client,
view_bounds);
- DrawBackground (hwnd, eventref,
view_bounds);
- if (!client)
+ if (!hwnd.visible) {
+ if (client) {
+ hwnd.expose_pending =
false;
+ } else {
+ hwnd.nc_expose_pending
= false;
+ }
+ return false;
+ }
+
+ if (client) {
+ if (!hwnd.expose_pending) {
+ return false;
+ }
+ msg.message = Msg.WM_PAINT;
+ } else {
+ if (!hwnd.nc_expose_pending) {
+ return false;
+ }
+ //DrawBackground here
DrawBorders (hwnd);
-
- break;
+ Region region = new Region
(hwnd.Invalid);
+ IntPtr hrgn = region.GetHrgn
(null); // Graphics object isn't needed
+ msg.message = Msg.WM_NCPAINT;
+ msg.wParam = hrgn ==
IntPtr.Zero ? (IntPtr)1 : hrgn;
+ msg.refobject = region;
+
+ }
+ return true;
}
+ case kEventControlVisibilityChanged: {
+ HIRect bounds = new HIRect ();
+
+ HIViewGetBounds (handle, ref bounds);
+ Driver.AddExpose (hwnd, client, bounds);
+ if (client) {
+ msg.message = Msg.WM_SHOWWINDOW;
+ msg.lParam = (IntPtr) 0;
+ msg.wParam = (HIViewIsVisible
(handle) ? (IntPtr)1 : (IntPtr)0);
+ return true;
+ }
+ return false;
+ }
case kEventControlBoundsChanged: {
HIRect view_frame = new HIRect ();
@@ -134,68 +170,6 @@
}
return false;
}
- case kEventControlClick: {
- QDPoint point = new QDPoint ();
- ushort button = 0;
-
- if (XplatUICarbon.GrabHwnd != null) {
- hwnd = XplatUICarbon.GrabHwnd;
- msg.hwnd = hwnd.Handle;
- client = true;
- }
-
- GetEventParameter (eventref,
kEventParamMouseLocation, typeQDPoint, IntPtr.Zero, (uint)Marshal.SizeOf
(typeof (QDPoint)), IntPtr.Zero, ref point);
- GetEventParameter (eventref,
kEventParamMouseButton, typeMouseButton, IntPtr.Zero, (uint)Marshal.SizeOf
(typeof (ushort)), IntPtr.Zero, ref button);
-
- Driver.ScreenToClient (hwnd.Handle, ref
point);
-
- msg.wParam = ButtonTowParam (button);
- msg.lParam = (IntPtr) ((ushort) point.y
<< 16 | (ushort) point.x);
- msg.message = (client ?
Msg.WM_MOUSEMOVE : Msg.WM_NCMOUSEMOVE) + ((button - 1) * 3) + 1;
-
- Driver.mouse_position.X = (int) point.x;
- Driver.mouse_position.Y = (int) point.y;
-
- NativeWindow.WndProc (msg.hwnd,
msg.message, msg.wParam, msg.lParam);
-
- HandleControlClick (handle, point, 0,
IntPtr.Zero);
- break;
- }
- case kEventControlTrack: {
- QDPoint point = new QDPoint ();
- MouseTrackingResult mousestatus =
MouseTrackingResult.kMouseTrackingMouseDown;
-
- if (XplatUICarbon.GrabHwnd != null) {
- hwnd = XplatUICarbon.GrabHwnd;
- client = true;
- msg.hwnd = hwnd.Handle;
- }
-
- GetEventParameter (eventref,
kEventParamMouseLocation, typeQDPoint, IntPtr.Zero, (uint)Marshal.SizeOf
(typeof (QDPoint)), IntPtr.Zero, ref point);
-
- while (mousestatus !=
MouseTrackingResult.kMouseTrackingMouseUp) {
- uint modifiers = 0;
-
- if (mousestatus ==
MouseTrackingResult.kMouseTrackingMouseDragged) {
- Driver.ScreenToClient
(hwnd.Handle, ref point);
- NativeWindow.WndProc
(hwnd.Handle, (client ? Msg.WM_MOUSEMOVE : Msg.WM_NCMOUSEMOVE),
Driver.GetMousewParam (0), (IntPtr) ((ushort) point.y << 16 | (ushort)
point.x));
- }
- Driver.FlushQueue ();
-
- TrackMouseLocationWithOptions
(IntPtr.Zero, 0, 0.01, ref point, ref modifiers, ref mousestatus);
- }
- Driver.ScreenToClient (hwnd.Handle, ref
point);
-
- msg.message = (client ?
Msg.WM_MOUSEMOVE : Msg.WM_NCMOUSEMOVE) + ((StateToButton
(XplatUICarbon.MouseState) - 1) * 3) + 2;
- msg.wParam = StateTowParam
(XplatUICarbon.MouseState);
- msg.lParam = (IntPtr) ((ushort) point.y
<< 16 | (ushort) point.x);
-
- Driver.mouse_position.X = (int) point.x;
- Driver.mouse_position.Y = (int) point.y;
-
- SetKeyboardFocus (GetControlOwner
(hwnd.Handle), hwnd.Handle, 1);
- return true;
- }
case kEventControlGetFocusPart: {
short pcode = 0;
SetEventParameter (eventref,
kEventParamControlPart, typeControlPartCode, (uint)Marshal.SizeOf (typeof
(short)), ref pcode);
@@ -205,66 +179,6 @@
return false;
}
- private int StateToButton (MouseButtons state) {
- int button = 0;
-
- switch (state) {
- case MouseButtons.Left:
- button = 1;
- break;
- case MouseButtons.Right:
- button = 2;
- break;
- case MouseButtons.Middle:
- button = 3;
- break;
- }
-
- return button;
- }
-
- private IntPtr StateTowParam (MouseButtons state) {
- int wparam = (int) Driver.GetMousewParam (0);
-
- switch (state) {
- case MouseButtons.Left:
- XplatUICarbon.MouseState &=
~MouseButtons.Left;
- wparam &= (int)MsgButtons.MK_LBUTTON;
- break;
- case MouseButtons.Right:
- XplatUICarbon.MouseState &=
~MouseButtons.Right;
- wparam &= (int)MsgButtons.MK_RBUTTON;
- break;
- case MouseButtons.Middle:
- XplatUICarbon.MouseState &=
~MouseButtons.Middle;
- wparam &= (int)MsgButtons.MK_MBUTTON;
- break;
- }
-
- return (IntPtr) wparam;
- }
-
- private IntPtr ButtonTowParam (ushort button) {
- int wparam = (int) Driver.GetMousewParam (0);
-
- switch (button) {
- case 1:
- XplatUICarbon.MouseState |=
MouseButtons.Left;
- wparam |= (int)MsgButtons.MK_LBUTTON;
- break;
- case 2:
- XplatUICarbon.MouseState |=
MouseButtons.Right;
- wparam |= (int)MsgButtons.MK_RBUTTON;
- break;
- case 3:
- XplatUICarbon.MouseState |=
MouseButtons.Middle;
- wparam |= (int)MsgButtons.MK_MBUTTON;
- break;
- }
-
- return (IntPtr) wparam;
- }
-
private void DrawBackground (Hwnd hwnd, IntPtr eventref, HIRect
bounds) {
if (XplatUICarbon.WindowBackgrounds [hwnd] != null) {
IntPtr context = IntPtr.Zero;
@@ -305,27 +219,15 @@
[DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
static extern int GetEventParameter (IntPtr eventref, uint
name, uint type, IntPtr outtype, uint size, IntPtr outsize, ref IntPtr data);
[DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
- static extern int GetEventParameter (IntPtr eventref, uint
name, uint type, IntPtr outtype, uint size, IntPtr outsize, ref ushort data);
- [DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
- static extern int GetEventParameter (IntPtr eventref, uint
name, uint type, IntPtr outtype, uint size, IntPtr outsize, ref QDPoint data);
- [DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
static extern int SetEventParameter (IntPtr eventref, uint
name, uint type, uint size, ref short data);
- [DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
- static extern void SetKeyboardFocus (IntPtr window, IntPtr
handle, short part);
- [DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
- static extern IntPtr GetControlOwner (IntPtr handle);
-
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
static extern int HIViewGetBounds (IntPtr handle, ref HIRect
rect);
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
static extern int HIViewGetFrame (IntPtr handle, ref HIRect
rect);
-
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
- static extern void HandleControlClick (IntPtr handle, QDPoint
point, uint modifiers, IntPtr callback);
-
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
- static extern void TrackMouseLocationWithOptions (IntPtr port,
int options, double eventtimeout, ref QDPoint point, ref uint modifier, ref
MouseTrackingResult status);
-
+ extern static bool HIViewIsVisible (IntPtr vHnd);
+
[DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
static extern int CGContextSetRGBFillColor (IntPtr cgContext,
float r, float g, float b, float alpha);
[DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/EventHandler.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/EventHandler.cs
2007-12-07 15:06:03 UTC (rev 90937)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/EventHandler.cs
2007-12-07 15:12:07 UTC (rev 90938)
@@ -54,16 +54,10 @@
internal const uint kEventClassAccessibility = 1633903461;
internal static EventTypeSpec [] ControlEvents = new
EventTypeSpec [] {
- new
EventTypeSpec (kEventClassControl, ControlHandler.kEventControlSetFocusPart),
- new
EventTypeSpec (kEventClassControl, ControlHandler.kEventControlGetFocusPart),
- new
EventTypeSpec (kEventClassControl, ControlHandler.kEventControlClick),
- new
EventTypeSpec (kEventClassControl,
ControlHandler.kEventControlContextualMenuClick),
- new
EventTypeSpec (kEventClassControl, ControlHandler.kEventControlTrack),
- new
EventTypeSpec (kEventClassControl, ControlHandler.kEventControlSimulateHit),
new
EventTypeSpec (kEventClassControl, ControlHandler.kEventControlBoundsChanged),
- new
EventTypeSpec (kEventClassControl,
ControlHandler.kEventControlTrackingAreaEntered),
- new
EventTypeSpec (kEventClassControl,
ControlHandler.kEventControlTrackingAreaExited),
- new
EventTypeSpec (kEventClassControl, ControlHandler.kEventControlDraw)
+ new
EventTypeSpec (kEventClassControl, ControlHandler.kEventControlDraw),
+ new
EventTypeSpec (kEventClassControl, ControlHandler.kEventControlGetFocusPart),
+ new
EventTypeSpec (kEventClassControl,
ControlHandler.kEventControlVisibilityChanged)
};
internal static EventTypeSpec [] ApplicationEvents = new
EventTypeSpec[] {
@@ -73,9 +67,13 @@
private static EventTypeSpec [] WindowEvents = new
EventTypeSpec[] {
new
EventTypeSpec (kEventClassMouse, MouseHandler.kEventMouseMoved),
+ new
EventTypeSpec (kEventClassMouse, MouseHandler.kEventMouseDragged),
+ new
EventTypeSpec (kEventClassMouse, MouseHandler.kEventMouseDown),
+ new
EventTypeSpec (kEventClassMouse, MouseHandler.kEventMouseUp),
new
EventTypeSpec (kEventClassWindow, WindowHandler.kEventWindowBoundsChanged),
new
EventTypeSpec (kEventClassWindow, WindowHandler.kEventWindowClose),
+ new
EventTypeSpec (kEventClassWindow, WindowHandler.kEventWindowShown),
new
EventTypeSpec (kEventClassKeyboard,
KeyboardHandler.kEventRawKeyModifiersChanged),
new
EventTypeSpec (kEventClassKeyboard, KeyboardHandler.kEventRawKeyDown),
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/KeyboardHandler.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/KeyboardHandler.cs
2007-12-07 15:06:03 UTC (rev 90937)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/KeyboardHandler.cs
2007-12-07 15:12:07 UTC (rev 90938)
@@ -77,6 +77,20 @@
private bool CharCodeToVirtualKeys (byte charCode, out int
vkey) {
vkey = (int) charCode;
+ switch (vkey) {
+ case 28:
+ vkey = (int) VirtualKeys.VK_LEFT;
+ break;
+ case 29:
+ vkey = (int) VirtualKeys.VK_RIGHT;
+ break;
+ case 30:
+ vkey = (int) VirtualKeys.VK_UP;
+ break;
+ case 31:
+ vkey = (int) VirtualKeys.VK_DOWN;
+ break;
+ }
return true;
}
@@ -109,7 +123,7 @@
msg.wParam = (IntPtr) vkey;
if (result) {
- GetKeyboardFocus (handle, ref msg.hwnd);
+ msg.hwnd = XplatUICarbon.FocusWindow;
}
return result;
@@ -135,8 +149,6 @@
static extern int GetEventParameter (IntPtr eventref, uint
name, uint type, IntPtr outtype, uint size, IntPtr outsize, ref byte data);
[DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
static extern int GetEventParameter (IntPtr eventref, uint
name, uint type, IntPtr outtype, uint size, IntPtr outsize, ref UInt32 data);
- [DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
- static extern int GetKeyboardFocus (IntPtr handle, ref IntPtr
control);
}
internal enum KeyboardModifiers : uint {
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/MouseHandler.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/MouseHandler.cs
2007-12-07 15:06:03 UTC (rev 90937)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/MouseHandler.cs
2007-12-07 15:12:07 UTC (rev 90938)
@@ -38,58 +38,88 @@
internal const uint kEventMouseWheelMoved = 10;
internal const uint kEventParamMouseLocation = 1835822947;
+ internal const uint kEventParamMouseButton = 1835168878;
+ internal const uint typeMouseButton = 1835168878;
internal const uint typeQDPoint = 1363439732;
+
+ internal const uint DoubleClickInterval = 7500000;
+ internal static ClickStruct ClickPending;
internal MouseHandler (XplatUICarbon driver) : base (driver) {}
public bool ProcessEvent (IntPtr eventref, IntPtr handle, uint
kind, ref MSG msg) {
QDPoint qdpoint = new QDPoint ();
CGPoint point = new CGPoint ();
+ Rect window_bounds = new Rect ();
+ IntPtr view_handle = IntPtr.Zero;
+ IntPtr window_handle = IntPtr.Zero;
+ bool client = true;
+ ushort button = 0;
+ Hwnd hwnd;
GetEventParameter (eventref, kEventParamMouseLocation,
typeQDPoint, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (QDPoint)), IntPtr.Zero,
ref qdpoint);
+ GetEventParameter (eventref, kEventParamMouseButton,
typeMouseButton, IntPtr.Zero, (uint)Marshal.SizeOf (typeof (ushort)),
IntPtr.Zero, ref button);
point.x = qdpoint.x;
point.y = qdpoint.y;
- switch (kind) {
- case kEventMouseMoved: {
- Rect window_bounds = new Rect ();
- IntPtr view_handle = IntPtr.Zero;
- IntPtr window_handle = IntPtr.Zero;
- bool client = true;
- Hwnd hwnd;
+ GetWindowBounds (handle, 33, ref window_bounds);
+ HIViewFindByID (HIViewGetRoot (handle), new HIViewID
(EventHandler.kEventClassWindow, 1), ref window_handle);
- GetWindowBounds (handle, 33, ref
window_bounds);
- HIViewFindByID (HIViewGetRoot (handle),
new HIViewID (EventHandler.kEventClassWindow, 1), ref window_handle);
+ point.x -= window_bounds.left;
+ point.y -= window_bounds.top;
- point.x -= window_bounds.left;
- point.y -= window_bounds.top;
+ HIViewGetSubviewHit (window_handle, ref point, true,
ref view_handle);
+ HIViewConvertPoint (ref point, window_handle,
view_handle);
- HIViewGetSubviewHit (window_handle, ref
point, true, ref view_handle);
- HIViewConvertPoint (ref point,
window_handle, view_handle);
+ qdpoint.x = (short) point.x;
+ qdpoint.y = (short) point.y;
- hwnd = Hwnd.ObjectFromHandle
(view_handle);
- if (XplatUICarbon.GrabHwnd != null)
- hwnd = XplatUICarbon.GrabHwnd;
- if (hwnd == null)
- return false;
+ hwnd = Hwnd.ObjectFromHandle (view_handle);
+ if (XplatUICarbon.GrabHwnd != null) {
+ hwnd = XplatUICarbon.GrabHwnd;
+ client = true;
+ }
+ if (hwnd == null)
+ return false;
- client = (hwnd.ClientWindow ==
view_handle ? true : hwnd == XplatUICarbon.GrabHwnd ? true : false);
+ Driver.ScreenToClient (hwnd.Handle, ref qdpoint);
- msg.hwnd = hwnd.Handle;
+ msg.hwnd = hwnd.Handle;
+ msg.lParam = (IntPtr) ((ushort) point.y << 16 |
(ushort) point.x);
+ client = (hwnd.ClientWindow == view_handle ? true :
hwnd == XplatUICarbon.GrabHwnd ? true : false);
+
+ switch (kind) {
+ case kEventMouseDown:
+ msg.message = (client ?
Msg.WM_MOUSEMOVE : Msg.WM_NCMOUSEMOVE) + ((button - 1) * 3) + 1;
+ msg.wParam = ButtonTowParam (button);
+ if (ClickPending.Pending &&
(((DateTime.Now.Ticks - ClickPending.Time) < DoubleClickInterval) && (msg.hwnd
== ClickPending.Hwnd) && (msg.wParam == ClickPending.wParam) && (msg.lParam ==
ClickPending.lParam) && (msg.message == ClickPending.Message))) {
+ msg.message = (client ?
Msg.WM_MOUSEMOVE : Msg.WM_NCMOUSEMOVE) + ((button - 1) * 3) + 3;
+ ClickPending.Pending = false;
+ } else {
+ ClickPending.Pending = true;
+ ClickPending.Hwnd = msg.hwnd;
+ ClickPending.Message =
msg.message;
+ ClickPending.wParam =
msg.wParam;
+ ClickPending.lParam =
msg.lParam;
+ ClickPending.Time =
DateTime.Now.Ticks;
+ }
+ break;
+ case kEventMouseUp:
+ msg.message = (client ?
Msg.WM_MOUSEMOVE : Msg.WM_NCMOUSEMOVE) + ((StateToButton
(XplatUICarbon.MouseState) - 1) * 3) + 2;
+ msg.wParam = StateTowParam
(XplatUICarbon.MouseState);
+ break;
+ case kEventMouseDragged:
+ case kEventMouseMoved:
msg.message = (client ?
Msg.WM_MOUSEMOVE : Msg.WM_NCMOUSEMOVE);
- msg.lParam = (IntPtr) ((ushort)point.y
<< 16 | (ushort)point.x);
msg.wParam = Driver.GetMousewParam (0);
-
- Driver.mouse_position.X = (int)point.x;
- Driver.mouse_position.Y = (int)point.y;
- XplatUICarbon.Hover.Hwnd = hwnd.Handle;
- XplatUICarbon.Hover.Timer.Enabled =
true;
-
- return true;
- }
+ break;
+ default:
+ return false;
}
- return false;
+ Driver.mouse_position.X = (int) point.x;
+ Driver.mouse_position.Y = (int) point.y;
+ return true;
}
internal bool TranslateMessage (ref MSG msg) {
@@ -107,8 +137,71 @@
return false;
}
+ private int StateToButton (MouseButtons state) {
+ int button = 0;
+
+ switch (state) {
+ case MouseButtons.Left:
+ button = 1;
+ break;
+ case MouseButtons.Right:
+ button = 2;
+ break;
+ case MouseButtons.Middle:
+ button = 3;
+ break;
+ }
+
+ return button;
+ }
+
+ private IntPtr StateTowParam (MouseButtons state) {
+ int wparam = (int) Driver.GetMousewParam (0);
+
+ switch (state) {
+ case MouseButtons.Left:
+ XplatUICarbon.MouseState &=
~MouseButtons.Left;
+ wparam &= (int)MsgButtons.MK_LBUTTON;
+ break;
+ case MouseButtons.Right:
+ XplatUICarbon.MouseState &=
~MouseButtons.Right;
+ wparam &= (int)MsgButtons.MK_RBUTTON;
+ break;
+ case MouseButtons.Middle:
+ XplatUICarbon.MouseState &=
~MouseButtons.Middle;
+ wparam &= (int)MsgButtons.MK_MBUTTON;
+ break;
+ }
+
+ return (IntPtr) wparam;
+ }
+
+ private IntPtr ButtonTowParam (ushort button) {
+ int wparam = (int) Driver.GetMousewParam (0);
+
+ switch (button) {
+ case 1:
+ XplatUICarbon.MouseState |=
MouseButtons.Left;
+ wparam |= (int)MsgButtons.MK_LBUTTON;
+ break;
+ case 2:
+ XplatUICarbon.MouseState |=
MouseButtons.Right;
+ wparam |= (int)MsgButtons.MK_RBUTTON;
+ break;
+ case 3:
+ XplatUICarbon.MouseState |=
MouseButtons.Middle;
+ wparam |= (int)MsgButtons.MK_MBUTTON;
+ break;
+ }
+
+ return (IntPtr) wparam;
+ }
+
+
[DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
static extern int GetEventParameter (IntPtr eventref, uint
name, uint type, IntPtr outtype, uint size, IntPtr outsize, ref QDPoint data);
+ [DllImport
("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+ static extern int GetEventParameter (IntPtr eventref, uint
name, uint type, IntPtr outtype, uint size, IntPtr outsize, ref ushort data);
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
internal static extern int GetWindowBounds (IntPtr handle, uint
region, ref Rect bounds);
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/WindowHandler.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/WindowHandler.cs
2007-12-07 15:06:03 UTC (rev 90937)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.CarbonInternal/WindowHandler.cs
2007-12-07 15:12:07 UTC (rev 90938)
@@ -116,6 +116,16 @@
case kEventWindowClose:
NativeWindow.WndProc (window,
Msg.WM_DESTROY, IntPtr.Zero, IntPtr.Zero);
return false;
+ case kEventWindowShown: {
+ Hwnd hwnd =
Hwnd.ObjectFromHandle (window);
+
+ msg.message = Msg.WM_SHOWWINDOW;
+ msg.lParam = (IntPtr) 1;
+ msg.wParam = (IntPtr) 0;
+ msg.hwnd = hwnd.Handle;
+
+ return true;
+ }
case kEventWindowBoundsChanged: {
Rect window_bounds = new Rect
();
HIRect view_bounds = new HIRect
();
@@ -149,9 +159,9 @@
}
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
- internal static extern int GetWindowBounds (IntPtr handle, uint
region, ref Rect bounds);
+ static extern int GetWindowBounds (IntPtr handle, uint region,
ref Rect bounds);
[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
- internal static extern int HIViewSetFrame (IntPtr handle, ref
HIRect bounds);
+ static extern int HIViewSetFrame (IntPtr handle, ref HIRect
bounds);
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches