What does "Broken accounting of active state"

It seems that what triggers this warning is the following.

Say you invoke the popover with button press at position (x,y). The popover is assigned to a parent such that the popover window will fill the space between (x1,y1) and (x2,y2).

The warnings will appear If and only if x1<x<x2 and y1<y<y2.

In other words, gtk4 “accounting” assumes that the button press position is associated with the popover parent widget, which is not necessarily true.

As you can see from position popover at x,y, you cannot position the popover anywhere (say the x,y click position), but must be associated to a parent widget’s position.

How about if you force the pointer away from the (x1,y1,x2,y2) rectangle before the popup() call?

With X11 this can be done with XWarpPointer(). Does it work?

Yeah, it works. The following code will send the pointer to the right edge of the main window, but only for X11. Maybe the warning does not occur with Wayland or Win32?

#ifdef GDK_WINDOWING_X11
      GdkDisplay *displayGdk = gdk_display_get_default();
      Display *display = gdk_x11_display_get_xdisplay(displayGdk);
      GtkNative *native = gtk_widget_get_native(MainWidget);
      GdkSurface *surface = gtk_native_get_surface(native);
      Window src_w = gdk_x11_surface_get_xid (surface);
      unsigned int src_width = gtk_widget_get_width(MainWidget);
      int i = round(x);
      XWarpPointer(display, src_w, None, 0, 0, 0, 0, src_width-i, 0);        
#endif
      gtk_popover_popup(GTK_POPOVER(popover));

After reviewing details pointed to by Sid, if the gesture callback is triggered by “pressed”, then, if you do not release the button and decide to move the cursor across the (x1,y1,x2,y2) rectangle, you will get the warnings. So to avoid the warnings, set the callback to the “released” signal.

AFAICT, the warning bug only applies to popovers that are triggered by a click which does not occur over the popover’s parent widget. This especially important when the popover applies to a selection model, since in this case the code has to decide where to assign the parent of the popover, with respect to the current selected items.

1 Like