return cursor;
}
+
+ public Bitmap DefineStdCursorBitmap (StdCursor id)
+ {
+ CursorFontShape shape;
+ string name;
+ IntPtr theme;
+ int size;
+ Bitmap bmp = null;
+
+ try {
+ shape = XplatUIX11.StdCursorToFontShape (id);
+ name = shape.ToString ().Replace ("XC_", string.Empty);
+ size = XplatUIX11.XcursorGetDefaultSize (Handle);
+ theme = XplatUIX11.XcursorGetTheme (Handle);
+ IntPtr images_ptr = XplatUIX11.XcursorLibraryLoadImages (name, theme, size);
+#if debug
+ Console.WriteLine ("DefineStdCursorBitmap, id={0}, #id={1}, name{2}, size={3}, theme: {4}, images_ptr={5}", id, (int) id, name, size, Marshal.PtrToStringAnsi (theme), images_ptr);
+#endif
+
+ if (images_ptr == IntPtr.Zero) {
+ return null;
+ }
+
+ XcursorImages images = (XcursorImages)Marshal.PtrToStructure (images_ptr, typeof (XcursorImages));
+#if debug
+ Console.WriteLine ("DefineStdCursorBitmap, cursor has {0} images", images.nimage);
+#endif
+
+ if (images.nimage > 0) {
+ // We only care about the first image.
+ XcursorImage image = (XcursorImage)Marshal.PtrToStructure (Marshal.ReadIntPtr (images.images), typeof (XcursorImage));
+
+#if debug
+ Console.WriteLine ("DefineStdCursorBitmap, loaded image <size={0}, height={1}, width={2}, xhot={3}, yhot={4}, pixels={5}", image.size, image.height, image.width, image.xhot, image.yhot, image.pixels);
+#endif
+ // A sanity check
+ if (image.width <= short.MaxValue && image.height <= short.MaxValue) {
+ int [] pixels = new int [image.width * image.height];
+ Marshal.Copy (image.pixels, pixels, 0, pixels.Length);
+ bmp = new Bitmap (image.width, image.height);
+ for (int w = 0; w < image.width; w++) {
+ for (int h = 0; h < image.height; h++) {
+ bmp.SetPixel (w, h, Color.FromArgb (pixels [h * image.width + w]));
+ }
+ }
+ }
+ }
+
+ XplatUIX11.XcursorImagesDestroy (images_ptr);
+ } catch (DllNotFoundException ex) {
+ Console.WriteLine ("Could not load libXcursor: " + ex.Message + " (" + ex.GetType ().Name + ")");
+ return null;
+ }
+
+ return bmp;
+ }
+
public IntPtr DefineStdCursor (StdCursor id)
{
CursorFontShape shape;
// of ours but not the modal one, switch back to the modal window
if (ActiveWindow != null &&
- NativeWindow.FindWindow (ActiveWindow.Handle) != null) {
+ NativeWindow.FromHandle (ActiveWindow.Handle) != null) {
if (ActiveWindow != (X11Hwnd)ModalWindows.Peek())
((X11Hwnd)ModalWindows.Peek()).Activate ();
}
}
- public PaintEventArgs PaintEventStart (IntPtr handle, bool client)
+ public PaintEventArgs PaintEventStart (ref Message m, IntPtr handle, bool client)
{
X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
HideCaret();
}
- return hwnd.PaintEventStart (client);
+ return hwnd.PaintEventStart (ref m, client);
}
- public void PaintEventEnd (IntPtr handle, bool client)
+ public void PaintEventEnd (ref Message m, IntPtr handle, bool client)
{
X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
- hwnd.PaintEventEnd (client);
+ hwnd.PaintEventEnd (ref m, client);
if (Caret.Visible == true) {
ShowCaret();
switch (xevent.type) {
case XEventName.KeyPress:
- if (Dnd.InDrag ())
- Dnd.HandleKeyPress (ref xevent);
Keyboard.KeyEvent (FocusWindow.Handle, xevent, ref msg);
return true;
}
case XEventName.ButtonRelease:
- if (Dnd.InDrag()) {
- if (Dnd.HandleButtonRelease (ref xevent))
- return true;
- // Don't return here, so that the BUTTONUP message can get through
- }
-
switch(xevent.ButtonEvent.button) {
case 1:
if (client) {
xevent.MotionEvent.x, xevent.MotionEvent.y);
#endif
- if (Dnd.HandleMotionNotify (ref xevent))
- goto ProcessNextMessage;
-
if (Grab.Hwnd != IntPtr.Zero)
msg.hwnd = Grab.Hwnd;
else
public void DrawReversibleLine (Point start, Point end, Color backColor)
{
+ if (backColor.GetBrightness() < 0.5)
+ backColor = Color.FromArgb(255 - backColor.R, 255 - backColor.G, 255 - backColor.B);
+
IntPtr gc = GetReversibleScreenGC (backColor);
Xlib.XDrawLine (display, RootWindow.Handle, gc, start.X, start.Y, end.X, end.Y);
public void FillReversibleRectangle (Rectangle rectangle, Color backColor)
{
+ if (backColor.GetBrightness() < 0.5)
+ backColor = Color.FromArgb(255 - backColor.R, 255 - backColor.G, 255 - backColor.B);
+
IntPtr gc = GetReversibleScreenGC (backColor);
if (rectangle.Width < 0) {
public void DrawReversibleFrame (Rectangle rectangle, Color backColor, FrameStyle style)
{
+ if (backColor.GetBrightness() < 0.5)
+ backColor = Color.FromArgb(255 - backColor.R, 255 - backColor.G, 255 - backColor.B);
+
IntPtr gc = GetReversibleScreenGC (backColor);
if (rectangle.Width < 0) {