wmww / gtk-layer-shell

A library to create panels and other desktop components for Wayland using the Layer Shell protocol
GNU General Public License v3.0
323 stars 16 forks source link

Normalize boolean values for anchors. #79

Closed alebastr closed 3 years ago

alebastr commented 3 years ago

The code in this file assumes that all true gbooleans are equal. That's not correct and it's acceptable, albeit discouraged, to assign any int value to gboolean. Of course in this case any strict equality checks in this file could fail.

Fixes auto exclusive zone when passing values other than TRUE or FALSE to gtk_layer_set_anchor.


For reference, this is how waybar code looked before I finally decided to figure out why auto exclusive zone doesn't work.

  gtk_layer_set_anchor(
      gtk_window, GTK_LAYER_SHELL_EDGE_LEFT, anchor_ & ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT);
  gtk_layer_set_anchor(
      gtk_window, GTK_LAYER_SHELL_EDGE_RIGHT, anchor_ & ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT);
  gtk_layer_set_anchor(
      gtk_window, GTK_LAYER_SHELL_EDGE_TOP, anchor_ & ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP);
  gtk_layer_set_anchor(
      gtk_window, GTK_LAYER_SHELL_EDGE_BOTTOM, anchor_ & ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM);

By opening this pull request, I agree for my modifications to be licensed under whatever licenses are indicated at the start of the files I modified

wmww commented 3 years ago

Added a test which failed before your fixand works now. Still need to look at everywhere else we assume true booleans are equal.

alebastr commented 3 years ago

IIRC, that was the only place with a real issue. There's a similar code in layer_surface_set_keyboard_interactivity, but in the worst case it could only trigger extra surface commit.