bool Ctrl::SetWndCapture() { GuiLock __; ASSERT(IsMainThread()); LLOG("SetWndCapture " << Name()); StopGrabPopup(); ReleaseWndCapture(); if(gdk_pointer_grab(gdk(), FALSE, GdkEventMask(GDK_BUTTON_RELEASE_MASK|GDK_BUTTON_PRESS_MASK|GDK_POINTER_MOTION_MASK), NULL, NULL, CurrentTime) == GDK_GRAB_SUCCESS) { grabwindow = this; return true; } return false; }
// this function will make sure that everything has been initialized. nsresult nsScreenManagerGtk :: EnsureInit() { if (mCachedScreenArray.Count() > 0) return NS_OK; #if GTK_CHECK_VERSION(2,2,0) mRootWindow = gdk_get_default_root_window(); #else mRootWindow = GDK_ROOT_PARENT(); #endif // GTK_CHECK_VERSION(2,2,0) g_object_ref(mRootWindow); // GDK_STRUCTURE_MASK ==> StructureNotifyMask, for ConfigureNotify // GDK_PROPERTY_CHANGE_MASK ==> PropertyChangeMask, for PropertyNotify gdk_window_set_events(mRootWindow, GdkEventMask(gdk_window_get_events(mRootWindow) | GDK_STRUCTURE_MASK | GDK_PROPERTY_CHANGE_MASK)); gdk_window_add_filter(mRootWindow, root_window_event_filter, this); #ifdef MOZ_X11 mNetWorkareaAtom = XInternAtom(GDK_WINDOW_XDISPLAY(mRootWindow), "_NET_WORKAREA", False); #endif return Init(); }
// this function will make sure that everything has been initialized. nsresult nsScreenManagerGtk :: EnsureInit() { if (mCachedScreenArray.Count() > 0) return NS_OK; mRootWindow = gdk_get_default_root_window(); if (!mRootWindow) { // Sometimes we don't initial X (e.g., xpcshell) return NS_OK; } g_object_ref(mRootWindow); // GDK_PROPERTY_CHANGE_MASK ==> PropertyChangeMask, for PropertyNotify gdk_window_set_events(mRootWindow, GdkEventMask(gdk_window_get_events(mRootWindow) | GDK_PROPERTY_CHANGE_MASK)); g_signal_connect(gdk_screen_get_default(), "monitors-changed", G_CALLBACK(monitors_changed), this); #ifdef MOZ_X11 gdk_window_add_filter(mRootWindow, root_window_event_filter, this); if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) mNetWorkareaAtom = XInternAtom(GDK_WINDOW_XDISPLAY(mRootWindow), "_NET_WORKAREA", False); #endif return Init(); }
void Ctrl::CaptureSync() { if(grabwindow && !gdk_pointer_is_grabbed()) { if(gdk_pointer_grab(grabwindow->gdk(), FALSE, GdkEventMask(GDK_BUTTON_RELEASE_MASK|GDK_BUTTON_PRESS_MASK|GDK_POINTER_MOTION_MASK), NULL, NULL, CurrentTime) != GDK_GRAB_SUCCESS) { grabwindow = NULL; } } }
void Ctrl::StartGrabPopup() { if(activePopup.GetCount() && !grabpopup) { Ctrl *w = activePopup[0]; if(w) { ReleaseWndCapture0(); if(gdk_pointer_grab(w->gdk(), FALSE, GdkEventMask(GDK_BUTTON_RELEASE_MASK|GDK_BUTTON_PRESS_MASK|GDK_POINTER_MOTION_MASK), NULL, NULL, CurrentTime) == GDK_GRAB_SUCCESS) grabpopup = w; } } }
void Ctrl::StartGrabPopup() { if(activePopup.GetCount() && !grabpopup) { Ctrl *w = activePopup[0]; if(w && w->IsOpen()) { ReleaseWndCapture0(); static GdkCursor *NormalArrowCursor; ONCELOCK { NormalArrowCursor = gdk_cursor_new(GDK_LEFT_PTR); } if(gdk_pointer_grab(w->gdk(), FALSE, GdkEventMask(GDK_BUTTON_RELEASE_MASK|GDK_BUTTON_PRESS_MASK|GDK_POINTER_MOTION_MASK), NULL, NormalArrowCursor, CurrentTime) == GDK_GRAB_SUCCESS) grabpopup = w; }
static gboolean gtk_window_button_press_callback(GtkWidget* widget, GdkEventButton* gdk_event, wxMiniFrame* win) { if (gdk_event->window != gtk_widget_get_window(widget)) return false; if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnScroll) return TRUE; if (win->m_isDragging) return TRUE; int style = win->GetWindowStyle(); int y = (int)gdk_event->y; int x = (int)gdk_event->x; if ((style & wxRESIZE_BORDER) && (x > win->m_width-14) && (y > win->m_height-14)) { GtkWidget *ancestor = gtk_widget_get_toplevel( widget ); GdkWindow *source = gtk_widget_get_window(widget); int org_x = 0; int org_y = 0; gdk_window_get_origin( source, &org_x, &org_y ); gtk_window_begin_resize_drag (GTK_WINDOW (ancestor), GDK_WINDOW_EDGE_SOUTH_EAST, 1, org_x + x, org_y + y, 0); return TRUE; } if (win->m_miniTitle && (style & wxCLOSE_BOX)) { if ((y > 3) && (y < 19) && (x > win->m_width-19) && (x < win->m_width-3)) { win->Close(); return TRUE; } } if (y >= win->m_miniEdge + win->m_miniTitle) return true; gdk_window_raise(gtk_widget_get_window(win->m_widget)); const GdkEventMask mask = GdkEventMask( GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON1_MOTION_MASK); #ifdef __WXGTK3__ gdk_device_grab( gdk_event->device, gdk_event->window, GDK_OWNERSHIP_NONE, false, mask, NULL, gdk_event->time); #else gdk_pointer_grab(gdk_event->window, false, mask, NULL, NULL, gdk_event->time); #endif win->m_diffX = x; win->m_diffY = y; win->m_oldX = 0; win->m_oldY = 0; win->m_isDragging = true; return TRUE; }
bool wxPopupTransientWindow::Show( bool show ) { #ifdef __WXGTK__ if (!show) { #ifdef __WXGTK3__ GdkDisplay* display = gtk_widget_get_display(m_widget); #ifdef __WXGTK4__ gdk_seat_ungrab(gdk_display_get_default_seat(display)); #else wxGCC_WARNING_SUPPRESS(deprecated-declarations) GdkDeviceManager* manager = gdk_display_get_device_manager(display); GdkDevice* device = gdk_device_manager_get_client_pointer(manager); gdk_device_ungrab(device, unsigned(GDK_CURRENT_TIME)); wxGCC_WARNING_RESTORE() #endif #else gdk_pointer_ungrab( (guint32)GDK_CURRENT_TIME ); #endif gtk_grab_remove( m_widget ); } #endif #ifdef __WXX11__ if (!show) { XUngrabPointer( wxGlobalDisplay(), CurrentTime ); } #endif #if defined( __WXMSW__ ) || defined( __WXMAC__) if (!show && m_child && m_child->HasCapture()) { m_child->ReleaseMouse(); } #endif bool ret = wxPopupWindow::Show( show ); #ifdef __WXGTK__ if (show) { gtk_grab_add( m_widget ); GdkWindow* window = gtk_widget_get_window(m_widget); #ifdef __WXGTK4__ GdkDisplay* display = gdk_window_get_display(window); GdkSeat* seat = gdk_display_get_default_seat(display); gdk_seat_grab(seat, window, GDK_SEAT_CAPABILITY_POINTER, false, NULL, NULL, NULL, 0); #else const GdkEventMask mask = GdkEventMask( GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_POINTER_MOTION_MASK); #ifdef __WXGTK3__ GdkDisplay* display = gdk_window_get_display(window); wxGCC_WARNING_SUPPRESS(deprecated-declarations) GdkDeviceManager* manager = gdk_display_get_device_manager(display); GdkDevice* device = gdk_device_manager_get_client_pointer(manager); gdk_device_grab(device, window, GDK_OWNERSHIP_NONE, true, mask, NULL, unsigned(GDK_CURRENT_TIME)); wxGCC_WARNING_RESTORE() #else gdk_pointer_grab( window, true, mask, NULL, NULL, (guint32)GDK_CURRENT_TIME ); #endif #endif // !__WXGTK4__ } #endif #ifdef __WXX11__ if (show) { Window xwindow = (Window) m_clientWindow; /* int res =*/ XGrabPointer(wxGlobalDisplay(), xwindow, True, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime ); } #endif #if defined( __WXMSW__ ) || defined( __WXMAC__) if (show && m_child) { // Assume that the mouse is outside the popup to begin with m_child->CaptureMouse(); } #endif return ret; }