Skip to content

Commit

Permalink
cairo-gtk: Allow opacity & layer (above/below) to be set in viewport …
Browse files Browse the repository at this point in the history
…config

For example, this can be used to set the window to be transparent and
always on top:

config :hello_scenic_full, :viewport,
  name: :main_viewport,
  size: {800, 600},
  theme: :dark,
  default_scene: HelloScenicFull.Scene.Primitives,
  drivers: [
    [
      module: Scenic.Driver.Local,
      name: :local,
      window: [resizeable: false, title: "hello_scenic_full"],
      on_close: :stop_system,
      opacity: 160,
      layer: 1
    ]
  ]
  • Loading branch information
ringlej committed Oct 27, 2023
1 parent 70d2bf3 commit 7b56c74
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions c_src/device/cairo/cairo_gtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,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();
}

0 comments on commit 7b56c74

Please sign in to comment.