internal static CGSize TranslateWindowSizeToCocoaWindowSize(CreateParams cp, CGSize size)
        {
            /* From XplatUIX11
             * If this is a form with no window manager, X is handling all the border and caption painting
             * so remove that from the area (since the area we set of the window here is the part of the window
             * we're painting in only)
             */
            Form form = cp.control as Form;

            if (form != null && (form.window_manager == null || cp.IsSet(WindowExStyles.WS_EX_TOOLWINDOW)))
            {
                Hwnd.Borders borders = Hwnd.GetBorders(cp, null);
                CGSize       qsize   = size;

                qsize.Width  -= borders.left + borders.right;
                qsize.Height -= borders.top + borders.bottom;

                size = qsize;
            }

            if (size.Height == 0)
            {
                size.Height = 1;
            }
            if (size.Width == 0)
            {
                size.Width = 1;
            }
            return(size);
        }
Exemple #2
0
        public static Borders GetBorders(CreateParams cp, Menu menu)
        {
            Borders borders = new Borders();

            if (menu != null)
            {
                int menu_height = menu.Rect.Height;
                if (menu_height == 0)
                {
                    menu_height = ThemeEngine.Current.CalcMenuBarSize(GraphicsContext, menu, cp.Width);
                }
                borders.top += menu_height;
            }

            if (cp.IsSet(WindowStyles.WS_CAPTION))
            {
                int caption_height;
                if (cp.IsSet(WindowExStyles.WS_EX_TOOLWINDOW))
                {
                    caption_height = ThemeEngine.Current.ToolWindowCaptionHeight;
                }
                else
                {
                    caption_height = ThemeEngine.Current.CaptionHeight;
                }
                borders.top += caption_height;
            }

            Borders border_width = GetBorderWidth(cp);

            borders.left   += border_width.left;
            borders.right  += border_width.right;
            borders.top    += border_width.top;
            borders.bottom += border_width.bottom;

            return(borders);
        }
        internal static CGRect TranslateClientRectangleToQuartzClientRectangle(Hwnd hwnd, Control ctrl)
        {
            /* From XplatUIX11
             * If this is a form with no window manager, X is handling all the border and caption painting
             * so remove that from the area (since the area we set of the window here is the part of the window
             * we're painting in only)
             */
            var          crect = hwnd.ClientRect;
            CGRect       rect  = new CGRect(crect.X, crect.Y, crect.Width, crect.Height);
            Form         form  = ctrl as Form;
            CreateParams cp    = null;

            if (form != null)
            {
                cp = form.GetCreateParams();
            }

            if (form != null && (form.window_manager == null || cp.IsSet(WindowExStyles.WS_EX_TOOLWINDOW)))
            {
                Hwnd.Borders borders = Hwnd.GetBorders(cp, null);
                CGRect       qrect   = rect;

                qrect.Y      -= borders.top;
                qrect.X      -= borders.left;
                qrect.Width  += borders.left + borders.right;
                qrect.Height += borders.top + borders.bottom;

                rect = qrect;
            }

            if (rect.Width < 1 || rect.Height < 1)
            {
                rect.Width  = 1;
                rect.Height = 1;
                rect.X      = -5;
                rect.Y      = -5;
            }

            return(rect);
        }
Exemple #4
0
		internal static Size TranslateXWindowSizeToWindowSize (CreateParams cp, int xWidth, int xHeight)
		{
			/* 
			 * If this is a form with no window manager, X is handling all the border and caption painting
			 * so remove that from the area (since the area we set of the window here is the part of the window 
			 * we're painting in only)
			 */
			Size rect = new Size (xWidth, xHeight);
			Form form = cp.control as Form;
			if (form != null && (form.window_manager == null && !cp.IsSet (WindowExStyles.WS_EX_TOOLWINDOW))) {
				Hwnd.Borders borders = Hwnd.GetBorders (cp, null);
				Size xrect = rect;

				xrect.Width += borders.left + borders.right;
				xrect.Height += borders.top + borders.bottom;

				rect = xrect;
			}
			return rect;
		}
