FlafyDev / wayland_shell

MIT License
1 stars 1 forks source link

Set layer anchors/general setup #2

Open darkwater opened 1 month ago

darkwater commented 1 month ago

Excerpt from my main_application.cc:

  gtk_layer_init_for_window(window);
  gtk_layer_set_namespace(window, "fdls");
  gtk_layer_set_keyboard_mode(window, GTK_LAYER_SHELL_KEYBOARD_MODE_NONE);
  gtk_layer_set_layer(window, GTK_LAYER_SHELL_LAYER_TOP);
  gtk_layer_set_anchor(window, GTK_LAYER_SHELL_EDGE_TOP, TRUE);
  gtk_layer_set_anchor(window, GTK_LAYER_SHELL_EDGE_RIGHT, TRUE);
  gtk_layer_set_anchor(window, GTK_LAYER_SHELL_EDGE_BOTTOM, TRUE);
  gtk_layer_set_anchor(window, GTK_LAYER_SHELL_EDGE_LEFT, TRUE);
  gtk_layer_set_exclusive_edge(window, GTK_LAYER_SHELL_EDGE_BOTTOM);

We need to figure out how to let users configure these things:

  1. Namespace
  2. Layer (top/bottom/etc)
  3. Anchors
  4. Exclusive edge (also see #4)
  5. Keyboard mode (also see #3)

I think it makes sense to have a sort of initialization method to confiugre these things, like:

WaylandShell.initialize(
  namespace: "bar",
  layer: WaylandShellLayer.top,
  anchors: { WaylandShellEdge.bottom, ... },
  exclusiveEdge: WaylandShellEdge.bottom,
  keyboardInteractivity: WaylandShellKeyboardInteractivity.onDemand,
);

Of course, it should also be possible to change these later, with separate methods. Or maybe the user should just call all relevant methods individually? I like the idea of having an init function that gives some guidance in the form of "you can set these things" but that would result in a bunch of duplication in the library/API.

FlafyDev commented 1 month ago

Yeah I think it's good to have an initialize function with all the layer shell apis as parameters (in addition to individual methods to call while the program is running)

The default values for initialize can be to make the app fullscreen

darkwater commented 1 month ago

I think it makes sense for the default to be no anchors, that will make the window float in the center (at least on Hyprland), which makes sense for eg. a program launcher