greshake / i3status-rust

Very resourcefriendly and feature-rich replacement for i3status, written in pure Rust
GNU General Public License v3.0
2.86k stars 472 forks source link

Error in focused_window #1588

Closed madhur closed 2 years ago

madhur commented 2 years ago

Error in focused_window: bad event. (Cause: invalid value: integer 4294967294, expected i32 at line 1 column 330).

I am getting this error when I click on the window created by Global Protect VPN popup.

Here is the block configuration

[[block]]
block = "focused_window"
[block.format]
full = "$title"
short = "$title"

i3status-rs 0.30.0 (commit c56a570a 2022-08-01)

ammgws commented 2 years ago

Can you run swaymsg -t get_tree and show the part for the Global Protect VPN popup?

e.g.

          "nodes": [
            {
              "id": 7,
              "type": "con",
              "orientation": "none",
              "percent": 0.5,
              "urgent": false,
              "marks": [
              ],
              "focused": true,
              "layout": "none",
              "border": "pixel",
              "current_border_width": 1,
              "rect": {
                "x": 683,
                "y": 18,
                "width": 683,
                "height": 750
              },
              "deco_rect": {
                "x": 0,
                "y": 0,
                "width": 0,
                "height": 0
              },
              "window_rect": {
                "x": 1,
                "y": 1,
                "width": 681,
                "height": 748
              },
              "geometry": {
                "x": 0,
                "y": 0,
                "width": 800,
                "height": 600
              },
              "name": "swaymsg ~",
              "window": null,
              "nodes": [
              ],
              "floating_nodes": [
              ],
              "focus": [
              ],
              "fullscreen_mode": 0,
              "sticky": false,
              "pid": 26069,
              "app_id": "Alacritty",
              "visible": true,
              "max_render_time": 0,
              "shell": "xdg_shell",
              "inhibit_idle": false,
              "idle_inhibitors": {
                "user": "none",
                "application": "none"
              }
            }
          ],
madhur commented 2 years ago

I am using i3, here is the full output when popup was open

{
  "id": 94389901464944,
  "type": "root",
  "orientation": "horizontal",
  "scratchpad_state": "none",
  "percent": null,
  "urgent": false,
  "marks": [],
  "focused": false,
  "layout": "splith",
  "workspace_layout": "default",
  "last_split_layout": "splith",
  "border": "normal",
  "current_border_width": -1,
  "rect": {
    "x": 0,
    "y": 0,
    "width": 3840,
    "height": 2160
  },
  "deco_rect": {
    "x": 0,
    "y": 0,
    "width": 0,
    "height": 0
  },
  "window_rect": {
    "x": 0,
    "y": 0,
    "width": 0,
    "height": 0
  },
  "geometry": {
    "x": 0,
    "y": 0,
    "width": 0,
    "height": 0
  },
  "name": "root",
  "window": null,
  "window_type": null,
  "nodes": [
    {
      "id": 94389901444240,
      "type": "output",
      "orientation": "none",
      "scratchpad_state": "none",
      "percent": 0.5,
      "urgent": false,
      "marks": [],
      "focused": false,
      "layout": "output",
      "workspace_layout": "default",
      "last_split_layout": "splith",
      "border": "normal",
      "current_border_width": -1,
      "rect": {
        "x": 0,
        "y": 0,
        "width": 3840,
        "height": 2160
      },
      "deco_rect": {
        "x": 0,
        "y": 0,
        "width": 0,
        "height": 0
      },
      "window_rect": {
        "x": 0,
        "y": 0,
        "width": 0,
        "height": 0
      },
      "geometry": {
        "x": 0,
        "y": 0,
        "width": 0,
        "height": 0
      },
      "name": "__i3",
      "window": null,
      "window_type": null,
      "nodes": [
        {
          "id": 94389901469024,
          "type": "con",
          "orientation": "horizontal",
          "scratchpad_state": "none",
          "percent": null,
          "urgent": false,
          "marks": [],
          "focused": false,
          "output": "__i3",
          "layout": "splith",
          "workspace_layout": "default",
          "last_split_layout": "splith",
          "border": "normal",
          "current_border_width": -1,
          "rect": {
            "x": 0,
            "y": 0,
            "width": 0,
            "height": 0
          },
          "deco_rect": {
            "x": 0,
            "y": 0,
            "width": 0,
            "height": 0
          },
          "window_rect": {
            "x": 0,
            "y": 0,
            "width": 0,
            "height": 0
          },
          "geometry": {
            "x": 0,
            "y": 0,
            "width": 0,
            "height": 0
          },
          "name": "content",
          "window": null,
          "window_type": null,
          "nodes": [
            {
              "id": 94389901472048,
              "type": "workspace",
              "orientation": "none",
              "scratchpad_state": "none",
              "percent": null,
              "urgent": false,
              "marks": [],
              "focused": false,
              "output": "__i3",
              "layout": "splith",
              "workspace_layout": "default",
              "last_split_layout": "splith",
              "border": "normal",
              "current_border_width": -1,
              "rect": {
                "x": 0,
                "y": 0,
                "width": 0,
                "height": 0
              },
              "deco_rect": {
                "x": 0,
                "y": 0,
                "width": 0,
                "height": 0
              },
              "window_rect": {
                "x": 0,
                "y": 0,
                "width": 0,
                "height": 0
              },
              "geometry": {
                "x": 0,
                "y": 0,
                "width": 0,
                "height": 0
              },
              "name": "__i3_scratch",
              "num": -1,
              "gaps": {
                "inner": 0,
                "outer": 0,
                "top": 0,
                "right": 0,
                "bottom": 0,
                "left": 0
              },
              "window": null,
              "window_type": null,
              "nodes": [],
              "floating_nodes": [],
              "focus": [],
              "fullscreen_mode": 1,
              "sticky": false,
              "floating": "auto_off",
              "swallows": []
            }
          ],
          "floating_nodes": [],
          "focus": [
            94389901472048
          ],
          "fullscreen_mode": 0,
          "sticky": false,
          "floating": "auto_off",
          "swallows": []
        }
      ],
      "floating_nodes": [],
      "focus": [
        94389901469024
      ],
      "fullscreen_mode": 0,
      "sticky": false,
      "floating": "auto_off",
      "swallows": []
    },
    {
      "id": 94389901475072,
      "type": "output",
      "orientation": "none",
      "scratchpad_state": "none",
      "percent": 0.5,
      "urgent": false,
      "marks": [],
      "focused": false,
      "layout": "output",
      "workspace_layout": "default",
      "last_split_layout": "splith",
      "border": "normal",
      "current_border_width": -1,
      "rect": {
        "x": 0,
        "y": 0,
        "width": 3840,
        "height": 2160
      },
      "deco_rect": {
        "x": 0,
        "y": 0,
        "width": 0,
        "height": 0
      },
      "window_rect": {
        "x": 0,
        "y": 0,
        "width": 0,
        "height": 0
      },
      "geometry": {
        "x": 0,
        "y": 0,
        "width": 0,
        "height": 0
      },
      "name": "DP-2",
      "window": null,
      "window_type": null,
      "nodes": [
        {
          "id": 94389901478096,
          "type": "dockarea",
          "orientation": "none",
          "scratchpad_state": "none",
          "percent": null,
          "urgent": false,
          "marks": [],
          "focused": false,
          "output": "DP-2",
          "layout": "dockarea",
          "workspace_layout": "default",
          "last_split_layout": "splith",
          "border": "normal",
          "current_border_width": -1,
          "rect": {
            "x": 0,
            "y": 0,
            "width": 3840,
            "height": 31
          },
          "deco_rect": {
            "x": 0,
            "y": 0,
            "width": 0,
            "height": 0
          },
          "window_rect": {
            "x": 0,
            "y": 0,
            "width": 0,
            "height": 0
          },
          "geometry": {
            "x": 0,
            "y": 0,
            "width": 0,
            "height": 0
          },
          "name": "topdock",
          "window": null,
          "window_type": null,
          "nodes": [
            {
              "id": 94389901368352,
              "type": "con",
              "orientation": "none",
              "scratchpad_state": "none",
              "percent": 1,
              "urgent": false,
              "marks": [],
              "focused": false,
              "output": "DP-2",
              "layout": "splith",
              "workspace_layout": "default",
              "last_split_layout": "splith",
              "border": "normal",
              "current_border_width": 3,
              "rect": {
                "x": 0,
                "y": 0,
                "width": 3840,
                "height": 31
              },
              "deco_rect": {
                "x": 0,
                "y": 0,
                "width": 0,
                "height": 0
              },
              "window_rect": {
                "x": 0,
                "y": 0,
                "width": 3840,
                "height": 31
              },
              "geometry": {
                "x": 0,
                "y": 2129,
                "width": 3840,
                "height": 31
              },
              "name": "i3bar for output DP-2",
              "window": 18874375,
              "window_type": "unknown",
              "window_properties": {
                "class": "i3bar",
                "instance": "bar-0",
                "title": "i3bar for output DP-2",
                "transient_for": null
              },
              "nodes": [],
              "floating_nodes": [],
              "focus": [],
              "fullscreen_mode": 0,
              "sticky": false,
              "floating": "auto_off",
              "swallows": []
            }
          ],
          "floating_nodes": [],
          "focus": [
            94389901368352
          ],
          "fullscreen_mode": 0,
          "sticky": false,
          "floating": "auto_off",
          "swallows": [
            {
              "dock": 2,
              "insert_where": 2
            }
          ]
        },
        {
          "id": 94389901481120,
          "type": "con",
          "orientation": "horizontal",
          "scratchpad_state": "none",
          "percent": null,
          "urgent": false,
          "marks": [],
          "focused": false,
          "output": "DP-2",
          "layout": "splith",
          "workspace_layout": "default",
          "last_split_layout": "splith",
          "border": "normal",
          "current_border_width": -1,
          "rect": {
            "x": 0,
            "y": 31,
            "width": 3840,
            "height": 2129
          },
          "deco_rect": {
            "x": 0,
            "y": 0,
            "width": 0,
            "height": 0
          },
          "window_rect": {
            "x": 0,
            "y": 0,
            "width": 0,
            "height": 0
          },
          "geometry": {
            "x": 0,
            "y": 0,
            "width": 0,
            "height": 0
          },
          "name": "content",
          "window": null,
          "window_type": null,
          "nodes": [
            {
              "id": 94389901487312,
              "type": "workspace",
              "orientation": "none",
              "scratchpad_state": "none",
              "percent": null,
              "urgent": false,
              "marks": [],
              "focused": false,
              "output": "DP-2",
              "layout": "splith",
              "workspace_layout": "default",
              "last_split_layout": "splith",
              "border": "normal",
              "current_border_width": -1,
              "rect": {
                "x": 0,
                "y": 31,
                "width": 3840,
                "height": 2129
              },
              "deco_rect": {
                "x": 0,
                "y": 0,
                "width": 0,
                "height": 0
              },
              "window_rect": {
                "x": 0,
                "y": 0,
                "width": 0,
                "height": 0
              },
              "geometry": {
                "x": 0,
                "y": 0,
                "width": 0,
                "height": 0
              },
              "name": "1",
              "num": 1,
              "gaps": {
                "inner": 0,
                "outer": 0,
                "top": 0,
                "right": 0,
                "bottom": 0,
                "left": 0
              },
              "window": null,
              "window_type": null,
              "nodes": [],
              "floating_nodes": [
                {
                  "id": 94389901004368,
                  "type": "floating_con",
                  "orientation": "horizontal",
                  "scratchpad_state": "none",
                  "percent": null,
                  "urgent": false,
                  "marks": [],
                  "focused": false,
                  "output": "DP-2",
                  "layout": "splith",
                  "workspace_layout": "default",
                  "last_split_layout": "splith",
                  "border": "normal",
                  "current_border_width": -1,
                  "rect": {
                    "x": 0,
                    "y": 30,
                    "width": 3840,
                    "height": 1663
                  },
                  "deco_rect": {
                    "x": 0,
                    "y": 0,
                    "width": 0,
                    "height": 0
                  },
                  "window_rect": {
                    "x": 0,
                    "y": 0,
                    "width": 0,
                    "height": 0
                  },
                  "geometry": {
                    "x": 0,
                    "y": 0,
                    "width": 0,
                    "height": 0
                  },
                  "name": null,
                  "window": null,
                  "window_type": null,
                  "nodes": [
                    {
                      "id": 94389901003888,
                      "type": "con",
                      "orientation": "none",
                      "scratchpad_state": "none",
                      "percent": 1,
                      "urgent": false,
                      "marks": [],
                      "focused": false,
                      "output": "DP-2",
                      "layout": "splith",
                      "workspace_layout": "default",
                      "last_split_layout": "splith",
                      "border": "pixel",
                      "current_border_width": 0,
                      "rect": {
                        "x": 0,
                        "y": 30,
                        "width": 3840,
                        "height": 1663
                      },
                      "deco_rect": {
                        "x": 0,
                        "y": 0,
                        "width": 0,
                        "height": 0
                      },
                      "window_rect": {
                        "x": 0,
                        "y": 0,
                        "width": 3840,
                        "height": 1663
                      },
                      "geometry": {
                        "x": 0,
                        "y": 30,
                        "width": 3840,
                        "height": 1663
                      },
                      "name": "Guake!",
                      "window": 27262988,
                      "window_type": "normal",
                      "window_properties": {
                        "class": "Guake",
                        "instance": "guake",
                        "title": "Guake!",
                        "transient_for": null
                      },
                      "nodes": [],
                      "floating_nodes": [],
                      "focus": [],
                      "fullscreen_mode": 0,
                      "sticky": true,
                      "floating": "auto_on",
                      "swallows": []
                    }
                  ],
                  "floating_nodes": [],
                  "focus": [
                    94389901003888
                  ],
                  "fullscreen_mode": 0,
                  "sticky": false,
                  "floating": "auto_off",
                  "swallows": []
                },
                {
                  "id": 94389901393728,
                  "type": "floating_con",
                  "orientation": "horizontal",
                  "scratchpad_state": "none",
                  "percent": null,
                  "urgent": false,
                  "marks": [],
                  "focused": false,
                  "output": "DP-2",
                  "layout": "splith",
                  "workspace_layout": "default",
                  "last_split_layout": "splith",
                  "border": "normal",
                  "current_border_width": -1,
                  "rect": {
                    "x": 3388,
                    "y": 4294967294,
                    "width": 304,
                    "height": 349
                  },
                  "deco_rect": {
                    "x": 0,
                    "y": 0,
                    "width": 0,
                    "height": 0
                  },
                  "window_rect": {
                    "x": 0,
                    "y": 0,
                    "width": 0,
                    "height": 0
                  },
                  "geometry": {
                    "x": 0,
                    "y": 0,
                    "width": 0,
                    "height": 0
                  },
                  "name": null,
                  "window": null,
                  "window_type": null,
                  "nodes": [
                    {
                      "id": 94389901004848,
                      "type": "con",
                      "orientation": "none",
                      "scratchpad_state": "none",
                      "percent": 1,
                      "urgent": false,
                      "marks": [],
                      "focused": true,
                      "output": "DP-2",
                      "layout": "splith",
                      "workspace_layout": "default",
                      "last_split_layout": "splith",
                      "border": "pixel",
                      "current_border_width": 2,
                      "rect": {
                        "x": 3388,
                        "y": 4294967294,
                        "width": 304,
                        "height": 349
                      },
                      "deco_rect": {
                        "x": 0,
                        "y": 0,
                        "width": 0,
                        "height": 0
                      },
                      "window_rect": {
                        "x": 2,
                        "y": 2,
                        "width": 300,
                        "height": 345
                      },
                      "geometry": {
                        "x": 3390,
                        "y": 0,
                        "width": 300,
                        "height": 345
                      },
                      "name": "GlobalProtect",
                      "window": 31457304,
                      "window_type": "normal",
                      "window_properties": {
                        "class": "PanGPUI",
                        "instance": "PanGPUI",
                        "title": "GlobalProtect",
                        "transient_for": null
                      },
                      "nodes": [],
                      "floating_nodes": [],
                      "focus": [],
                      "fullscreen_mode": 0,
                      "sticky": false,
                      "floating": "auto_on",
                      "swallows": []
                    }
                  ],
                  "floating_nodes": [],
                  "focus": [
                    94389901004848
                  ],
                  "fullscreen_mode": 0,
                  "sticky": false,
                  "floating": "auto_off",
                  "swallows": []
                }
              ],
              "focus": [
                94389901393728,
                94389901004368
              ],
              "fullscreen_mode": 1,
              "sticky": false,
              "floating": "auto_off",
              "swallows": []
            }
          ],
          "floating_nodes": [],
          "focus": [
            94389901487312
          ],
          "fullscreen_mode": 0,
          "sticky": false,
          "floating": "auto_off",
          "swallows": []
        },
        {
          "id": 94389901484144,
          "type": "dockarea",
          "orientation": "none",
          "scratchpad_state": "none",
          "percent": null,
          "urgent": false,
          "marks": [],
          "focused": false,
          "output": "DP-2",
          "layout": "dockarea",
          "workspace_layout": "default",
          "last_split_layout": "splith",
          "border": "normal",
          "current_border_width": -1,
          "rect": {
            "x": 0,
            "y": 2160,
            "width": 3840,
            "height": 0
          },
          "deco_rect": {
            "x": 0,
            "y": 0,
            "width": 0,
            "height": 0
          },
          "window_rect": {
            "x": 0,
            "y": 0,
            "width": 0,
            "height": 0
          },
          "geometry": {
            "x": 0,
            "y": 0,
            "width": 0,
            "height": 0
          },
          "name": "bottomdock",
          "window": null,
          "window_type": null,
          "nodes": [],
          "floating_nodes": [],
          "focus": [],
          "fullscreen_mode": 0,
          "sticky": false,
          "floating": "auto_off",
          "swallows": [
            {
              "dock": 3,
              "insert_where": 2
            }
          ]
        }
      ],
      "floating_nodes": [],
      "focus": [
        94389901481120,
        94389901478096,
        94389901484144
      ],
      "fullscreen_mode": 0,
      "sticky": false,
      "floating": "auto_off",
      "swallows": []
    }
  ],
  "floating_nodes": [],
  "focus": [
    94389901475072,
    94389901444240
  ],
  "fullscreen_mode": 0,
  "sticky": false,
  "floating": "auto_off",
  "swallows": []
}
ammgws commented 2 years ago

Those ids are so massive lol

Now just need to cross reference with swayipc-rs to see which field of tripping it

ammgws commented 2 years ago

@madhur Can you try the latest commit?

madhur commented 2 years ago

Now, the bar itself is not loading with error image

i3status-rs 0.30.0 (commit 3eba9745 2022-08-14)

Here is my config

theme = "nord-dark"
icons = "awesome"

[[block]]
block = "focused_window"
[block.format]
full = "$title"
short = "$title"

[[block]]
block = "uptime"
interval = 3600 # update every hour

[[block]]
block = "cpu"
interval = 1
format_alt = "$barchart.str() $utilization.eng()"
format = "$frequency.eng() \\| $utilization.eng() \\|$boost.str()"

#[[block]]
#block = "custom"
#command = "/home/madhur/.config/i3status-rust/cputemp.sh" # assumes fontawesome icons
#interval = 1

[[block]]
block = "temperature"
format = "$max|"
interval = 5
collapsed=false
chip="k10temp-*"

[[block]]
block = "memory"
format_mem = "$mem_used.eng(3,B,M) /$mem_total.eng(3,B,M) ($mem_used_percents.eng(2))"
format_swap = "$swap_free.eng(3,B,M) / $swap_total.eng(3,B,M)($swap_used_percents.eng(2))"
display_type = "memory"
clickable = true
interval = 5
warning_mem = 80
warning_swap = 80
critical_mem = 95
critical_swap = 95

