// Constructor.  Called from the "Screen" class.
	internal RootWindow(Display dpy, Screen screen, XWindow handle)
			: base(dpy, screen, DrawableKind.Widget, null)
			{
				// Set this window's handle and add it to the handle map.
				this.handle = (XDrawable)handle;
				if(dpy.handleMap == null)
				{
					dpy.handleMap = new HandleMap();
				}
				dpy.handleMap[handle] = this;

				// Adjust the root window object to match the screen state.
				width = (int)(Xlib.XWidthOfScreen(screen.screen));
				height = (int)(Xlib.XHeightOfScreen(screen.screen));
				mapped = true;
				autoMapChildren = false;

				// Get the current state of the RESOURCE_MANAGER property.
				// We extract color theme information from it.
				resourceManager = Xlib.XInternAtom
					(dpy.dpy, "RESOURCE_MANAGER", XBool.False);
				IntPtr resptr = Xlib.XSharpGetResources(dpy.dpy, handle);
				if(resptr != IntPtr.Zero)
				{
					resources = Marshal.PtrToStringAnsi(resptr);
					Xlib.XSharpFreeResources(resptr);
				}

				// Select for property notifications so that we can
				// track changes to the RESOURCE_MANAGER property.
				SelectInput(EventMask.PropertyChangeMask);
			}
Exemple #2
0
        // Constructor.  Called from the "Screen" class.
        internal RootWindow(Display dpy, Screen screen, XWindow handle)
            : base(dpy, screen, DrawableKind.Widget, null)
        {
            // Set this window's handle and add it to the handle map.
            this.handle = (XDrawable)handle;
            if (dpy.handleMap == null)
            {
                dpy.handleMap = new HandleMap();
            }
            dpy.handleMap[handle] = this;

            // Adjust the root window object to match the screen state.
            width           = (int)(Xlib.XWidthOfScreen(screen.screen));
            height          = (int)(Xlib.XHeightOfScreen(screen.screen));
            mapped          = true;
            autoMapChildren = false;

            // Get the current state of the RESOURCE_MANAGER property.
            // We extract color theme information from it.
            resourceManager = Xlib.XInternAtom
                                  (dpy.dpy, "RESOURCE_MANAGER", XBool.False);
            IntPtr resptr = Xlib.XSharpGetResources(dpy.dpy, handle);

            if (resptr != IntPtr.Zero)
            {
                resources = Marshal.PtrToStringAnsi(resptr);
                Xlib.XSharpFreeResources(resptr);
            }

            // Select for property notifications so that we can
            // track changes to the RESOURCE_MANAGER property.
            SelectInput(EventMask.PropertyChangeMask);
        }
Exemple #3
0
 /// <summary>
 /// <para>Construct a new clipboard, associated with a particular
 /// screen and selection name.</para>
 /// </summary>
 ///
 /// <param name="screen">
 /// <para>The screen to attach the clipboard to, or <see langword="null"/>
 /// to use the default screen.</para>
 /// </param>
 ///
 /// <param name="name">
 /// <para>The name of the selection to use for clipboard access.
 /// This is usually <c>PRIMARY</c> for the X selection or
 /// <c>CLIPBOARD</c> for the explicit copy/cut/paste clipboard.</para>
 /// </param>
 ///
 /// <exception cref="T:System.ArgumentNullException">
 /// <para>The <paramref name="name"/> parameter is
 /// <see langword="null"/>.</para>
 /// </exception>
 public Clipboard(Screen screen, String name)
     : base(TopLevelWindow.GetRoot(screen), -1, -1, 1, 1)
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     try
     {
         IntPtr display = dpy.Lock();
         this.name = Xlib.XInternAtom
                         (display, name, XBool.False);
         this.targets = Xlib.XInternAtom
                            (display, "TARGETS", XBool.False);
     }
     finally
     {
         dpy.Unlock();
     }
 }
	/// <summary>
	/// <para>Construct a new clipboard, associated with a particular
	/// screen and selection name.</para>
	/// </summary>
	///
	/// <param name="screen">
	/// <para>The screen to attach the clipboard to, or <see langword="null"/>
	/// to use the default screen.</para>
	/// </param>
	///
	/// <param name="name">
	/// <para>The name of the selection to use for clipboard access.
	/// This is usually <c>PRIMARY</c> for the X selection or
	/// <c>CLIPBOARD</c> for the explicit copy/cut/paste clipboard.</para>
	/// </param>
	///
	/// <exception cref="T:System.ArgumentNullException">
	/// <para>The <paramref name="name"/> parameter is
	/// <see langword="null"/>.</para>
	/// </exception>
	public Clipboard(Screen screen, String name)
			: base(TopLevelWindow.GetRoot(screen), -1, -1, 1, 1)
			{
				if(name == null)
				{
					throw new ArgumentNullException("name");
				}
				try
				{
					IntPtr display = dpy.Lock();
					this.name = Xlib.XInternAtom
						(display, name, XBool.False);
					this.targets = Xlib.XInternAtom
						(display, "TARGETS", XBool.False);
				}
				finally
				{
					dpy.Unlock();
				}
			}
	extern public static int XConvertSelection
			(IntPtr display, XAtom selection, XAtom target,
			 XAtom property, XWindow requestor, XTime time);
