Skip to content

Commit

Permalink
Support negative rectangle coordinates (#12)
Browse files Browse the repository at this point in the history
Since i3 4.22 now supports gaps, negative gaps can cause nodes
(workspaces, windows, ...) to have negative coordinates which we did not
support.

However, sometimes i3 reports negative coordinates as `uint32_t`.
Because of this the range of possible values for rectangle coordinates
are `[INT32_MIN, UINT32_MAX)`.
To work around this, we just read an int64_t.

Ref: i3/i3#5352
Ref: polybar/polybar#2888
  • Loading branch information
patrick96 committed Jan 5, 2023
1 parent 86ddf71 commit 85b444c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/i3ipc++/ipc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ std::string get_socketpath();
* Primitive of rectangle
*/
struct rect_t {
uint32_t x; ///< Position on X axis
uint32_t y; ///< Position on Y axis
int64_t x; ///< Position on X axis
int64_t y; ///< Position on Y axis
uint32_t width; ///< Width of rectangle
uint32_t height; ///< Height of rectangle
};
Expand Down
4 changes: 2 additions & 2 deletions src/ipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ std::vector<std::ostream*> g_logging_err_outs = {

inline rect_t parse_rect_from_json(const Json::Value& value) {
rect_t r{};
r.x = value["x"].asUInt();
r.y = value["y"].asUInt();
r.x = value["x"].asInt64();
r.y = value["y"].asInt64();
r.width = value["width"].asUInt();
r.height = value["height"].asUInt();
return r;
Expand Down

0 comments on commit 85b444c

Please sign in to comment.