[[block]]
block = "nvidia_gpu"
format = "RTX 3060 $temperature $fan_speed $memory $utilization"
interval = 1
idle=60
good=70
info=80
warning=90

[[block]]
block = "disk_space"
path = "/"
info_type = "used"
format = "$percentage ($used / $total)"
alert = 95
warning = 90
[[block.click]]
button = "right"
update = true

[[block]]
block = "net"
device = "enp5s0"
#format = "$ssid $ip $speed_down.eng(3,B,K) $speed_up.eng(3,B,K)"
format = "{$ip |}{$speed_up $speed_down|Wired connection}"
format_alt = "$ssid $graph_up $graph_down"
interval = 5

#[[block]]
#block = "net"
#device = "wlp2s0f0u1"
#format = "$ssid $ip $speed_down.eng(3,B,K) $speed_up.eng(3,B,K)"
#format = "{$ssid |}{$speed_up $speed_down|Wired connection}"
#format_alt = "$ssid $graph_up $graph_down"
#interval = 5

[[block]]
block = "sound"
format = "{ $volume|}"

[block.mappings]
"alsa_output.usb-Microsoft_Microsoft_LifeChat_LX-6000-00.analog-stereo" = "🎧"
"alsa_output.pci-0000_05_00.1.hdmi-stereo" = "🔈"
"alsa_output.pci-0000_05_00.1.hdmi-stereo-extra2" = "🔈"