Exemple #6
0
 int sendXMessage(XWindow w, XAtom a, long mask, long x)
 {
     return(0);
 }
Exemple #7
0
        public Mini(string[] args)
        {
            if (args.Length > 0)
            {
                if (args[0].Equals("--version"))
                {
                    Console.WriteLine(VERSION_STRING);
                    Environment.Exit(0);
                }
            }

            XGCValues            gv;
            XSetWindowAttributes sattr;

            focused_client = null;
            focus_model    = DEFAULT_FOCUS_MODEL;

            //  for (int i = 0; i < argc; i++)
            //    command_line = command_line + argv[i] + " ";

            try {
                dpy = new XDisplay(":0");

                try {
                    font = new XFont(dpy, DEFAULT_FONT);
                } catch {
                    font = new XFont(dpy, "Fixed");
                }
            } catch (Exception e) {
                Console.WriteLine("{0} check your DISPLAY variable.", e.Message);
                Environment.Exit(-1);
            }

            XEvent ev = new XEvent(dpy);

            ev.ErrorHandlerEvent += new ErrorHandler(ErrorHandler);

            // SET UP ATOMS
            atom_wm_state        = new XAtom(dpy, "WM_STATE", false);
            atom_wm_change_state = new XAtom(dpy, "WM_CHANGE_STATE", false);
            atom_wm_protos       = new XAtom(dpy, "WM_PROTOCOLS", false);
            atom_wm_delete       = new XAtom(dpy, "WM_DELETE_WINDOW", false);
            atom_wm_takefocus    = new XAtom(dpy, "WM_TAKE_FOCUS", false);

            XSetWindowAttributes pattr = new XSetWindowAttributes();

            pattr.override_redirect = true;
            _button_proxy_win       = new XWindow(dpy, new Rectangle(-80, -80, 24, 24));
            _button_proxy_win.ChangeAttributes(XWindowAttributeFlags.CWOverrideRedirect, pattr);

            // SETUP COLORS USED FOR WINDOW TITLE BARS and WINDOW BORDERS
            fg               = new XColor(dpy, DEFAULT_FOREGROUND_COLOR);
            bg               = new XColor(dpy, DEFAULT_BACKGROUND_COLOR);
            bd               = new XColor(dpy, DEFAULT_BORDER_COLOR);
            fc               = new XColor(dpy, DEFAULT_FOCUS_COLOR);
            focused_border   = new XColor(dpy, FOCUSED_BORDER_COLOR);
            unfocused_border = new XColor(dpy, UNFOCUSED_BORDER_COLOR);

            //shape = XShapeQueryExtension(dpy, &shape_event, &dummy);

            move_curs  = new XCursor(dpy, XCursors.XC_fleur);
            arrow_curs = new XCursor(dpy, XCursors.XC_left_ptr);

            root.DefineCursor(arrow_curs);

            gv.function   = XGCFunctionMask.GXcopy;
            gv.foreground = fg.Pixel;
            gv.font       = font.FID;
            string_gc     = new XGC(dpy, root, XGCValuesMask.GCFunction | XGCValuesMask.GCForeground | XGCValuesMask.GCFont, gv);

            gv.foreground = unfocused_border.Pixel;
            unfocused_gc  = new XGC(dpy, root, XGCValuesMask.GCForeground | XGCValuesMask.GCFont, gv);

            gv.foreground    = fg.Pixel;
            focused_title_gc = new XGC(dpy, root, XGCValuesMask.GCForeground | XGCValuesMask.GCFont, gv);

            gv.foreground = bd.Pixel;
            gv.line_width = DEFAULT_BORDER_WIDTH;
            border_gc     = new XGC(dpy, root, XGCValuesMask.GCFunction | XGCValuesMask.GCForeground | XGCValuesMask.GCLineWidth, gv);

            gv.foreground     = fg.Pixel;
            gv.function       = XGCFunctionMask.GXinvert;
            gv.subwindow_mode = XSubwindowMode.IncludeInferiors;
            invert_gc         = new XGC(dpy, root, XGCValuesMask.GCForeground | XGCValuesMask.GCFunction | XGCValuesMask.GCSubwindowMode | XGCValuesMask.GCLineWidth | XGCValuesMask.GCFont, gv);

            sattr.event_mask = XEventMask.SubstructureRedirectMask | XEventMask.SubstructureNotifyMask | XEventMask.ButtonPressMask | XEventMask.ButtonReleaseMask | XEventMask.FocusChangeMask | XEventMask.EnterWindowMask | XEventMask.LeaveWindowMask | XEventMask.PropertyChangeMask | XEventMask.ButtonMotionMask;

            root.ChangeAttributes(XWindowAttributeFlags.CWEventMask, sattr);

            queryWindowTree();

            ev.KeyPressHandlerEvent         += new KeyPressHandler(handleKeyPressEvent);
            ev.ButtonPressHandlerEvent      += new ButtonPressHandler(handleButtonPressEvent);
            ev.ButtonReleaseHandlerEvent    += new ButtonReleaseHandler(handleButtonReleaseEvent);
            ev.ConfigureRequestHandlerEvent += new ConfigureRequestHandler(handleConfigureRequestEvent);
            ev.MotionNotifyHandlerEvent     += new MotionNotifyHandler(handleMotionNotifyEvent);
            ev.MapRequestHandlerEvent       += new MapRequestHandler(handleMapRequestEvent);
            ev.UnmapNotifyHandlerEvent      += new UnmapNotifyHandler(handleUnmapNotifyEvent);
            ev.DestroyNotifyHandlerEvent    += new DestroyNotifyHandler(handleDestroyNotifyEvent);
            ev.EnterNotifyHandlerEvent      += new EnterNotifyHandler(handleEnterNotifyEvent);
            ev.FocusInHandlerEvent          += new FocusInHandler(handleFocusInEvent);
            ev.FocusOutHandlerEvent         += new FocusOutHandler(handleFocusOutEvent);
            ev.PropertyNotifyHandlerEvent   += new PropertyNotifyHandler(handlePropertyNotifyEvent);
            ev.ExposeHandlerEvent           += new ExposeHandler(handleExposeEvent);
            ev.ShapeHandlerEvent            += new ShapeHandler(handleShapeEvent);
        }
