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

Allow opacity & layer (above/below) to be set in viewport config #58

Merged
merged 2 commits into from
Oct 28, 2023
Merged
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
23 changes: 21 additions & 2 deletions c_src/device/cairo/cairo_gtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,16 @@ static gboolean on_scroll_event(GtkWidget* widget,
{
float x = floorf(event->x);
float y = floorf(event->y);
float xoffset = floorf(event->delta_x);
float yoffset = floorf(event->delta_y);
float xoffset = 0.0;
float yoffset = 0.0;

switch (event->direction) {
case GDK_SCROLL_UP: yoffset = -1.0; break;
case GDK_SCROLL_DOWN: yoffset = 1.0; break;
case GDK_SCROLL_LEFT: xoffset = 1.0; break;
case GDK_SCROLL_RIGHT: xoffset = -1.0; break;
case GDK_SCROLL_SMOOTH: return FALSE;
}
send_scroll(xoffset, yoffset, x, y);

return TRUE;
Expand Down Expand Up @@ -271,5 +279,16 @@ void device_loop(driver_data_t* p_data)
g_set_printerr_handler(glib_error);

gtk_widget_show_all((GtkWidget*)g_cairo_gtk.window);

gtk_widget_set_opacity(GTK_WIDGET(g_cairo_gtk.window), (g_opts.global_opacity / 255.0f));

if (g_opts.layer > 0) {
gtk_window_set_keep_above(GTK_WINDOW(g_cairo_gtk.window), TRUE);
}

if (g_opts.layer < 0) {
gtk_window_set_keep_below(GTK_WINDOW(g_cairo_gtk.window), TRUE);
}

gtk_main();
}