Exemple #5
0
		internal static Size TranslateWindowSizeToXWindowSize (CreateParams cp, Size size)
		{
			/* 
			 * If this is a form with no window manager, X is handling all the border and caption painting
			 * so remove that from the area (since the area we set of the window here is the part of the window 
			 * we're painting in only)
			 */
			Form form = cp.control as Form;
			if (form != null && (form.window_manager == null && !cp.IsSet (WindowExStyles.WS_EX_TOOLWINDOW))) {
				Hwnd.Borders borders = Hwnd.GetBorders (cp, null);
				Size xrect = size;

				xrect.Width -= borders.left + borders.right;
				xrect.Height -= borders.top + borders.bottom;

				size = xrect;
			}
			if (size.Height == 0)
				size.Height = 1;
			if (size.Width == 0)
				size.Width = 1;
			return size;
		}
Exemple #6
0
		void SetWMStyles(Hwnd hwnd, CreateParams cp) {
			MotifWmHints		mwmHints;
			MotifFunctions		functions;
			MotifDecorations	decorations;
			int[]			atoms;
			int			atom_count;
			Rectangle		client_rect;
			Form			form;
			IntPtr			window_type;
			bool			hide_from_taskbar;
			IntPtr			transient_for_parent;
			
			// Windows we manage ourselves don't need WM window styles.
			if (cp.HasWindowManager && !cp.IsSet (WindowExStyles.WS_EX_TOOLWINDOW)) {
				return;
			}

			atoms = new int[8];
			mwmHints = new MotifWmHints();
			functions = 0;
			decorations = 0;
			window_type = _NET_WM_WINDOW_TYPE_NORMAL;
			transient_for_parent = IntPtr.Zero;

			mwmHints.flags = (IntPtr)(MotifFlags.Functions | MotifFlags.Decorations);
			mwmHints.functions = (IntPtr)0;
			mwmHints.decorations = (IntPtr)0;

			form = cp.control as Form;

			if (ExStyleSet (cp.ExStyle, WindowExStyles.WS_EX_TOOLWINDOW)) {
				/* tool windows get no window manager
				   decorations.
				*/

				/* just because the window doesn't get any decorations doesn't
				   mean we should disable the functions.  for instance, without
				   MotifFunctions.Maximize, changing the windowstate to Maximized
				   is ignored by metacity. */
				functions |= MotifFunctions.Move | MotifFunctions.Resize | MotifFunctions.Minimize | MotifFunctions.Maximize;
			} else if (form != null && form.FormBorderStyle == FormBorderStyle.None) {
				/* allow borderless window to be maximized */
				functions |= MotifFunctions.All | MotifFunctions.Resize;
			} else {
				if (StyleSet (cp.Style, WindowStyles.WS_CAPTION)) {
					functions |= MotifFunctions.Move;
					decorations |= MotifDecorations.Title | MotifDecorations.Menu;
				}

				if (StyleSet (cp.Style, WindowStyles.WS_THICKFRAME)) {
					functions |= MotifFunctions.Move | MotifFunctions.Resize;
					decorations |= MotifDecorations.Border | MotifDecorations.ResizeH;
				}

				if (StyleSet (cp.Style, WindowStyles.WS_MINIMIZEBOX)) {
					functions |= MotifFunctions.Minimize;
					decorations |= MotifDecorations.Minimize;
				}

				if (StyleSet (cp.Style, WindowStyles.WS_MAXIMIZEBOX)) {
					functions |= MotifFunctions.Maximize;
					decorations |= MotifDecorations.Maximize;
				}

				if (StyleSet (cp.Style, WindowStyles.WS_SIZEBOX)) {
					functions |= MotifFunctions.Resize;
					decorations |= MotifDecorations.ResizeH;
				}

				if (ExStyleSet (cp.ExStyle, WindowExStyles.WS_EX_DLGMODALFRAME)) {
					decorations |= MotifDecorations.Border;
				}

				if (StyleSet (cp.Style, WindowStyles.WS_BORDER)) {
					decorations |= MotifDecorations.Border;
				}
			
				if (StyleSet (cp.Style, WindowStyles.WS_DLGFRAME)) {
					decorations |= MotifDecorations.Border;
				}

				if (StyleSet (cp.Style, WindowStyles.WS_SYSMENU)) {
					functions |= MotifFunctions.Close;
				}
				else {
					functions &= ~(MotifFunctions.Maximize | MotifFunctions.Minimize | MotifFunctions.Close);
					decorations &= ~(MotifDecorations.Menu | MotifDecorations.Maximize | MotifDecorations.Minimize);
					if (cp.Caption == "") {
						functions &= ~MotifFunctions.Move;
						decorations &= ~(MotifDecorations.Title | MotifDecorations.ResizeH);
					}
				}
			}

			if ((functions & MotifFunctions.Resize) == 0) {
				hwnd.fixed_size = true;
				Rectangle fixed_rectangle = new Rectangle (cp.X, cp.Y, cp.Width, cp.Height);
				SetWindowMinMax(hwnd.Handle, fixed_rectangle, fixed_rectangle.Size, fixed_rectangle.Size, cp);
			} else {
				hwnd.fixed_size = false;
			}

			mwmHints.functions = (IntPtr)functions;
			mwmHints.decorations = (IntPtr)decorations;

			DriverDebug ("SetWMStyles ({0}, {1}) functions = {2}, decorations = {3}", hwnd, cp, functions, decorations);

			if (cp.IsSet (WindowExStyles.WS_EX_TOOLWINDOW)) {
				// needed! map toolwindows to _NET_WM_WINDOW_TYPE_UTILITY to make newer metacity versions happy
				// and get those windows in front of their parents
				window_type = _NET_WM_WINDOW_TYPE_UTILITY;
			} else {
				window_type = _NET_WM_WINDOW_TYPE_NORMAL;
			}
			
			if (!cp.IsSet (WindowExStyles.WS_EX_APPWINDOW)) {
				hide_from_taskbar = true;
			} else if (cp.IsSet (WindowExStyles.WS_EX_TOOLWINDOW) &&  form != null && form.Parent != null && !form.ShowInTaskbar) {
				hide_from_taskbar = true;
			} else {
				hide_from_taskbar = false;
			}

			if (ExStyleSet (cp.ExStyle, WindowExStyles.WS_EX_TOOLWINDOW)) {
				if (form != null && !hwnd.reparented) {
					if (form.Owner != null && form.Owner.Handle != IntPtr.Zero) {
						Hwnd owner_hwnd = Hwnd.ObjectFromHandle (form.Owner.Handle);
						if (owner_hwnd != null)
							transient_for_parent = owner_hwnd.whole_window;
					}
				}
			} 
			if (StyleSet (cp.Style, WindowStyles.WS_POPUP) && (hwnd.parent != null) && (hwnd.parent.whole_window != IntPtr.Zero)) {
				transient_for_parent = hwnd.parent.whole_window;
			}
			
			FormWindowState current_state = GetWindowState (hwnd.Handle);
			if (current_state == (FormWindowState)(-1))
				current_state = FormWindowState.Normal;

			client_rect = TranslateClientRectangleToXClientRectangle (hwnd);

			lock (XlibLock) {
				atom_count = 0;

				atoms [0] = window_type.ToInt32 ();
				XChangeProperty (DisplayHandle, hwnd.whole_window, _NET_WM_WINDOW_TYPE, (IntPtr)Atom.XA_ATOM, 32, PropertyMode.Replace, atoms, 1);

				XChangeProperty(DisplayHandle, hwnd.whole_window, _MOTIF_WM_HINTS, _MOTIF_WM_HINTS, 32, PropertyMode.Replace, ref mwmHints, 5);

				if (transient_for_parent != IntPtr.Zero) {
					XSetTransientForHint (DisplayHandle, hwnd.whole_window, transient_for_parent);
				}

				MoveResizeWindow(DisplayHandle, hwnd.client_window, client_rect.X, client_rect.Y, client_rect.Width, client_rect.Height);

				if (hide_from_taskbar) {
					/* this line keeps the window from showing up in gnome's taskbar */
					atoms[atom_count++] = _NET_WM_STATE_SKIP_TASKBAR.ToInt32();
				}
				/* we need to add these atoms in the
				 * event we're maximized, since we're
				 * replacing the existing
				 * _NET_WM_STATE here.  If we don't
				 * add them, future calls to
				 * GetWindowState will return Normal
				 * for a window which is maximized. */
				if (current_state == FormWindowState.Maximized) {
					atoms[atom_count++] = _NET_WM_STATE_MAXIMIZED_HORZ.ToInt32();
					atoms[atom_count++] = _NET_WM_STATE_MAXIMIZED_VERT.ToInt32();
				}
				
				if (form != null && form.Modal) {
					atoms[atom_count++] = _NET_WM_STATE_MODAL.ToInt32 ();
				}
				
				XChangeProperty(DisplayHandle, hwnd.whole_window, _NET_WM_STATE, (IntPtr)Atom.XA_ATOM, 32, PropertyMode.Replace, atoms, atom_count);

				atom_count = 0;
				IntPtr[] atom_ptrs = new IntPtr[2];
				atom_ptrs[atom_count++] = WM_DELETE_WINDOW;
				if (ExStyleSet (cp.ExStyle, WindowExStyles.WS_EX_CONTEXTHELP)) {
					atom_ptrs[atom_count++] = _NET_WM_CONTEXT_HELP;
				}

				XSetWMProtocols(DisplayHandle, hwnd.whole_window, atom_ptrs, atom_count);
			}
		}
		internal static Size TranslateQuartzWindowSizeToWindowSize (CreateParams cp, int width, int height) {
			/* From XplatUIX11
			 * If this is a form with no window manager, X is handling all the border and caption painting
			 * so remove that from the area (since the area we set of the window here is the part of the window 
			 * we're painting in only)
			 */
			Size size = new Size (width, height);
			Form form = cp.control as Form;
			if (form != null && (form.window_manager == null || cp.IsSet (WindowExStyles.WS_EX_TOOLWINDOW))) {
				Hwnd.Borders borders = Hwnd.GetBorders (cp, null);
				Size qsize = size;

				qsize.Width += borders.left + borders.right;
				qsize.Height += borders.top + borders.bottom;
				
				size = qsize;
			}

			return size;
		}