#[[block]]
#block = "custom"
#command = "echo \uf011" # assumes fontawesome icons
#interval = "once"
#[[block.click]]
#cmd = "rofi -modi 'Powermenu:/home/madhur/.config/rofi/powermenu.sh' -theme /home/madhur/.config/rofi/powermenu.rasi -show Powermenu -icon-theme Papirus -hover-select -me-select-entry '' -me-accept-entry MousePrimary"
#button = "left"

[[block]]
block = "notify"
format = "$paused{Off}|On"

[[block]]
block = "dnf"
interval = 1800
format = "$count.eng(1) updates available"
format_singular = "One update available"
format_up_to_date = "system up to date"
critical_updates_regex = "(linux|linux-lts|linux-zen)"
[[block.click]]
button = "left"
cmd = "dnf list -q --upgrades | tail -n +2 | rofi -dmenu"

[[block]]
block = "time"
interval = 5
[block.format]
full = "%a %d %b %R"
short = "%R"
madhur commented 2 years ago

I removed theme and icon from the config and the bar displayed successfully, though I was able to reproduce the same issue again

MaxVerevkin commented 2 years ago
theme = "nord-dark"
icons = "awesome"

This syntax got removed, see https://github.com/greshake/i3status-rust/blob/master/doc/themes.md

