1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2004-2006 Novell, Inc.
23 // Peter Bartok pbartok@novell.com
24 // Chris Toshok toshok@ximian.com
29 // This driver understands the following environment variables: (Set the var to enable feature)
31 // MONO_XEXCEPTIONS = throw an exception when a X11 error is encountered;
32 // by default a message is displayed but execution continues
34 // MONO_XSYNC = perform all X11 commands synchronous; this is slower but
35 // helps in debugging errors
40 // define to log Window handles and relationships to stdout
43 // Extra detailed debug
44 #undef DriverDebugExtra
45 #undef DriverDebugParent
46 #undef DriverDebugCreate
47 #undef DriverDebugDestroy
48 #undef DriverDebugThreads
49 #undef DriverDebugXEmbed
52 using System.ComponentModel;
53 using System.Collections;
54 using System.Diagnostics;
56 using System.Drawing.Drawing2D;
57 using System.Drawing.Imaging;
60 using System.Net.Sockets;
61 using System.Reflection;
62 using System.Runtime.InteropServices;
64 using System.Threading;
65 using System.Windows.Forms;
68 namespace System.Windows.Forms.X11Internal {
69 internal class XplatUIX11_new : XplatUIDriver {
70 #region Local Variables
72 static volatile XplatUIX11_new Instance;
73 static readonly object lockobj = new object ();
75 static bool themes_enabled;
77 static Hashtable MessageQueues; // Holds our thread-specific X11ThreadQueues
81 #endregion // Local Variables
83 private XplatUIX11_new() {
84 // Handle singleton stuff first
87 // Now regular initialization
88 MessageQueues = Hashtable.Synchronized (new Hashtable(7));
89 if (Xlib.XInitThreads() == 0) {
90 Console.WriteLine ("Failed XInitThreads. The X11 event loop will not function properly");
94 private void InitializeDisplay ()
96 display = new X11Display (Xlib.XOpenDisplay(IntPtr.Zero));
98 Graphics.FromHdcInternal (display.Handle);
102 // Remove our display handle from S.D
103 Graphics.FromHdcInternal (IntPtr.Zero);
106 #endregion // Constructors
108 #region Singleton Specific Code
109 public static XplatUIX11_new GetInstance() {
111 if (Instance == null) {
112 Instance = new XplatUIX11_new ();
114 Instance.InitializeDisplay ();
121 public int Reference {
128 #region Internal Methods
129 internal static void Where() {
130 Console.WriteLine("Here: {0}\n", GetInstance().display.WhereString());
133 #endregion // Internal Methods
135 #region Private Methods
137 internal X11ThreadQueue ThreadQueue (Thread thread)
139 X11ThreadQueue queue;
141 queue = (X11ThreadQueue)MessageQueues[thread];
143 queue = new X11ThreadQueue(thread);
144 MessageQueues[thread] = queue;
149 #endregion // Private Methods
152 #region Public Properties
153 internal override int CaptionHeight {
157 internal override Size CursorSize {
158 get { return display.CursorSize; }
161 internal override bool DragFullWindows {
165 internal override Size DragSize {
166 get { return new Size(4, 4); }
169 internal override Size FrameBorderSize {
170 get { return new Size (4, 4); }
173 internal override Size IconSize {
174 get { return display.IconSize; }
177 internal override int KeyboardSpeed {
178 get { return display.KeyboardSpeed; }
181 internal override int KeyboardDelay {
182 get { return display.KeyboardSpeed; }
185 internal override Size MaxWindowTrackSize {
186 get { return new Size (WorkingArea.Width, WorkingArea.Height); }
189 internal override bool MenuAccessKeysUnderlined {
195 internal override Size MinimizedWindowSpacingSize {
196 get { return new Size(1, 1); }
199 internal override Size MinimumWindowSize {
200 get { return new Size(1, 1); }
203 internal override Keys ModifierKeys {
204 get { return display.ModifierKeys; }
207 internal override Size SmallIconSize {
208 get { return display.SmallIconSize; }
211 internal override int MouseButtonCount {
212 get { return 3; /* FIXME - should detect this somehow.. */}
215 internal override bool MouseButtonsSwapped {
216 get { return false; /*FIXME - how to detect? */}
219 internal override Size MouseHoverSize {
220 get { return new Size (1, 1); }
223 internal override int MouseHoverTime {
224 get { return display.MouseHoverTime; }
227 internal override bool MouseWheelPresent {
228 get { return true; /* FIXME - how to detect? */ }
231 internal override Rectangle VirtualScreen {
232 get { return display.VirtualScreen; }
235 internal override Rectangle WorkingArea {
236 get { return display.WorkingArea; }
239 internal override bool ThemesEnabled {
240 get { return XplatUIX11_new.themes_enabled; }
244 #endregion // Public properties
246 #region Public Static Methods
247 internal override void RaiseIdle (EventArgs e)
249 X11ThreadQueue queue = ThreadQueue (Thread.CurrentThread);
253 internal override IntPtr InitializeDriver ()
257 display = new X11Display (Xlib.XOpenDisplay(IntPtr.Zero));
262 internal override void ShutdownDriver(IntPtr token)
265 if (display != null) {
272 internal override void EnableThemes()
274 themes_enabled = true;
277 internal override void Activate (IntPtr handle)
279 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
285 internal override void AudibleAlert()
287 display.AudibleAlert ();
291 internal override void CaretVisible (IntPtr handle, bool visible)
293 display.CaretVisible (handle, visible);
296 // XXX this implementation should probably be shared between all non-win32 backends
297 internal override bool CalculateWindowRect (ref Rectangle ClientRect, CreateParams cp, Menu menu, out Rectangle WindowRect)
299 WindowRect = Hwnd.GetWindowRectangle (cp, menu, ClientRect);
303 internal override void ClientToScreen (IntPtr handle, ref int x, ref int y)
305 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
308 hwnd.ClientToScreen (ref x, ref y);
311 internal override int[] ClipboardAvailableFormats (IntPtr handle)
313 return display.ClipboardAvailableFormats (handle);
316 internal override void ClipboardClose (IntPtr handle)
318 display.ClipboardClose (handle);
321 internal override int ClipboardGetID (IntPtr handle, string format)
323 return display.ClipboardGetID (handle, format);
326 internal override IntPtr ClipboardOpen (bool primary_selection)
328 return display.ClipboardOpen (primary_selection);
331 internal override object ClipboardRetrieve (IntPtr handle, int type, XplatUI.ClipboardToObject converter)
333 return display.ClipboardRetrieve (handle, type, converter);
336 internal override void ClipboardStore (IntPtr handle, object obj, int type, XplatUI.ObjectToClipboard converter)
338 display.ClipboardStore (handle, obj, type, converter);
341 internal override void CreateCaret (IntPtr handle, int width, int height)
343 display.CreateCaret (handle, width, height);
346 internal override IntPtr CreateWindow (CreateParams cp)
348 X11Hwnd hwnd = new X11Hwnd (display);
350 hwnd.CreateWindow (cp);
355 internal override IntPtr CreateWindow (IntPtr Parent, int X, int Y, int Width, int Height)
357 CreateParams create_params = new CreateParams();
359 create_params.Caption = "";
362 create_params.Width = Width;
363 create_params.Height = Height;
365 create_params.ClassName = XplatUI.DefaultClassName;
366 create_params.ClassStyle = 0;
367 create_params.ExStyle = 0;
368 create_params.Parent = IntPtr.Zero;
369 create_params.Param = 0;
371 return CreateWindow (create_params);
374 internal override IntPtr DefineCursor (Bitmap bitmap, Bitmap mask, Color cursor_pixel, Color mask_pixel, int xHotSpot, int yHotSpot)
376 return display.DefineCursor (bitmap, mask, cursor_pixel, mask_pixel, xHotSpot, yHotSpot);
378 internal override Bitmap DefineStdCursorBitmap (StdCursor id)
380 return display.DefineStdCursorBitmap (id);
382 internal override IntPtr DefineStdCursor (StdCursor id)
384 return display.DefineStdCursor (id);
387 internal override IntPtr DefWndProc(ref Message msg)
389 X11Hwnd hwnd = (X11Hwnd)Hwnd.GetObjectFromWindow(msg.HWnd);
394 return hwnd.DefWndProc (ref msg);
397 internal override void DestroyCaret (IntPtr handle)
399 display.DestroyCaret (handle);
402 internal override void DestroyCursor(IntPtr cursor)
404 display.DestroyCursor (cursor);
407 internal override void DestroyWindow (IntPtr handle) {
410 hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
413 #if DriverDebug || DriverDebugDestroy
414 Console.WriteLine("window {0:X} already destroyed", handle.ToInt32());
419 #if DriverDebug || DriverDebugDestroy
420 Console.WriteLine("Destroying window {0}", XplatUI.Window(hwnd.ClientWindow));
423 display.DestroyWindow (hwnd);
426 internal override IntPtr DispatchMessage(ref MSG msg)
428 return display.DispatchMessage (ref msg);
431 internal override void DrawReversibleLine (Point start, Point end, Color backColor)
433 display.DrawReversibleLine (start, end, backColor);
436 internal override void FillReversibleRectangle (Rectangle rectangle, Color backColor)
438 display.FillReversibleRectangle (rectangle, backColor);
441 internal override void DrawReversibleFrame (Rectangle rectangle, Color backColor, FrameStyle style)
443 display.DrawReversibleFrame (rectangle, backColor, style);
446 internal override void DrawReversibleRectangle (IntPtr handle, Rectangle rect, int line_width)
448 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
451 hwnd.DrawReversibleRectangle (rect, line_width);
454 internal override void DoEvents ()
456 X11ThreadQueue queue = ThreadQueue (Thread.CurrentThread);
457 display.DoEvents (queue);
460 internal override void EnableWindow (IntPtr handle, bool Enable)
464 hwnd = Hwnd.ObjectFromHandle(handle);
466 hwnd.Enabled = Enable;
469 internal override void EndLoop (Thread thread)
471 // This is where we one day will shut down the loop for the thread
475 internal override IntPtr GetActive()
477 X11Hwnd hwnd = display.GetActiveWindow ();
479 return (hwnd == null) ? IntPtr.Zero : hwnd.Handle;
482 internal override Region GetClipRegion (IntPtr handle)
484 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
486 return (hwnd == null) ? null : hwnd.GetClipRegion ();
489 internal override void GetCursorInfo(IntPtr cursor, out int width, out int height, out int hotspot_x, out int hotspot_y)
497 internal override void GetDisplaySize(out Size size)
499 display.GetDisplaySize (out size);
502 internal override SizeF GetAutoScaleSize (Font font)
504 return display.GetAutoScaleSize (font);
507 // XXX this should be someplace shareable by all non-win32 backends.. like in Hwnd itself.
508 // maybe a Hwnd.ParentHandle property
509 internal override IntPtr GetParent (IntPtr handle)
513 hwnd = Hwnd.ObjectFromHandle(handle);
514 if (hwnd != null && hwnd.parent != null) {
515 return hwnd.parent.Handle;
520 // This is a nop on win32 and x11
521 internal override IntPtr GetPreviousWindow(IntPtr handle) {
525 internal override void GetCursorPos (IntPtr handle, out int x, out int y)
527 display.GetCursorPos ((X11Hwnd)Hwnd.ObjectFromHandle(handle),
531 internal override IntPtr GetFocus()
533 return display.GetFocus ();
536 // XXX this should be shared amongst non-win32 backends
537 internal override bool GetFontMetrics (Graphics g, Font font, out int ascent, out int descent)
539 FontFamily ff = font.FontFamily;
540 ascent = ff.GetCellAscent (font.Style);
541 descent = ff.GetCellDescent (font.Style);
546 // XXX this should be shared amongst non-win32 backends
547 internal override Point GetMenuOrigin (IntPtr handle)
551 hwnd = Hwnd.ObjectFromHandle(handle);
554 return hwnd.MenuOrigin;
559 internal override bool GetMessage (object queue_id, ref MSG msg, IntPtr handle, int wFilterMin, int wFilterMax)
561 return display.GetMessage (queue_id, ref msg, handle, wFilterMin, wFilterMax);
564 internal override bool GetText (IntPtr handle, out string text)
566 X11Hwnd hwnd = (X11Hwnd) Hwnd.ObjectFromHandle(handle);
569 return hwnd != null && hwnd.GetText (out text);
572 internal override void GetWindowPos (IntPtr handle, bool is_toplevel,
573 out int x, out int y,
574 out int width, out int height,
575 out int client_width, out int client_height)
577 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
580 hwnd.GetPosition (is_toplevel, out x, out y, out width, out height, out client_width, out client_height);
583 // Should we throw an exception or fail silently?
584 // throw new ArgumentException("Called with an invalid window handle", "handle");
595 internal override FormWindowState GetWindowState (IntPtr handle)
597 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
600 return FormWindowState.Normal; // XXX should we throw an exception here? probably
602 return hwnd.GetWindowState ();
605 internal override void GrabInfo (out IntPtr handle, out bool GrabConfined, out Rectangle GrabArea)
607 display.GrabInfo (out handle, out GrabConfined, out GrabArea);
610 internal override void GrabWindow (IntPtr handle, IntPtr confine_to_handle)
612 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
613 X11Hwnd confine_to_hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(confine_to_handle);
615 display.GrabWindow (hwnd, confine_to_hwnd);
618 internal override void UngrabWindow (IntPtr handle)
620 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
622 display.UngrabWindow (hwnd);
625 internal override void HandleException(Exception e) {
626 StackTrace st = new StackTrace(e, true);
627 Console.WriteLine("Exception '{0}'", e.Message+st.ToString());
628 Console.WriteLine("{0}{1}", e.Message, st.ToString());
631 internal override void Invalidate (IntPtr handle, Rectangle rc, bool clear)
633 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
635 hwnd.Invalidate (rc, clear);
638 internal override void InvalidateNC (IntPtr handle)
640 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
642 hwnd.InvalidateNC ();
645 internal override bool IsEnabled(IntPtr handle)
647 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle (handle);
649 return hwnd != null && hwnd.Enabled;
652 internal override bool IsVisible(IntPtr handle)
654 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle (handle);
656 return hwnd != null && hwnd.Visible;
659 internal override void KillTimer (Timer timer)
661 X11ThreadQueue queue = (X11ThreadQueue) MessageQueues [timer.thread];
664 // This isn't really an error, MS doesn't start the timer if
665 // it has no assosciated queue
668 queue.KillTimer (timer);
671 internal override void MenuToScreen (IntPtr handle, ref int x, ref int y)
673 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
676 hwnd.MenuToScreen (ref x, ref y);
679 internal override void OverrideCursor (IntPtr cursor)
681 display.OverrideCursor = cursor;
684 internal override PaintEventArgs PaintEventStart (ref Message m, IntPtr handle, bool client)
686 return display.PaintEventStart (ref m, handle, client);
689 internal override void PaintEventEnd (ref Message m, IntPtr handle, bool client)
691 display.PaintEventEnd (ref m, handle, client);
695 internal override bool PeekMessage (object queue_id, ref MSG msg, IntPtr hWnd, int wFilterMin, int wFilterMax, uint flags)
697 return display.PeekMessage (queue_id, ref msg, hWnd, wFilterMin, wFilterMax, flags);
700 internal override bool PostMessage (IntPtr handle, Msg message, IntPtr wparam, IntPtr lparam)
702 return display.PostMessage (handle, message, wparam, lparam);
705 internal override void PostQuitMessage(int exitCode)
707 display.PostMessage (display.FosterParent.Handle, Msg.WM_QUIT, IntPtr.Zero, IntPtr.Zero);
712 internal override void RequestAdditionalWM_NCMessages (IntPtr handle, bool hover, bool leave)
714 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
717 hwnd.RequestAdditionalWM_NCMessages (hover, leave);
720 internal override void RequestNCRecalc (IntPtr handle)
722 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
725 hwnd.RequestNCRecalc ();
728 internal override void ResetMouseHover (IntPtr handle)
730 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
732 display.ResetMouseHover (hwnd);
735 internal override void ScreenToClient(IntPtr handle, ref int x, ref int y)
737 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
740 hwnd.ScreenToClient (ref x, ref y);
743 internal override void ScreenToMenu (IntPtr handle, ref int x, ref int y)
745 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
748 hwnd.ScreenToMenu (ref x, ref y);
751 internal override void ScrollWindow (IntPtr handle, Rectangle area, int XAmount, int YAmount, bool with_children)
753 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
756 hwnd.ScrollWindow (area, XAmount, YAmount, with_children);
759 internal override void ScrollWindow(IntPtr handle, int XAmount, int YAmount, bool with_children)
761 X11Hwnd hwnd = (X11Hwnd)Hwnd.GetObjectFromWindow(handle);
766 rect = hwnd.ClientRect;
769 hwnd.ScrollWindow (rect, XAmount, YAmount, with_children);
773 internal override void SendAsyncMethod (AsyncMethodData method)
775 display.SendAsyncMethod (method);
778 // XXX this is likely shareable amongst other backends
779 internal override IntPtr SendMessage (IntPtr handle, Msg message, IntPtr wParam, IntPtr lParam)
781 return display.SendMessage (handle, message, wParam, lParam);
784 internal override int SendInput(IntPtr handle, Queue keys) {
785 return display.SendInput(handle, keys);
789 internal override void SetAllowDrop (IntPtr handle, bool value)
791 // We allow drop on all windows
794 internal override DragDropEffects StartDrag (IntPtr handle, object data,
795 DragDropEffects allowed_effects)
797 return display.StartDrag (handle, data, allowed_effects);
800 internal override void SetBorderStyle (IntPtr handle, FormBorderStyle border_style)
802 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
805 hwnd.SetBorderStyle (border_style);
808 internal override void SetCaretPos (IntPtr handle, int x, int y)
810 display.SetCaretPos (handle, x, y);
813 internal override void SetClipRegion (IntPtr handle, Region region)
815 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
818 hwnd.SetClipRegion (region);
821 internal override void SetCursor (IntPtr handle, IntPtr cursor)
823 display.SetCursor (handle, cursor);
826 internal override void SetCursorPos (IntPtr handle, int x, int y)
828 if (handle == IntPtr.Zero) {
829 display.SetCursorPos (x, y);
832 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
834 hwnd.SetCursorPos (x, y);
838 internal override void SetFocus (IntPtr handle)
840 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
842 display.SetFocus (hwnd);
845 internal override void SetIcon(IntPtr handle, Icon icon)
847 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);;
853 internal override void SetMenu(IntPtr handle, Menu menu)
855 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
860 internal override void SetModal(IntPtr handle, bool Modal)
862 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
865 display.SetModal (hwnd, Modal);
868 internal override IntPtr SetParent(IntPtr handle, IntPtr parent)
870 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
871 X11Hwnd parent_hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(parent);
874 hwnd.SetParent (parent_hwnd);
879 internal override void SetTimer (Timer timer)
881 X11ThreadQueue queue = (X11ThreadQueue) MessageQueues [timer.thread];
884 // This isn't really an error, MS doesn't start the timer if
885 // it has no assosciated queue
888 queue.SetTimer (timer);
891 internal override bool SetTopmost(IntPtr handle, bool enabled)
893 X11Hwnd hwnd = (X11Hwnd) Hwnd.ObjectFromHandle (handle);
898 return hwnd.SetTopmost (enabled);
901 internal override bool SetOwner(IntPtr handle, IntPtr handle_owner)
905 hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
910 X11Hwnd hwnd_owner = (X11Hwnd)Hwnd.ObjectFromHandle(handle_owner);
912 return hwnd.SetOwner (hwnd_owner);
915 internal override bool SetVisible (IntPtr handle, bool visible, bool activate)
917 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
919 return hwnd != null && hwnd.SetVisible (visible, activate);
922 internal override void SetWindowMinMax (IntPtr handle, Rectangle maximized, Size min, Size max)
924 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
929 hwnd.SetMinMax (maximized, min, max);
932 internal override void SetWindowPos (IntPtr handle, int x, int y, int width, int height)
934 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
937 hwnd.SetPosition (x, y, width, height);
940 internal override void SetWindowState (IntPtr handle, FormWindowState state)
942 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
945 hwnd.SetWindowState (state);
948 internal override void SetWindowStyle (IntPtr handle, CreateParams cp)
950 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
953 hwnd.SetHwndStyles (cp);
954 hwnd.SetWMStyles (cp);
958 internal override double GetWindowTransparency (IntPtr handle)
960 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
963 return hwnd.GetWindowTransparency ();
968 internal override void SetWindowTransparency (IntPtr handle, double transparency, Color key)
970 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
973 hwnd.SetWindowTransparency (transparency, key);
976 internal override bool SetZOrder (IntPtr handle, IntPtr after_handle, bool top, bool bottom)
978 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
980 if (hwnd == null || !hwnd.mapped)
983 X11Hwnd after_hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(after_handle);
985 return hwnd.SetZOrder (after_hwnd, top, bottom);
988 internal override void ShowCursor (bool show)
990 display.ShowCursor (show);
993 internal override object StartLoop(Thread thread)
995 return (object) ThreadQueue(thread);
998 internal override TransparencySupport SupportsTransparency()
1000 return display.SupportsTransparency ();
1003 internal override bool SystrayAdd (IntPtr handle, string tip, Icon icon, out ToolTip tt)
1005 return display.SystrayAdd (handle, tip, icon, out tt);
1008 internal override bool SystrayChange (IntPtr handle, string tip, Icon icon, ref ToolTip tt)
1010 return display.SystrayChange (handle, tip, icon, ref tt);
1013 internal override void SystrayRemove (IntPtr handle, ref ToolTip tt)
1015 display.SystrayRemove (handle, ref tt);
1018 NotifyIcon.BalloonWindow balloon_window;
1020 internal override void SystrayBalloon(IntPtr handle, int timeout, string title, string text, ToolTipIcon icon)
1022 Control control = Control.FromHandle(handle);
1024 if (control == null)
1027 if (balloon_window != null) {
1028 balloon_window.Close ();
1029 balloon_window.Dispose ();
1032 balloon_window = new NotifyIcon.BalloonWindow (handle);
1033 balloon_window.Title = title;
1034 balloon_window.Text = text;
1035 balloon_window.Timeout = timeout;
1036 balloon_window.Show ();
1038 SendMessage(handle, Msg.WM_USER, IntPtr.Zero, (IntPtr) Msg.NIN_BALLOONSHOW);
1041 internal override bool Text (IntPtr handle, string text)
1043 X11Hwnd hwnd = (X11Hwnd) Hwnd.ObjectFromHandle(handle);
1051 internal override bool TranslateMessage (ref MSG msg)
1053 return display.TranslateMessage (ref msg);
1056 internal override void UpdateWindow (IntPtr handle)
1058 X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle);
1064 internal override void CreateOffscreenDrawable (IntPtr handle,
1065 int width, int height,
1066 out object offscreen_drawable)
1068 display.CreateOffscreenDrawable (handle, width, height,
1069 out offscreen_drawable);
1072 internal override void DestroyOffscreenDrawable (object offscreen_drawable)
1074 display.DestroyOffscreenDrawable (offscreen_drawable);
1077 internal override Graphics GetOffscreenGraphics (object offscreen_drawable)
1079 return display.GetOffscreenGraphics (offscreen_drawable);
1082 internal override void BlitFromOffscreen (IntPtr dest_handle,
1084 object offscreen_drawable,
1085 Graphics offscreen_dc,
1088 display.BlitFromOffscreen (dest_handle, dest_dc, offscreen_drawable, offscreen_dc, r);
1091 #endregion // Public Static Methods
1094 internal override event EventHandler Idle {
1096 Console.WriteLine ("adding idle handler for thread {0}", Thread.CurrentThread.GetHashCode());
1097 X11ThreadQueue queue = ThreadQueue(Thread.CurrentThread);
1098 queue.Idle += value;
1101 X11ThreadQueue queue = ThreadQueue(Thread.CurrentThread);
1102 queue.Idle += value;
1105 #endregion // Events