Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] GTK 4 - Release signal not works for button 1 in GestureClick #1043

Closed
qarmin opened this issue May 21, 2022 · 1 comment
Closed

[BUG] GTK 4 - Release signal not works for button 1 in GestureClick #1043

qarmin opened this issue May 21, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@qarmin
Copy link

qarmin commented May 21, 2022

Ubuntu 22.04, GTK 4.6.2, GTK-rs 0.4.7

Bug description

When trying to connect to button/gestureclick release button I found that this button never works.
Also strange that in provided example, pressed/released signal works both only in ~50% situations, some clicks not emit properly pressed/released signal

Example output of minimal project(missing lines with RELEASE 1 )

PRESSED 1 - GestureClick { inner: ObjectRef { inner: 0x556c577be3f0, type: GtkGestureClick } } - 1 - 220.236328125 - 149.73251342773438
PRESSED 1 - GestureClick { inner: ObjectRef { inner: 0x556c577be3f0, type: GtkGestureClick } } - 1 - 112.19646453857422 - 166.01904296875
PRESSED 1 - GestureClick { inner: ObjectRef { inner: 0x556c577be3f0, type: GtkGestureClick } } - 1 - 112.19646453857422 - 166.01904296875
PRESSED 2 - GestureClick { inner: ObjectRef { inner: 0x556c577be3f0, type: GtkGestureClick } } - 1 - 138.84469604492188 - 224.26025390625
RELEASED 2 - GestureClick { inner: ObjectRef { inner: 0x556c577be3f0, type: GtkGestureClick } } - 1 - 138.84469604492188 - 224.26025390625
PRESSED 2 - GestureClick { inner: ObjectRef { inner: 0x556c577be3f0, type: GtkGestureClick } } - 1 - 143.7550811767578 - 217.5904541015625
RELEASED 2 - GestureClick { inner: ObjectRef { inner: 0x556c577be3f0, type: GtkGestureClick } } - 1 - 143.7550811767578 - 217.5904541015625
PRESSED 2 - GestureClick { inner: ObjectRef { inner: 0x556c577be3f0, type: GtkGestureClick } } - 1 - 143.7550811767578 - 217.5904541015625
RELEASED 2 - GestureClick { inner: ObjectRef { inner: 0x556c577be3f0, type: GtkGestureClick } } - 1 - 143.7550811767578 - 217.5904541015625
PRESSED 3 - GestureClick { inner: ObjectRef { inner: 0x556c577be3f0, type: GtkGestureClick } } - 1 - 148.2012939453125 - 170.17926025390625
RELEASED 3 - GestureClick { inner: ObjectRef { inner: 0x556c577be3f0, type: GtkGestureClick } } - 1 - 149.10012817382813 - 169.28042602539063
PRESSED 3 - GestureClick { inner: ObjectRef { inner: 0x556c577be3f0, type: GtkGestureClick } } - 1 - 158.7550506591797 - 167.16534423828125
RELEASED 3 - GestureClick { inner: ObjectRef { inner: 0x556c577be3f0, type: GtkGestureClick } } - 1 - 158.7550506591797 - 167.16534423828125
PRESSED 3 - GestureClick { inner: ObjectRef { inner: 0x556c577be3f0, type: GtkGestureClick } } - 1 - 158.7550506591797 - 167.16534423828125
RELEASED 3 - GestureClick { inner: ObjectRef { inner: 0x556c577be3f0, type: GtkGestureClick } } - 1 - 158.7550506591797 - 167.16534423828125
PRESSED 3 - GestureClick { inner: ObjectRef { inner: 0x556c577be3f0, type: GtkGestureClick } } - 2 - 160.63632202148438 - 165.28408813476563
RELEASED 3 - GestureClick { inner: ObjectRef { inner: 0x556c577be3f0, type: GtkGestureClick } } - 2 - 160.63632202148438 - 165.28408813476563
PRESSED 3 - GestureClick { inner: ObjectRef { inner: 0x556c577be3f0, type: GtkGestureClick } } - 3 - 160.63632202148438 - 165.28408813476563
RELEASED 3 - GestureClick { inner: ObjectRef { inner: 0x556c577be3f0, type: GtkGestureClick } } - 3 - 160.63632202148438 - 165.28408813476563

Code

use gtk4::prelude::*;

struct GuiData {
    window : gtk4::ApplicationWindow,
    button : gtk4::Button,
    gc_button: gtk4::GestureClick
}
impl GuiData {
    pub fn new_with_application(application: &gtk4::Application) -> Self{
    let window = gtk4::ApplicationWindow::new(application);


        let button =  gtk4::Button::with_label("TEST");
        let gc_button =  gtk4::GestureClick::new();
        button.add_controller(&gc_button);

        window.set_child(Some(&button));
        window.set_default_size(300, 300);

        GuiData{
            window,
            button,
            gc_button
        }
    }
}

fn main() {
    let application = gtk4::Application::builder().build();
    application.connect_activate(move |application| {
        let gui_data = GuiData::new_with_application(&application);

        gui_data.gc_button.set_button(0);
        gui_data.gc_button.connect_pressed(|a,b,c,d|{
           println!("PRESSED {} - {:?} - {} - {} - {}",a.current_button(),a,b,c,d);
        });
        gui_data.gc_button.connect_released(|a,b,c,d|{
            println!("RELEASED {} - {:?} - {} - {} - {}",a.current_button(),a,b,c,d);
        });

        gui_data.window.show();
    });
    application.run();
}
@qarmin qarmin added the bug Something isn't working label May 21, 2022
@bilelmoussaoui
Copy link
Member

That would be an upstream gtk bug, the bindings do nothing special here. Please open an issue in https://gitlab.gnome.org/GNOME/gtk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants