public static void GrabWindow(Window window)
        {
            window.GrabFocus();

            Grab.Add(window);

            Gdk.GrabStatus grabbed =
                Gdk.Pointer.Grab(window.GdkWindow, true,
                                 Gdk.EventMask.ButtonPressMask
                                 | Gdk.EventMask.ButtonReleaseMask
                                 | Gdk.EventMask.PointerMotionMask, null, null, CURRENT_TIME);

            if (grabbed == Gdk.GrabStatus.Success)
            {
                grabbed = Gdk.Keyboard.Grab(window.GdkWindow, true, CURRENT_TIME);

                if (grabbed != Gdk.GrabStatus.Success)
                {
                    Grab.Remove(window);
                    window.Destroy();
                }
            }
            else
            {
                Grab.Remove(window);
                window.Destroy();
            }
        }
Exemplo n.º 2
0
        public static Gdk.GrabStatus Grab(Gdk.Window window, bool owner_events, Gdk.EventMask event_mask, Gdk.Window confine_to, Gdk.Cursor cursor, uint time_)
        {
            int raw_ret = gdk_pointer_grab(window == null ? IntPtr.Zero : window.Handle, owner_events, (int)event_mask, confine_to == null ? IntPtr.Zero : confine_to.Handle, cursor == null ? IntPtr.Zero : cursor.Handle, time_);

            Gdk.GrabStatus ret = (Gdk.GrabStatus)raw_ret;
            return(ret);
        }
Exemplo n.º 3
0
        public static Gdk.GrabStatus Grab(Gdk.Window window, bool owner_events, uint time_)
        {
            int raw_ret = gdk_keyboard_grab(window == null ? IntPtr.Zero : window.Handle, owner_events, time_);

            Gdk.GrabStatus ret = (Gdk.GrabStatus)raw_ret;
            return(ret);
        }
Exemplo n.º 4
0
        public Gdk.GrabStatus Grab(Gdk.Window window, Gdk.SeatCapabilities capabilities, bool owner_events, Gdk.Cursor cursor, Gdk.Event evnt, Gdk.SeatGrabPrepareFunc prepare_func)
        {
            GdkSharp.SeatGrabPrepareFuncWrapper prepare_func_wrapper = new GdkSharp.SeatGrabPrepareFuncWrapper(prepare_func);
            int raw_ret = gdk_seat_grab(Handle, window == null ? IntPtr.Zero : window.Handle, (int)capabilities, owner_events, cursor == null ? IntPtr.Zero : cursor.Handle, evnt == null ? IntPtr.Zero : evnt.Handle, prepare_func_wrapper.NativeDelegate, IntPtr.Zero);

            Gdk.GrabStatus ret = (Gdk.GrabStatus)raw_ret;
            return(ret);
        }
Exemplo n.º 5
0
        private void ShowCalendar()
        {
            popup        = new Window(WindowType.Popup);
            popup.Screen = tree.Screen;

            Frame frame = new Frame();

            frame.Shadow = ShadowType.Out;
            frame.Show();

            popup.Add(frame);

            VBox box = new VBox(false, 0);

            box.Show();
            frame.Add(box);

            cal = new Calendar();
            cal.DisplayOptions = CalendarDisplayOptions.ShowHeading
                                 | CalendarDisplayOptions.ShowDayNames
                                 | CalendarDisplayOptions.ShowWeekNumbers;

            cal.KeyPressEvent      += OnCalendarKeyPressed;
            popup.ButtonPressEvent += OnButtonPressed;

            cal.Show();

            Alignment calAlignment = new Alignment(0.0f, 0.0f, 1.0f, 1.0f);

            calAlignment.Show();
            calAlignment.SetPadding(4, 4, 4, 4);
            calAlignment.Add(cal);

            box.PackStart(calAlignment, false, false, 0);

            // FIXME: Make the popup appear directly below the date
            Gdk.Rectangle allocation = tree.Allocation;
//   Gtk.Requisition req = tree.SizeRequest ();
            int x = 0, y = 0;

            tree.GdkWindow.GetOrigin(out x, out y);
//   popup.Move(x + allocation.X, y + allocation.Y + req.Height + 3);
            popup.Move(x + allocation.X, y + allocation.Y);
            popup.Show();
            popup.GrabFocus();

            Grab.Add(popup);

            Gdk.GrabStatus grabbed = Gdk.Pointer.Grab(popup.GdkWindow, true,
                                                      Gdk.EventMask.ButtonPressMask
                                                      | Gdk.EventMask.ButtonReleaseMask
                                                      | Gdk.EventMask.PointerMotionMask, null, null, CURRENT_TIME);

            if (grabbed == Gdk.GrabStatus.Success)
            {
                grabbed = Gdk.Keyboard.Grab(popup.GdkWindow,
                                            true, CURRENT_TIME);

                if (grabbed != Gdk.GrabStatus.Success)
                {
                    Grab.Remove(popup);
                    popup.Destroy();
                    popup = null;
                }
            }
            else
            {
                Grab.Remove(popup);
                popup.Destroy();
                popup = null;
            }

            cal.DaySelectedDoubleClick += OnCalendarDaySelected;
            cal.ButtonPressEvent       += OnCalendarButtonPressed;

            cal.Date = date == DateTime.MinValue ? DateTime.Now : date;
        }
