Gtk4 Popup Menu on scrolled gtk canvas issue and flood of redaw events

I found an issue (not present in equivalent gtk3 code). Not sure if there is any intention, but it is annoying:

Have a scrolled window and put a large canvas inside. Then context popup a menu any where at mouse coordinates (works) – but for odd reasons this “click” always scrolls the scrolled canvas to “top left”. (case 3: below)

Any ideas?

Below the code snipped for the connected GtkGesture.

And some what related – I’d like to have a small popup window at mouse coordinates following and updating it’s contents (temporary coordinate/data display for quick inspection). I could do this in gtk3, but have not figure out a way in gtk4 yet. Any hints? (case 2: below)

Also activating popups seam to cause a crazy flood on canvas update events even nothing is changed but only over drawn by the popup. This can be very frustrating slowing down behaviors when the contents is very large and not super fast to redraw. Is there a better way to do thart?
I am drawing a potentially huge bitmap with a few text/graphical objects or annotations on top.


void ViewControl::pressed_cb (GtkGesture *gesture, int n_press, double x, double y, ViewControl *vc){
        static double mouse_pix_xy[2];
        double zf = vc->vinfo->GetZfac();
        int button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
        XSM_DEBUG_GP (DBG_L5, "PRESSED %d #%d at %g %g", button, n_press, x,y);

        // undo cairo image translation/scale:
        mouse_pix_xy[0] = (x - (double)(vc->rulewidth+vc->border/zf))/zf;
        mouse_pix_xy[1] = (y - (double)(vc->rulewidth+vc->border/zf))/zf;
        vc->tmp_xy = mouse_pix_xy; // data for foreach

        switch (button) {
        case 1:
                {
                        VObjectEvent event = { VOBJ_EV_BUTTON_1, VOBJ_EV_BUTTON_PRESS, x,y };
                        vc->tmp_event = &event;
                        vc->obj_drag_start = vc->check_on_object (&event);

                        XSM_DEBUG_GP (DBG_L5, "PRESSED BTN1 ... SETTING DRAG START = %s", vc->obj_drag_start?"TRUE":"FALSE");
                        // 1st check if mouse on editable object

                }
                break;
        case 2: // Show XYZ display
                // g_print ("BUTTON_PRESS image-pixel XY: %g, %g\n", mouse_pix_xy[0], mouse_pix_xy[1]);
                {
                        GtkWidget *menu;
                        GtkWidget *box;
                        GtkWidget *item;

                        menu = gtk_popover_new ();
                        gtk_widget_set_parent (menu, vc->canvas);
                        gtk_popover_set_has_arrow (GTK_POPOVER (menu), TRUE);
                        gtk_popover_set_pointing_to (GTK_POPOVER (menu), &(GdkRectangle){ x, y, 1, 1});
                        box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
                        gtk_popover_set_child (GTK_POPOVER (menu), box);

                        gchar *xyzi = vc->vinfo->makeXYZinfo (mouse_pix_xy[0], mouse_pix_xy[1]);
                        item = gtk_button_new_with_label (xyzi);
                        g_free (xyzi);
                        gtk_button_set_has_frame (GTK_BUTTON (item), FALSE);
                        gtk_box_append (GTK_BOX (box), item);

                        gtk_popover_popup (GTK_POPOVER (menu));
                }

                if (vc->event_filter){
                        int ix = (int)round (mouse_pix_xy[0]*vc->vinfo->GetQfac());
                        int iy = (int)round (mouse_pix_xy[1]*vc->vinfo->GetQfac());
                        vc->scan->Pixel2World (ix,iy, vc->CursorXYVt[0], vc->CursorXYVt[1]);
                        if (vc->event_filter[0] == 'P'){
                                vc->RemoveEventObjects ();
                                vc->RescanEventObjects ();
                        }
                }
                break;
        case 3: // check for object properties/action popup
                {
                        vc->tmp_object_op = NULL;
                        vc->obj_drag_start = false;

                        // 1st check if mouse on editable object
                        VObjectEvent event = { VOBJ_EV_BUTTON_3, VOBJ_EV_BUTTON_PRESS, x,y };
                        vc->pointer_coord_display = true;

                        vc->tmp_event = &event;     // data for foreach
                        //vc->tmp_xy = mouse_pix_xy; // data for foreach
                        vc->tmp_effected = 0;

                        if (vc->tmp_object_op){
                                // g_print ("CANVAS EVENT: grab mode\n");
                                if (!vc->tmp_object_op->check_event (vc->tmp_event, vc->tmp_xy))
                                        vc->tmp_object_op = NULL;
                        
                                return;
                        }

                        // Objects drawn manually
                        g_slist_foreach((GSList*) vc->gobjlist, (GFunc) ViewControl::check_obj_event, vc);

                        // Event Objects
                        g_slist_foreach((GSList*) vc->geventlist, (GFunc) ViewControl::check_obj_event, vc);

                        for (gsize i=0; i<OSD_MAX; ++i)
                                if (vc->osd_item[i])
                                        vc->check_obj_event (vc->osd_item[i], vc);

                }
                break;
        }
}