madhur commented 2 years ago
theme = "nord-dark"
icons = "awesome"

This syntax got removed, see https://github.com/greshake/i3status-rust/blob/master/doc/themes.md

Got it. Corrected. However, the issue is reproducible.

image

ammgws commented 2 years ago

Hmm, can you run cargo update before cargo build?

madhur commented 2 years ago

Ok, Did that. However, same issue. Output:

❯ cargo update
    Updating crates.io index
    Updating futures v0.3.21 -> v0.3.23
    Updating futures-channel v0.3.21 -> v0.3.23
    Updating futures-core v0.3.21 -> v0.3.23
    Updating futures-io v0.3.21 -> v0.3.23
    Updating futures-sink v0.3.21 -> v0.3.23
    Updating futures-task v0.3.21 -> v0.3.23
    Updating futures-util v0.3.21 -> v0.3.23
❯ cargo build
  Downloaded futures-io v0.3.23
  Downloaded futures-task v0.3.23
  Downloaded futures-core v0.3.23
  Downloaded futures-channel v0.3.23
  Downloaded futures v0.3.23
  Downloaded futures-util v0.3.23
  Downloaded futures-sink v0.3.23
  Downloaded 7 crates (282.0 KB) in 0.42s
   Compiling futures-core v0.3.23
   Compiling futures-task v0.3.23
   Compiling futures-sink v0.3.23
   Compiling futures-util v0.3.23
   Compiling futures-io v0.3.23
   Compiling futures-channel v0.3.23
   Compiling i3status-rs v0.30.0 (/home/madhur/github/personal/i3status-rust)
   Compiling futures-lite v1.12.0
   Compiling tokio-util v0.7.3
   Compiling async-channel v1.7.1
   Compiling async-broadcast v0.4.1
   Compiling ordered-stream v0.0.1
   Compiling tokio-stream v0.1.9
   Compiling signal-hook-tokio v0.3.1
   Compiling inotify v0.10.0
   Compiling async-io v1.7.0
   Compiling async-executor v1.4.1
   Compiling async-pidfd v0.1.4
   Compiling swayipc-async v2.0.1
   Compiling h2 v0.3.13
   Compiling futures v0.3.23
   Compiling zbus v2.3.2
   Compiling hyper v0.14.20
   Compiling hyper-tls v0.5.0
   Compiling reqwest v0.11.11
    Finished dev [unoptimized + debuginfo] target(s) in 25.01s