Exemplo n.º 6
0
        private void ShowCalendar()
        {
            popup        = new Window(WindowType.Popup);
            popup.Screen = this.Screen;

            Frame frame = new Frame();

            frame.ShadowType = ShadowType.Out;
            frame.Show();

            popup.Add(frame);

            VBox box = new VBox(false, 0);

            box.Show();
            frame.Add(box);

            cal = new Calendar();
            cal.DisplayOptions = CalendarDisplayOptions.ShowHeading
                                 | CalendarDisplayOptions.ShowDayNames
                                 | CalendarDisplayOptions.ShowWeekNumbers;

            cal.KeyPressEvent      += OnCalendarKeyPressed;
            popup.ButtonPressEvent += OnButtonPressed;

            cal.Show();

            Alignment calAlignment = new Alignment(0.0f, 0.0f, 1.0f, 1.0f);

            calAlignment.Show();
            calAlignment.SetPadding(4, 4, 4, 4);
            calAlignment.Add(cal);

            box.PackStart(calAlignment, false, false, 0);

            int minimum_height, natural_height;

            GetPreferredHeight(out minimum_height, out natural_height);
            int x = 0, y = 0;

            Window.GetOrigin(out x, out y);
            popup.Move(x + Allocation.X, y + Allocation.Y + natural_height + 3);
            popup.Show();
            popup.GrabFocus();

            Grab.Add(popup);

            Gdk.Device event_device = Gtk.Global.CurrentEventDevice;
            if (event_device.Source == Gdk.InputSource.Mouse)
            {
                pointer  = event_device;
                keyboard = event_device.AssociatedDevice;
            }
            else
            {
                keyboard = event_device;
                pointer  = event_device.AssociatedDevice;
            }

            Gdk.GrabStatus grabbed = pointer.Grab(popup.Window, Gdk.GrabOwnership.Application, true,
                                                  Gdk.EventMask.ButtonPressMask
                                                  | Gdk.EventMask.ButtonReleaseMask
                                                  | Gdk.EventMask.PointerMotionMask, null, CURRENT_TIME);

            if (grabbed == Gdk.GrabStatus.Success)
            {
                grabbed = keyboard.Grab(popup.Window, Gdk.GrabOwnership.Application, true,
                                        Gdk.EventMask.KeyPressMask | Gdk.EventMask.KeyReleaseMask, null, CURRENT_TIME);

                if (grabbed != Gdk.GrabStatus.Success)
                {
                    Grab.Remove(popup);
                    popup.Destroy();
                    popup = null;
                }
            }
            else
            {
                Grab.Remove(popup);
                popup.Destroy();
                popup = null;
            }

            cal.DaySelectedDoubleClick += OnCalendarDaySelected;
            cal.ButtonPressEvent       += OnCalendarButtonPressed;

            cal.Date = date;
        }
Exemplo n.º 7
0
        public void ShowCalendar()
        {
            popup        = new Window(WindowType.Popup);
            popup.Screen = parent.Screen;

            Frame frame = new Frame();

            frame.Shadow = ShadowType.Out;
            frame.Show();

            popup.Add(frame);

            VBox box = new VBox(false, 0);

            box.Show();
            frame.Add(box);

            cal = new Calendar();
            cal.DisplayOptions = CalendarDisplayOptions.ShowHeading
                                 | CalendarDisplayOptions.ShowDayNames
                                 | CalendarDisplayOptions.ShowWeekNumbers;

            cal.KeyPressEvent      += OnCalendarKeyPressed;
            popup.ButtonPressEvent += OnButtonPressed;

            cal.Show();

            Alignment calAlignment = new Alignment(0.0f, 0.0f, 1.0f, 1.0f);

            calAlignment.Show();
            calAlignment.SetPadding(4, 4, 4, 4);
            calAlignment.Add(cal);

            box.PackStart(calAlignment, false, false, 0);

            //Requisition req = SizeRequest();

            parent.GdkWindow.GetOrigin(out xPos, out yPos);
//			popup.Move(x + Allocation.X, y + Allocation.Y + req.Height + 3);
            popup.Move(xPos, yPos);
            popup.Show();
            popup.GrabFocus();

            Grab.Add(popup);

            Gdk.GrabStatus grabbed = Gdk.Pointer.Grab(popup.GdkWindow, true,
                                                      Gdk.EventMask.ButtonPressMask
                                                      | Gdk.EventMask.ButtonReleaseMask
                                                      | Gdk.EventMask.PointerMotionMask, null, null, CURRENT_TIME);

            if (grabbed == Gdk.GrabStatus.Success)
            {
                grabbed = Gdk.Keyboard.Grab(popup.GdkWindow,
                                            true, CURRENT_TIME);

                if (grabbed != Gdk.GrabStatus.Success)
                {
                    Grab.Remove(popup);
                    popup.Destroy();
                    popup = null;
                }
            }
            else
            {
                Grab.Remove(popup);
                popup.Destroy();
                popup = null;
            }

            cal.DaySelected  += OnCalendarDaySelected;
            cal.MonthChanged += OnCalendarMonthChanged;

            cal.Date = date;
        }