コード例 #1
0
ファイル: Program.cs プロジェクト: K-Library-NET/dotNET
        static void OverrideX11ErrorHandler()
        {
            if (!Xpcom.IsLinux)
            return;

            // Initalize the Display then override the X11 error handler.
            Form f = new Form();
            f.Show();
            Application.DoEvents();

            ErrorHandler = new XErrorHandler(HandleError);
            XSetErrorHandler(ErrorHandler);
        }
コード例 #2
0
        static void OverrideX11ErrorHandler()
        {
            if (!Xpcom.IsLinux)
            {
                return;
            }

            // Initalize the Display then override the X11 error handler.
            Form f = new Form();

            f.Show();
            Application.DoEvents();

            ErrorHandler = new XErrorHandler(HandleError);
            XSetErrorHandler(ErrorHandler);
        }
コード例 #3
0
ファイル: Xlib.cs プロジェクト: 1j01/node-ahk
 public static extern XErrorHandler XSetErrorHandler(XErrorHandler Handler);
コード例 #4
0
ファイル: XplatUIX11.cs プロジェクト: nlhepler/mono
		internal extern static IntPtr XSetErrorHandler(XErrorHandler error_handler);
コード例 #5
0
ファイル: XplatUIX11.cs プロジェクト: nlhepler/mono
		internal static IntPtr XSetErrorHandler(XErrorHandler error_handler)
		{
			DebugHelper.TraceWriteLine ("XSetErrorHandler");
			return _XSetErrorHandler(error_handler);
		}
コード例 #6
0
ファイル: XplatUIX11.cs プロジェクト: nlhepler/mono
		internal void SetDisplay(IntPtr display_handle)
		{
			if (display_handle != IntPtr.Zero) {
				Hwnd	hwnd;

				if ((DisplayHandle != IntPtr.Zero) && (FosterParent != IntPtr.Zero)) {
					hwnd = Hwnd.ObjectFromHandle(FosterParent);
					XDestroyWindow(DisplayHandle, FosterParent);
					hwnd.Dispose();
				}

				if (DisplayHandle != IntPtr.Zero) {
					XCloseDisplay(DisplayHandle);
				}

				DisplayHandle=display_handle;

				// We need to tell System.Drawing our DisplayHandle. FromHdcInternal has
				// been hacked to do this for us.
				Graphics.FromHdcInternal (DisplayHandle);

				// query for the render extension so
				// we can ignore the spurious
				// BadPicture errors that are
				// generated by cairo/render.
				XQueryExtension (DisplayHandle, "RENDER",
						 ref render_major_opcode, ref render_first_event, ref render_first_error);

				// Debugging support
				if (Environment.GetEnvironmentVariable ("MONO_XSYNC") != null) {
					XSynchronize(DisplayHandle, true);
				}

				if (Environment.GetEnvironmentVariable ("MONO_XEXCEPTIONS") != null) {
					ErrorExceptions = true;
				}

				// Generic X11 setup
				ScreenNo = XDefaultScreen(DisplayHandle);
				RootWindow = XRootWindow(DisplayHandle, ScreenNo);
				DefaultColormap = XDefaultColormap(DisplayHandle, ScreenNo);

				// Create the foster parent
				// it is important that border_width is kept in synch with the other XCreateWindow calls
				FosterParent=XCreateSimpleWindow(DisplayHandle, RootWindow, 0, 0, 1, 1, 0, UIntPtr.Zero, UIntPtr.Zero);
				if (FosterParent==IntPtr.Zero) {
					Console.WriteLine("XplatUIX11 Constructor failed to create FosterParent");
				}

				DebugHelper.WriteLine ("FosterParent created 0x{0:x}", FosterParent.ToInt32());

				hwnd = new Hwnd();
				hwnd.Queue = ThreadQueue(Thread.CurrentThread);
				hwnd.WholeWindow = FosterParent;
				hwnd.ClientWindow = FosterParent;

				// Create a HWND for RootWIndow as well, so our queue doesn't eat the events
				hwnd = new Hwnd();
				hwnd.Queue = ThreadQueue(Thread.CurrentThread);
				hwnd.whole_window = RootWindow;
				hwnd.ClientWindow = RootWindow;

				// For sleeping on the X11 socket
				listen = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
				IPEndPoint ep = new IPEndPoint(IPAddress.Loopback, 0);
				listen.Bind(ep);
				listen.Listen(1);

				// To wake up when a timer is ready
				network_buffer = new byte[10];

				wake = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
				wake.Connect(listen.LocalEndPoint);

				// Make this non-blocking, so it doesn't
				// deadlock if too many wakes are sent
				// before the wake_receive end is polled
				wake.Blocking = false;

				wake_receive = listen.Accept();

				#if __MonoCS__
				pollfds = new Pollfd [2];
				pollfds [0] = new Pollfd ();
				pollfds [0].fd = XConnectionNumber (DisplayHandle);
				pollfds [0].events = PollEvents.POLLIN;

				pollfds [1] = new Pollfd ();
				pollfds [1].fd = wake_receive.Handle.ToInt32 ();
				pollfds [1].events = PollEvents.POLLIN;
				#endif

				Keyboard = new X11Keyboard(DisplayHandle, FosterParent);
				Dnd = new X11Dnd (DisplayHandle, Keyboard);

				DoubleClickInterval = 500;

				HoverState.Interval = 500;
				HoverState.Timer = new Timer();
				HoverState.Timer.Enabled = false;
				HoverState.Timer.Interval = HoverState.Interval;
				HoverState.Timer.Tick += new EventHandler(MouseHover);
				HoverState.Size = new Size(4, 4);
				HoverState.X = -1;
				HoverState.Y = -1;

				ActiveWindow = IntPtr.Zero;
				FocusWindow = IntPtr.Zero;
				ModalWindows = new Stack(3);

				MouseState = MouseButtons.None;
				mouse_position = new Point(0, 0);

				Caret.Timer = new Timer();
				Caret.Timer.Interval = 500;		// FIXME - where should this number come from?
				Caret.Timer.Tick += new EventHandler(CaretCallback);

				SetupAtoms();

				// Grab atom changes off the root window to catch certain WM events
				XSelectInput(DisplayHandle, RootWindow, new IntPtr ((int) (EventMask.PropertyChangeMask | Keyboard.KeyEventMask)));

				// Handle any upcoming errors
				ErrorHandler = new XErrorHandler(HandleError);
				XSetErrorHandler(ErrorHandler);
			} else {
				throw new ArgumentNullException("Display", "Could not open display (X-Server required. Check your DISPLAY environment variable)");
			}
		}