Exemple #8
0
        public static Borders GetBorderWidth(CreateParams cp)
        {
            Borders border_size = new Borders();

            Size_ windowborder = ThemeEngine.Current.BorderSize; /*new Size_ (1, 1);*/ // This is the only one that can be changed from the display properties in windows.
            Size_ border       = ThemeEngine.Current.BorderStaticSize;                 /*new Size_ (1, 1);*/
            Size_ clientedge   = ThemeEngine.Current.Border3DSize;                     /*new Size_ (2, 2);*/
            Size_ thickframe   = new Size_(2 + windowborder.Width, 2 + windowborder.Height);
            Size_ dialogframe  = ThemeEngine.Current.BorderSizableSize;                /* new Size_ (3, 3);*/

            if (cp.IsSet(WindowStyles.WS_CAPTION))
            {
                border_size.Inflate(dialogframe);
            }
            else if (cp.IsSet(WindowStyles.WS_BORDER))
            {
                if (cp.IsSet(WindowExStyles.WS_EX_DLGMODALFRAME))
                {
                    if (cp.IsSet(WindowStyles.WS_THICKFRAME) && (cp.IsSet(WindowExStyles.WS_EX_STATICEDGE) || cp.IsSet(WindowExStyles.WS_EX_CLIENTEDGE)))
                    {
                        border_size.Inflate(border);
                    }
                }
                else
                {
                    border_size.Inflate(border);
                }
            }
            else if (cp.IsSet(WindowStyles.WS_DLGFRAME))
            {
                border_size.Inflate(dialogframe);
            }

            if (cp.IsSet(WindowStyles.WS_THICKFRAME))
            {
                if (cp.IsSet(WindowStyles.WS_DLGFRAME))
                {
                    border_size.Inflate(border);
                }
                else
                {
                    border_size.Inflate(thickframe);
                }
            }

            bool  only_small_border;
            Size_ small_border = Size_.Empty;

            only_small_border = cp.IsSet(WindowStyles.WS_THICKFRAME) || cp.IsSet(WindowStyles.WS_DLGFRAME);
            if (only_small_border && cp.IsSet(WindowStyles.WS_THICKFRAME) && !cp.IsSet(WindowStyles.WS_BORDER) && !cp.IsSet(WindowStyles.WS_DLGFRAME))
            {
                small_border = border;
            }

            if (cp.IsSet(WindowExStyles.WS_EX_CLIENTEDGE | WindowExStyles.WS_EX_DLGMODALFRAME))
            {
                border_size.Inflate(clientedge + (only_small_border ? small_border : dialogframe));
            }
            else if (cp.IsSet(WindowExStyles.WS_EX_STATICEDGE | WindowExStyles.WS_EX_DLGMODALFRAME))
            {
                border_size.Inflate(only_small_border ? small_border : dialogframe);
            }
            else if (cp.IsSet(WindowExStyles.WS_EX_STATICEDGE | WindowExStyles.WS_EX_CLIENTEDGE))
            {
                border_size.Inflate(border + (only_small_border ? Size_.Empty : clientedge));
            }
            else
            {
                if (cp.IsSet(WindowExStyles.WS_EX_CLIENTEDGE))
                {
                    border_size.Inflate(clientedge);
                }
                if (cp.IsSet(WindowExStyles.WS_EX_DLGMODALFRAME) && !cp.IsSet(WindowStyles.WS_DLGFRAME))
                {
                    border_size.Inflate(cp.IsSet(WindowStyles.WS_THICKFRAME) ? border : dialogframe);
                }
                if (cp.IsSet(WindowExStyles.WS_EX_STATICEDGE))
                {
                    if (cp.IsSet(WindowStyles.WS_THICKFRAME) || cp.IsSet(WindowStyles.WS_DLGFRAME))
                    {
                        border_size.Inflate(new Size_(-border.Width, -border.Height));
                    }
                    else
                    {
                        border_size.Inflate(border);
                    }
                }
            }

            return(border_size);
        }