❯ i3status-rs --version
i3status-rs 0.30.0 (commit 3eba9745 2022-08-14)
MaxVerevkin commented 2 years ago

I think that's the issue:

 "rect": {
                    "x": 3388,
                    "y": 4294967294,
                    "width": 304,
                    "height": 349
                  },

4294967294 does not fit in i32

ammgws commented 2 years ago

Ah, good spot.

That is kinda weird, seems like a bug with i3?

MaxVerevkin commented 2 years ago

seems like a bug with i3?

Maybe. y = -2 makes more sense than y = 4294967294 (they have the same binary representation).

ammgws commented 2 years ago

These are the functions producing that output in i3/sway. I guess that cast is causing this in i3..

i3:

/**
 * Stores a rectangle, for example the size of a window, the child window etc.
 *
 * Note that x and y can contain signed values in some cases (for example when
 * used for the coordinates of a window, which can be set outside of the
 * visible area, but not when specifying the position of a workspace for the
 * _NET_WM_WORKAREA hint). Not declaring x/y as int32_t saves us a lot of
 * typecasts.
 *
 */
struct Rect {
    uint32_t x;
    uint32_t y;
    uint32_t width;
    uint32_t height;
};
static void dump_rect(yajl_gen gen, const char *name, Rect r) {
    ystr(name);
    y(map_open);
    ystr("x");
    y(integer, (int32_t)r.x);
    ystr("y");
    y(integer, (int32_t)r.y);
    ystr("width");
    y(integer, r.width);
    ystr("height");
    y(integer, r.height);
    y(map_close);
}

sway:

/**
 * A box representing a rectangle region in a 2D space.
 *
 * The x and y coordinates are inclusive, and the width and height lengths are
 * exclusive. In other words, the box starts from the coordinates (x, y), and
 * goes up to but not including (x + width, y + height).
 */
struct wlr_box {
    int x, y;
    int width, height;
};
static json_object *ipc_json_create_rect(struct wlr_box *box) {
    json_object *rect = json_object_new_object();

    json_object_object_add(rect, "x", json_object_new_int(box->x));
    json_object_object_add(rect, "y", json_object_new_int(box->y));
    json_object_object_add(rect, "width", json_object_new_int(box->width));
    json_object_object_add(rect, "height", json_object_new_int(box->height));

    return rect;
}
MaxVerevkin commented 2 years ago

y(integer, (int32_t)r.y);

But int32_t is signed, right? So this cast should do 4294967294 -> -2. But it doesn't?

ammgws commented 2 years ago

yajl casting it back? :shrug:

MaxVerevkin commented 2 years ago

Apparently this had been fixed in https://github.com/i3/i3/pull/4377

@madhur which version of i3 do you use?

yajl casting it back?

Nope, it uses long long int. (https://fossies.org/dox/yajl-2.1.0/yajl__gen_8c.html#a7b8f271521bf910145bfaf7fb74e91dd)

ammgws commented 2 years ago

No wonder it didn't make sense... on the right track but it was fixed already :laughing:

madhur commented 2 years ago

I am using i3-gaps from Fedora 36

❯ i3 --version
i3 version 4.19.1 (2021-02-01) © 2009 Michael Stapelberg and contributors
MaxVerevkin commented 2 years ago

Well... You can install the latest (4.20, already 9 months old) version of i3-gaps from COPR, I guess...

madhur commented 2 years ago

Yes, I built the latest from source and the issue has been resolved :)