Exemple #8
0
        // Constructor.
        private Display(IntPtr dpy, String displayName, Application app)
        {
            // Copy parameters in from the create process.
            this.dpy         = dpy;
            this.displayName = displayName;
            this.app         = app;

            // Create objects for each of the display screens.
            int nscreens = (int)(Xlib.XScreenCount(dpy));

            screens = new Screen [nscreens];
            for (int scr = 0; scr < nscreens; ++scr)
            {
                screens[scr] = new Screen
                                   (this, scr, Xlib.XScreenOfDisplay(dpy, scr));
            }

            // Get the index of the default screen.
            defaultScreen = (int)(Xlib.XDefaultScreen(dpy));

            // Create an array to hold the standard cursors.
            cursors = new XCursor [(int)(CursorType.XC_num_glyphs)];

            // Reset the time of the last known event.
            knownEventTime = XTime.CurrentTime;

            // Construct the window handle map if not already present.
            if (handleMap == null)
            {
                handleMap = new HandleMap();
            }

            // Initialize the standard window manager atoms that we use.
            wmProtocols = Xlib.XInternAtom
                              (dpy, "WM_PROTOCOLS", XBool.False);
            wmDeleteWindow = Xlib.XInternAtom
                                 (dpy, "WM_DELETE_WINDOW", XBool.False);
            wmTakeFocus = Xlib.XInternAtom
                              (dpy, "WM_TAKE_FOCUS", XBool.False);
            wmMwmHints = Xlib.XInternAtom
                             (dpy, "_MOTIF_WM_HINTS", XBool.False);
            wmContextHelp = Xlib.XInternAtom
                                (dpy, "_NET_WM_CONTEXT_HELP", XBool.False);
            wmState = Xlib.XInternAtom
                          (dpy, "WM_STATE", XBool.False);
            wmNetState = Xlib.XInternAtom
                             (dpy, "_NET_WM_STATE", XBool.False);
            wmPing = Xlib.XInternAtom
                         (dpy, "_NET_WM_PING", XBool.False);
            internalBeginInvoke = Xlib.XInternAtom
                                      (dpy, "INTERNAL_BEGIN_INVOKE", XBool.False);

            // Which buttons should we use for "Select" and "Menu"?
            byte[] buttons = new byte [5];
            if (Xlib.XGetPointerMapping(dpy, buttons, 5) == 3)
            {
                menuButton = ButtonName.Button3;
            }
            else
            {
                menuButton = ButtonName.Button2;
            }
            selectButton = ButtonName.Button1;

            // Construct the font map.
            fonts = new Hashtable();

            // Load the builtin bitmaps.
            bitmaps = new BuiltinBitmaps(this);
        }
	extern public static void XSetTextProperty
			(IntPtr display, XWindow w, ref XTextProperty textProp,
			 XAtom property);