Exemple #9
0
		public static Borders GetBorders (CreateParams cp, Menu menu)
		{

			Borders borders = new Borders ();

			if (menu != null) {
				int menu_height = menu.Rect.Height;
				if (menu_height == 0)
					menu_height = ThemeEngine.Current.CalcMenuBarSize (GraphicsContext, menu, cp.Width);
				borders.top += menu_height;
			}
			
			if (cp.IsSet (WindowStyles.WS_CAPTION)) {
				int caption_height;
				if (cp.IsSet (WindowExStyles.WS_EX_TOOLWINDOW)) {
					caption_height = ThemeEngine.Current.ToolWindowCaptionHeight;
				} else {
					caption_height = ThemeEngine.Current.CaptionHeight;
				}
				borders.top += caption_height;
			}

			Borders border_width = GetBorderWidth (cp);

			borders.left += border_width.left;
			borders.right += border_width.right;
			borders.top += border_width.top;
			borders.bottom += border_width.bottom;
			
			return borders;
		}
Exemple #10
0
		public static Borders GetBorderWidth (CreateParams cp)
		{
			Borders border_size = new Borders ();

			Size windowborder = ThemeEngine.Current.BorderSize; /*new Size (1, 1);*/ // This is the only one that can be changed from the display properties in windows.
			Size border = ThemeEngine.Current.BorderStaticSize; /*new Size (1, 1);*/
			Size clientedge = ThemeEngine.Current.Border3DSize; /*new Size (2, 2);*/
			Size thickframe = new Size (2 + windowborder.Width, 2 + windowborder.Height);
			Size dialogframe = ThemeEngine.Current.BorderSizableSize; /* new Size (3, 3);*/
			
			if (cp.IsSet (WindowStyles.WS_CAPTION)) {
				border_size.Inflate (dialogframe);
			} else if (cp.IsSet (WindowStyles.WS_BORDER)) {
				if (cp.IsSet (WindowExStyles.WS_EX_DLGMODALFRAME)) {
					if (cp.IsSet (WindowStyles.WS_THICKFRAME) && (cp.IsSet (WindowExStyles.WS_EX_STATICEDGE) || cp.IsSet (WindowExStyles.WS_EX_CLIENTEDGE))) {
						border_size.Inflate (border);
					}
				} else {
					border_size.Inflate (border);
				}
			} else if (cp.IsSet (WindowStyles.WS_DLGFRAME)) {
				border_size.Inflate (dialogframe);
			}

			if (cp.IsSet (WindowStyles.WS_THICKFRAME)) {
				if (cp.IsSet (WindowStyles.WS_DLGFRAME)) {
					border_size.Inflate (border);
				} else {
					border_size.Inflate (thickframe);
				}
			}

			bool only_small_border;
			Size small_border = Size.Empty;

			only_small_border = cp.IsSet (WindowStyles.WS_THICKFRAME) || cp.IsSet (WindowStyles.WS_DLGFRAME);
			if (only_small_border && cp.IsSet (WindowStyles.WS_THICKFRAME) && !cp.IsSet (WindowStyles.WS_BORDER) && !cp.IsSet (WindowStyles.WS_DLGFRAME)) {
				small_border = border;
			}

			if (cp.IsSet (WindowExStyles.WS_EX_CLIENTEDGE | WindowExStyles.WS_EX_DLGMODALFRAME)) {
				border_size.Inflate (clientedge + (only_small_border ? small_border : dialogframe));
			} else if (cp.IsSet (WindowExStyles.WS_EX_STATICEDGE | WindowExStyles.WS_EX_DLGMODALFRAME)) {
				border_size.Inflate (only_small_border ? small_border : dialogframe);
			} else if (cp.IsSet (WindowExStyles.WS_EX_STATICEDGE | WindowExStyles.WS_EX_CLIENTEDGE)) {
				border_size.Inflate (border + (only_small_border ? Size.Empty : clientedge));
			} else {
				if (cp.IsSet (WindowExStyles.WS_EX_CLIENTEDGE)) {
					border_size.Inflate (clientedge);
				}
				if (cp.IsSet (WindowExStyles.WS_EX_DLGMODALFRAME) && !cp.IsSet (WindowStyles.WS_DLGFRAME)) {
					border_size.Inflate (cp.IsSet (WindowStyles.WS_THICKFRAME) ? border : dialogframe);
				}
				if (cp.IsSet (WindowExStyles.WS_EX_STATICEDGE)) {
					if (cp.IsSet (WindowStyles.WS_THICKFRAME) || cp.IsSet (WindowStyles.WS_DLGFRAME)) {
						border_size.Inflate (new Size (-border.Width, -border.Height));
					} else {
						border_size.Inflate (border);
					}
				}
			}
			
			return border_size;
		}