Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bitsdojo_window_linux/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 0.1.5
- Fix: #267 Gdk-CRITICAL warnings on mouse events
## 0.1.4
- Various fixes to work with latest Flutter version
## 0.1.3
Expand Down
4 changes: 3 additions & 1 deletion bitsdojo_window_linux/linux/gtk_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,14 @@ void getScaleFactorForWindow(GtkWindow *window, gint *scaleFactor) {
*scaleFactor = gdk_monitor_get_scale_factor(monitor);
}

void emitMouseMoveEvent(GtkWidget* widget, int x, int y) {
void emitMouseMoveEvent(GtkWidget* widget, int x, int y, GdkDevice *device) {
auto event = (GdkEventButton *)gdk_event_new(GDK_MOTION_NOTIFY);
event->type = GDK_MOTION_NOTIFY;
event->x = x;
event->y = y;
event->time = g_get_monotonic_time();
event->device = device;

gboolean result;
g_signal_emit_by_name(widget, "motion-notify-event", event, &result);
gdk_event_free((GdkEvent *)event);
Expand Down
2 changes: 1 addition & 1 deletion bitsdojo_window_linux/linux/gtk_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace bitsdojo_window {
void getMousePositionOnScreen(GtkWindow* window, gint* x, gint* y);
void getScreenRectForWindow(GtkWindow* window, GdkRectangle* rect);
void getScaleFactorForWindow(GtkWindow* window, gint* scaleFactor);
void emitMouseMoveEvent(GtkWidget* widget, int x, int y);
void emitMouseMoveEvent(GtkWidget* widget, int x, int y, GdkDevice *device);
} // namespace bitsdojo_window

#endif // _BDW_GTK_UTILS_
15 changes: 13 additions & 2 deletions bitsdojo_window_linux/linux/window_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,14 @@ BitsdojoWindowImpl *getAppWindowInstance() {
return _appWindow;
}

static GdkDevice* get_device(BitsdojoWindowImpl *self) {
auto window = self->handle;
auto screen = gtk_window_get_screen(window);
auto display = gdk_screen_get_display(screen);
auto seat = gdk_display_get_default_seat(display);
return gdk_seat_get_pointer(seat);
}

static gboolean onWindowEventAfter(GtkWidget *text_view, GdkEvent *event,
BitsdojoWindowImpl *self) {
if (event->type == GDK_ENTER_NOTIFY) {
Expand All @@ -252,6 +260,7 @@ static gboolean onWindowEventAfter(GtkWidget *text_view, GdkEvent *event,
newEvent->button = self->currentPressedEvent.button;
newEvent->type = GDK_BUTTON_RELEASE;
newEvent->time = g_get_monotonic_time();
newEvent->device = get_device(self);
gboolean result;
g_signal_emit_by_name(self->event_box, "button-release-event",
newEvent, &result);
Expand All @@ -263,9 +272,11 @@ static gboolean onWindowEventAfter(GtkWidget *text_view, GdkEvent *event,
self->unblockButtonPress();
gint x, y;
self->getMousePositionInsideWindow(&x, &y);
emitMouseMoveEvent(self->event_box,x, y);


emitMouseMoveEvent(self->event_box, x, y, get_device(self));
} else if (event->type == GDK_LEAVE_NOTIFY) {
emitMouseMoveEvent(self->event_box,-1, -1);
emitMouseMoveEvent(self->event_box,-1, -1, get_device(self));
} else {
// bitsdojo_window::printGdkEvent("event after", event->type);
}
Expand Down
2 changes: 1 addition & 1 deletion bitsdojo_window_linux/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: bitsdojo_window_linux
description: Linux implementation of the bitsdojo_window plugin.
version: 0.1.4
version: 0.1.5
homepage: https://www.bitsdojo.com
repository: https://github.com/bitsdojo/bitsdojo_window

Expand Down