コード例 #7
0
ファイル: XplatUIX11.cs プロジェクト: nlhepler/mono
		XplatUIX11()
		{
			// Handle singleton stuff first
			RefCount = 0;
			in_doevents = false;

			// Now regular initialization
			XlibLock = new object ();
			X11Keyboard.XlibLock = XlibLock;
			MessageQueues = Hashtable.Synchronized (new Hashtable(7));
			unattached_timer_list = ArrayList.Synchronized (new ArrayList (3));
			messageHold = Hashtable.Synchronized (new Hashtable(3));
			Clipboard = new ClipboardData ();
			XInitThreads();

			ErrorExceptions = false;

			// X11 Initialization
			SetDisplay(XOpenDisplay(IntPtr.Zero));
			X11DesktopColors.Initialize();

			
			// Disable keyboard autorepeat
			try {
				XkbSetDetectableAutoRepeat (DisplayHandle, true,  IntPtr.Zero);
				detectable_key_auto_repeat = true;
			} catch {
				Console.Error.WriteLine ("Could not disable keyboard auto repeat, will attempt to disable manually.");
				detectable_key_auto_repeat = false;
			}

			// Handle any upcoming errors; we re-set it here, X11DesktopColor stuff might have stolen it (gtk does)
			ErrorHandler = new XErrorHandler(HandleError);
			XSetErrorHandler(ErrorHandler);
		}
コード例 #8
0
 private static extern XErrorHandler XSetErrorHandler(XErrorHandler handler);