Exemple #10
0
	extern public static XStatus XGetWindowProperty
			(IntPtr display, XWindow w, XAtom property,
			 int long_offset, int long_length,
			 XBool deleteProp, XAtom req_type,
			 out XAtom actual_type_return,
			 out Xlib.Xint actual_format_return,
			 out Xlib.Xulong nitems_return,
			 out Xlib.Xulong bytes_after_return,
			 out IntPtr prop_return);
Exemple #11
0
	extern public static int XDeleteProperty
			(IntPtr display, XWindow w, XAtom property);
Exemple #12
0
	extern public static int XSetSelectionOwner
			(IntPtr display, XAtom selection, XWindow owner, XTime time);
Exemple #13
0
			public extern static int XGetTextProperty(IntPtr Display, int Window, ref XTextProperty Return, XAtom Property);
Exemple #14
0
	extern public static XWindow XGetSelectionOwner
			(IntPtr display, XAtom selection);
Exemple #15
0
	extern public static XStatus XSetWMProtocols
			(IntPtr display, XWindow w, XAtom[] protocols, int count);
	// Constructor.
	private Display(IntPtr dpy, String displayName, Application app)
			{
				// Copy parameters in from the create process.
				this.dpy = dpy;
				this.displayName = displayName;
				this.app = app;

				// Create objects for each of the display screens.
				int nscreens = (int)(Xlib.XScreenCount(dpy));
				screens = new Screen [nscreens];
				for(int scr = 0; scr < nscreens; ++scr)
				{
					screens[scr] = new Screen
						(this, scr, Xlib.XScreenOfDisplay(dpy, scr));
				}

				// Get the index of the default screen.
				defaultScreen = (int)(Xlib.XDefaultScreen(dpy));

				// Create an array to hold the standard cursors.
				cursors = new XCursor [(int)(CursorType.XC_num_glyphs)];

				// Reset the time of the last known event.
				knownEventTime = XTime.CurrentTime;

				// Construct the window handle map if not already present.
				if(handleMap == null)
				{
					handleMap = new HandleMap();
				}

				// Initialize the standard window manager atoms that we use.
				wmProtocols = Xlib.XInternAtom
					(dpy, "WM_PROTOCOLS", XBool.False);
				wmDeleteWindow = Xlib.XInternAtom
					(dpy, "WM_DELETE_WINDOW", XBool.False);
				wmTakeFocus = Xlib.XInternAtom
					(dpy, "WM_TAKE_FOCUS", XBool.False);
				wmMwmHints = Xlib.XInternAtom
					(dpy, "_MOTIF_WM_HINTS", XBool.False);
				wmContextHelp = Xlib.XInternAtom
					(dpy, "_NET_WM_CONTEXT_HELP", XBool.False);
				wmState = Xlib.XInternAtom
					(dpy, "WM_STATE", XBool.False);
				wmNetState = Xlib.XInternAtom
					(dpy, "_NET_WM_STATE", XBool.False);
				wmPing = Xlib.XInternAtom
					(dpy, "_NET_WM_PING", XBool.False);
				internalBeginInvoke = Xlib.XInternAtom
					(dpy, "INTERNAL_BEGIN_INVOKE", XBool.False);

				// Which buttons should we use for "Select" and "Menu"?
				byte[] buttons = new byte [5];
				if(Xlib.XGetPointerMapping(dpy, buttons, 5) == 3)
				{
					menuButton = ButtonName.Button3;
				}
				else
				{
					menuButton = ButtonName.Button2;
				}
				selectButton = ButtonName.Button1;

				// Construct the font map.
				fonts = new Hashtable();

				// Load the builtin bitmaps.
				bitmaps = new BuiltinBitmaps(this);
			}
	// Set the WM protocols for this window.
	private void SetProtocols(IntPtr display, XWindow handle)
			{
				XAtom[] protocols = new XAtom [4];
				int numProtocols = 0;
				protocols[numProtocols++] = dpy.wmDeleteWindow;
				protocols[numProtocols++] = dpy.wmTakeFocus;
				if((otherHints & OtherHints.HelpButton) != 0)
				{
					protocols[numProtocols++] = dpy.wmContextHelp;
				}
				protocols[numProtocols++] = dpy.wmPing;
				Xlib.XSetWMProtocols(display, handle, protocols, numProtocols);
			}
	// Get the contents of a 32-bit window property.
	private Xlib.Xlong[] GetWindowProperty(XAtom name)
			{
				try
				{
					// Lock down the display and get the window handle.
					IntPtr display = dpy.Lock();
					XWindow handle = GetWidgetHandle();

					// Fetch the value of the property.
					XAtom actualTypeReturn;
					Xlib.Xint actualFormatReturn;
					Xlib.Xulong nitemsReturn;
					Xlib.Xulong bytesAfterReturn;
					IntPtr propReturn;
					nitemsReturn = Xlib.Xulong.Zero;
					if(Xlib.XGetWindowProperty
							(display, handle, name, 0, 256,
							 XBool.False, XAtom.Zero,
							 out actualTypeReturn, out actualFormatReturn,
							 out nitemsReturn, out bytesAfterReturn,
							 out propReturn) == XStatus.Zero)
					{
						if(((uint)bytesAfterReturn) > 0)
						{
							// We didn't get everything, so try again.
							if(propReturn != IntPtr.Zero)
							{
								Xlib.XFree(propReturn);
								propReturn = IntPtr.Zero;
							}
							int length = 256 + (((int)bytesAfterReturn) / 4);
							nitemsReturn = Xlib.Xulong.Zero;
							if(Xlib.XGetWindowProperty
									(display, handle, name, 0, length,
									 XBool.False, XAtom.Zero,
									 out actualTypeReturn,
									 out actualFormatReturn,
									 out nitemsReturn, out bytesAfterReturn,
									 out propReturn) != XStatus.Zero)
							{
								propReturn = IntPtr.Zero;
								nitemsReturn = Xlib.Xulong.Zero;
							}
						}
					}
					else
					{
						propReturn = IntPtr.Zero;
						nitemsReturn = Xlib.Xulong.Zero;
					}

					// Convert the property data into an array of longs.
					Xlib.Xlong[] data = new Xlib.Xlong [(int)nitemsReturn];
					int size, posn;
					unsafe
					{
						size = sizeof(Xlib.Xlong);
					}
					for(posn = 0; posn < (int)nitemsReturn; ++posn)
					{
						if(size == 4)
						{
							data[posn] = (Xlib.Xlong)
								Marshal.ReadInt32(propReturn, size * posn);
						}
						else if(size == 8)
						{
							data[posn] = (Xlib.Xlong)
								Marshal.ReadInt64(propReturn, size * posn);
						}
					}

					// Free the property data.
					if(propReturn != IntPtr.Zero)
					{
						Xlib.XFree(propReturn);
					}

					// Return the final data to the caller.
					return data;
				}
				finally
				{
					dpy.Unlock();
				}
			}
Exemple #19
0
			public extern static void XSetTextProperty(IntPtr Display, int Window, ref XTextProperty Prop, XAtom property);
Exemple #20
0
	extern public static int XChangeProperty
			(IntPtr display, XWindow w, XAtom property,
			 XAtom type, int format, int mode,
			 Xlong[] data, int nelements);