private void PositionPopup() { int x, y; Gtk.Requisition event_box_req = event_box.SizeRequest(); Gtk.Requisition popup_req = popup.SizeRequest(); PositionWidget(popup, out x, out y, 5); int monitor = event_box.Screen.GetMonitorAtPoint(x, y); var monitor_rect = event_box.Screen.GetMonitorGeometry(monitor); x = x - (popup_req.Width / 2) + (event_box_req.Width / 2); if (x + popup_req.Width >= monitor_rect.Right - 5) { x = monitor_rect.Right - popup_req.Width - 5; } else if (x < monitor_rect.Left + 5) { x = monitor_rect.Left + 5; } popup.Move(x, y); }
private void PositionPopup() { int x, y; Gdk.Screen screen; Gdk.Rectangle area; Orientation orientation; GetGeometry(out screen, out area, out orientation); Gtk.Requisition popup_min_size, popup_natural_size; popup.GetPreferredSize(out popup_min_size, out popup_natural_size); bool on_bottom = area.Bottom + popup_natural_size.Height >= screen.Height; y = on_bottom ? area.Top - popup_natural_size.Height - 5 : area.Bottom + 5; int monitor = screen.GetMonitorAtPoint(area.Left, y); var monitor_rect = screen.GetMonitorGeometry(monitor); x = area.Left - (popup_natural_size.Width / 2) + (area.Width / 2); if (x + popup_natural_size.Width >= monitor_rect.Right - 5) { x = monitor_rect.Right - popup_natural_size.Width - 5; } else if (x < monitor_rect.Left + 5) { x = monitor_rect.Left + 5; } popup.Move(x, y); }