コード例 #9
0
ファイル: X11Display.cs プロジェクト: BrzVlad/mono
		public X11Display (IntPtr display)
		{
			if (display == IntPtr.Zero) {
				throw new ArgumentNullException("Display",
							"Could not open display (X-Server required. Check your DISPLAY environment variable)");
			}

			this.display = display;

			// Debugging support
			if (Environment.GetEnvironmentVariable ("MONO_XSYNC") != null) {
				Xlib.XSynchronize (display, true);
			}

			if (Environment.GetEnvironmentVariable ("MONO_XEXCEPTIONS") != null) {
				ErrorExceptions = true;
			}

			atoms = new X11Atoms (this);

			DoubleClickInterval = 500;

			HoverState.Interval = 500;
			HoverState.Timer = new Timer();
			HoverState.Timer.Enabled = false;
			HoverState.Timer.Interval = HoverState.Interval;
			HoverState.Timer.Tick += new EventHandler(MouseHover);
			HoverState.Size = new Size(4, 4);
			HoverState.X = -1;
			HoverState.Y = -1;

			ActiveWindow = null;
			FocusWindow = null;
			ModalWindows = new Stack(3);

			MouseState = MouseButtons.None;
			MousePosition = new Point(0, 0);

			Caret.Timer = new Timer();
			Caret.Timer.Interval = 500;		// FIXME - where should this number come from?
			Caret.Timer.Tick += new EventHandler(CaretCallback);

			// XXX multiscreen work here
			root_hwnd = new X11RootHwnd (this, Xlib.XRootWindow (display, DefaultScreen));

			// XXX do we need a per-screen foster parent?
			// Create the foster parent
			foster_hwnd = new X11Hwnd (this,
						   Xlib.XCreateSimpleWindow (display, root_hwnd.WholeWindow,
									     0, 0, 1, 1, 4, UIntPtr.Zero, UIntPtr.Zero));

			pollfds = new Pollfd [1];
			pollfds [0] = new Pollfd ();
			pollfds [0].fd = Xlib.XConnectionNumber (display);
			pollfds [0].events = PollEvents.POLLIN;

			Keyboard = new X11Keyboard(display, foster_hwnd.Handle);
			Dnd = new X11Dnd (display, Keyboard);

			ErrorExceptions = false;

			// Handle any upcoming errors
			ErrorHandler = new XErrorHandler (HandleError);
			Xlib.XSetErrorHandler (ErrorHandler);

			X11DesktopColors.Initialize(); // XXX we need to figure out how to make this display specific?

			// Disable keyboard autorepeat
			try {
				Xlib.XkbSetDetectableAutoRepeat (display, true, IntPtr.Zero);
				detectable_key_auto_repeat = true;
			} catch {
				Console.Error.WriteLine ("Could not disable keyboard auto repeat, will attempt to disable manually.");
				detectable_key_auto_repeat = false;
			}

			// we re-set our error handler here, X11DesktopColor stuff might have stolen it (gtk does)
			Xlib.XSetErrorHandler (ErrorHandler);

			// create our event thread (just sits on the X socket waiting for events)
			event_thread = new Thread (new ThreadStart (XEventThread));
			event_thread.IsBackground = true;
			event_thread.Start ();
		}
コード例 #10
0
ファイル: X11.cs プロジェクト: WatsonSileti/Avalonia
 public static extern IntPtr XSetErrorHandler(XErrorHandler handler);
コード例 #11
0
ファイル: Program.cs プロジェクト: K-Library-NET/dotNET
 internal static extern IntPtr XSetErrorHandler(XErrorHandler error_handler);
コード例 #12
0
ファイル: XplatUIX11GTK.cs プロジェクト: BrzVlad/mono
		// native X display handle
		internal void SetDisplay (IntPtr display_handle)
		{
			if (display_handle != IntPtr.Zero) {
				Hwnd	hwnd;
				
				if ((GdkDisplayHandle != IntPtr.Zero) && (GdkFosterParent != IntPtr.Zero)) {
					hwnd = Hwnd.ObjectFromHandle (gdk_x11_drawable_get_xid (GdkFosterParent));
					gdk_window_destroy (GdkFosterParent);
					hwnd.Dispose ();
				}
				
				if (GdkDisplayHandle != IntPtr.Zero) {
					gdk_display_close (GdkDisplayHandle);
				}
				
				DisplayHandle = display_handle;
				GdkDisplayHandle = gdk_x11_lookup_xdisplay (display_handle);
				
				// We need to tell System.Drawing our DisplayHandle. FromHdcInternal has
				// been hacked to do this for us.
				Graphics.FromHdcInternal (DisplayHandle);
				
				// Debugging support
				if (Environment.GetEnvironmentVariable ("MONO_XSYNC") != null) {
					XSynchronize (DisplayHandle, true);					
				}
				
				if (Environment.GetEnvironmentVariable ("MONO_XEXCEPTIONS") != null) {
					ErrorExceptions = true;
				}
				
				// Generic X11 setup
				GdkScreen = gdk_screen_get_default ();
				// or gdk_x11_get_default_screen
				ScreenNo = gdk_screen_get_number (GdkScreen);
				GdkRootWindow = gdk_get_default_root_window ();
				RootWindow = gdk_x11_drawable_get_xid (GdkRootWindow);
				GdkDefaultColormap = gdk_colormap_get_system ();
				DefaultColormap = gdk_x11_colormap_get_xcolormap (GdkDefaultColormap);
				
				VisualBestDepth = gdk_visual_get_best_depth ();
				//Console.WriteLine (VisualBestDepth);
				
				// Create the foster parent
				FosterParent = XCreateSimpleWindow (DisplayHandle, RootWindow, 0, 0, 1, 1, 4, 0, 0);
				GdkFosterParent = gdk_window_foreign_new (FosterParent);
				
				if (GdkFosterParent == IntPtr.Zero) {
					Console.WriteLine ("XplatUIX11GTK Constructor failed to create FosterParent");
				}
				
				hwnd = new Hwnd ();
				
				hwnd.WholeWindow = FosterParent;
				hwnd.ClientWindow = FosterParent;
				
				// For sleeping on the X11 socket
				listen = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
				IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 0);
				listen.Bind (ep);
				listen.Listen (1);
				
				// To wake up when a timer is ready
				network_buffer = new byte [10];
				
				wake = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
				wake.Connect (listen.LocalEndPoint);
				wake_receive = listen.Accept ();
				
				pollfds = new Pollfd [2];
				pollfds [0] = new Pollfd ();
				pollfds [0].fd = XConnectionNumber (DisplayHandle);
				pollfds [0].events = PollEvents.POLLIN;

				pollfds [1] = new Pollfd ();
				pollfds [1].fd = wake_receive.Handle.ToInt32 ();
				pollfds [1].events = PollEvents.POLLIN;
				
				Keyboard = new X11Keyboard (DisplayHandle);
				Dnd = new X11Dnd (DisplayHandle);
				
				PostQuitState = false;
				
				DoubleClickInterval = 500;
				
				HoverState.Interval = 500;
				HoverState.Timer = new Timer ();
				HoverState.Timer.Enabled = false;
				HoverState.Timer.Interval = HoverState.Interval;
				HoverState.Timer.Tick += new EventHandler (MouseHover);
				HoverState.X = -1;
				HoverState.Y = -1;
				
				ActiveWindow = IntPtr.Zero;
				FocusWindow = IntPtr.Zero;
				ModalWindows = new Stack (3);
				
				MouseState = MouseButtons.None;
				MousePosition = new Point (0, 0);
				
				Caret.Timer = new Timer ();
				Caret.Timer.Interval = 500;		// FIXME - where should this number come from?
				Caret.Timer.Tick += new EventHandler (CaretCallback);
				
				SetupAtoms ();
				
				// Grab atom changes off the root window to catch certain WM events
				gdk_window_set_events (GdkRootWindow, (int)GdkEventMask.GDK_PROPERTY_CHANGE_MASK);
				
				// Handle any upcoming errors
				ErrorHandler = new XErrorHandler (HandleError);
				XSetErrorHandler (ErrorHandler);
			} else {
				throw new ArgumentNullException ("Display", "Could not open display (X-Server required. Check your DISPLAY environment variable)");
			}
		}
コード例 #13
0
ファイル: XplatUIX11GTK.cs プロジェクト: BrzVlad/mono
		private XplatUIX11GTK ()
		{
			Console.WriteLine ("XplatUIX11GTK ctor...");
			// Handle singleton stuff first
			RefCount = 0;
			
			// init gdk
			gdk_init_check (IntPtr.Zero, IntPtr.Zero);
			
			// Now regular initialization
			XlibLock = new object ();
			MessageQueue = new XEventQueue ();
			TimerList = new ArrayList ();
			XInitThreads ();
			
			ErrorExceptions = false;
			
			// X11 Initialization
			SetDisplay (gdk_x11_display_get_xdisplay (gdk_display_get_default ()));
			X11DesktopColors.Initialize ();
			
			// Handle any upcoming errors; we re-set it here, X11DesktopColor stuff might have stolen it (gtk does)
			ErrorHandler = new XErrorHandler (HandleError);
			XSetErrorHandler (ErrorHandler);
		}
コード例 #14
0
 internal static extern IntPtr XSetErrorHandler(XErrorHandler error_handler);
コード例 #15
0
 internal extern static IntPtr XSetErrorHandler(XErrorHandler error_handler);
コード例 #16
0
ファイル: Functions.cs プロジェクト: White-Wolf/Minesharp
 public extern static IntPtr XSetErrorHandler(XErrorHandler error_handler);
コード例 #17
0
ファイル: Functions.cs プロジェクト: luislasonbra/PixelFarm
 public extern static IntPtr XSetErrorHandler(XErrorHandler error_handler);
コード例 #18
0
        /// <summary>
        /// Gets a value indicating whether the window is valid.
        /// </summary>
        /// <param name="window">The pointer to the window.</param>
        /// <returns><see langword="true"/> if the window is valid; otherwise, <see langword="false"/>.</returns>
        internal static bool IsWindowValid(IntPtr window)
        {
            bool validWindow = false;
            XWindowAttributes attributes = new XWindowAttributes();
            XErrorHandler handler = new XErrorHandler(IgnoreBadWindowHandler);
            originalEventHandler = XSetErrorHandler(handler);
            using (XServerConnection serverConnection = new XServerConnection())
            {
                validWindow = XGetWindowAttributes(serverConnection.Display, window, out attributes) != 0;
            }

            XSetErrorHandler(originalEventHandler);
            originalEventHandler = null;
            return validWindow;
        }