This repository has been archived by the owner on Nov 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 341
[WIP] Remove usages of wlr_output_layout_get() #1070
Closed
+203
−176
Closed
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifndef TYPES_WLR_OUTPUT_LAYOUT_H | ||
#define TYPES_WLR_OUTPUT_LAYOUT_H | ||
|
||
#include <wlr/types/wlr_output_layout.h> | ||
|
||
struct wlr_output_layout_output_state { | ||
struct wlr_output_layout *layout; | ||
struct wlr_output_layout_output *l_output; | ||
|
||
bool auto_configured; | ||
|
||
struct wl_listener mode; | ||
struct wl_listener scale; | ||
struct wl_listener transform; | ||
struct wl_listener output_destroy; | ||
}; | ||
|
||
struct wlr_output_layout_output { | ||
struct wlr_output *output; | ||
int x, y; | ||
struct wl_list link; | ||
struct wlr_output_layout_output_state *state; | ||
|
||
struct { | ||
struct wl_signal destroy; | ||
} events; | ||
}; | ||
|
||
struct wlr_output_layout_output *wlr_output_layout_get( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function will be exported because it has the |
||
struct wlr_output_layout *layout, struct wlr_output *reference); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
#include <wlr/types/wlr_output.h> | ||
#include <wlr/util/log.h> | ||
#include "util/signal.h" | ||
#include "types/wlr_output_layout.h" | ||
|
||
struct wlr_cursor_device { | ||
struct wlr_cursor *cursor; | ||
|
@@ -203,46 +204,51 @@ static void cursor_warp_unchecked(struct wlr_cursor *cur, | |
* Absolute movement for touch and pen devices will be relative to this box and | ||
* pointer movement will be constrained to this box. | ||
* | ||
* If none of these are set, returns NULL and absolute movement should be | ||
* If none of these are set, returns false and absolute movement should be | ||
* relative to the extents of the layout. | ||
*/ | ||
static struct wlr_box *get_mapping(struct wlr_cursor *cur, | ||
struct wlr_input_device *dev) { | ||
static bool get_mapping(struct wlr_cursor *cur, | ||
struct wlr_input_device *dev, struct wlr_box *box) { | ||
assert(cur->state->layout); | ||
struct wlr_cursor_device *c_device = get_cursor_device(cur, dev); | ||
|
||
if (c_device) { | ||
if (c_device->mapped_box) { | ||
return c_device->mapped_box; | ||
memcpy(box, c_device->mapped_box, sizeof(struct wlr_box)); | ||
return true; | ||
} | ||
if (c_device->mapped_output) { | ||
return wlr_output_layout_get_box(cur->state->layout, | ||
c_device->mapped_output); | ||
if (c_device->mapped_output && | ||
wlr_output_layout_get_box(cur->state->layout, | ||
c_device->mapped_output, box)) { | ||
return true; | ||
} | ||
} | ||
|
||
if (cur->state->mapped_box) { | ||
return cur->state->mapped_box; | ||
memcpy(box, cur->state->mapped_box, sizeof(struct wlr_box)); | ||
return true; | ||
} | ||
if (cur->state->mapped_output) { | ||
return wlr_output_layout_get_box(cur->state->layout, | ||
cur->state->mapped_output); | ||
|
||
if (cur->state->mapped_output && | ||
wlr_output_layout_get_box(cur->state->layout, | ||
cur->state->mapped_output, box)) { | ||
return true; | ||
} | ||
|
||
return NULL; | ||
return false; | ||
} | ||
|
||
bool wlr_cursor_warp(struct wlr_cursor *cur, struct wlr_input_device *dev, | ||
double lx, double ly) { | ||
assert(cur->state->layout); | ||
|
||
struct wlr_box mapping; | ||
bool result = false; | ||
struct wlr_box *mapping = get_mapping(cur, dev); | ||
if (mapping) { | ||
result = wlr_box_contains_point(mapping, lx, ly); | ||
if (get_mapping(cur, dev, &mapping)) { | ||
result = wlr_box_contains_point(&mapping, lx, ly); | ||
} else { | ||
result = wlr_output_layout_contains_point(cur->state->layout, NULL, | ||
lx, ly); | ||
result = | ||
wlr_output_layout_contains_point(cur->state->layout, NULL, lx, ly); | ||
} | ||
|
||
if (result) { | ||
|
@@ -254,9 +260,9 @@ bool wlr_cursor_warp(struct wlr_cursor *cur, struct wlr_input_device *dev, | |
|
||
static void cursor_warp_closest(struct wlr_cursor *cur, | ||
struct wlr_input_device *dev, double lx, double ly) { | ||
struct wlr_box *mapping = get_mapping(cur, dev); | ||
if (mapping) { | ||
wlr_box_closest_point(mapping, lx, ly, &lx, &ly); | ||
struct wlr_box mapping; | ||
if (get_mapping(cur, dev, &mapping)) { | ||
wlr_box_closest_point(&mapping, lx, ly, &lx, &ly); | ||
} else { | ||
wlr_output_layout_closest_point(cur->state->layout, NULL, lx, ly, | ||
&lx, &ly); | ||
|
@@ -270,13 +276,17 @@ void wlr_cursor_absolute_to_layout_coords(struct wlr_cursor *cur, | |
double *lx, double *ly) { | ||
assert(cur->state->layout); | ||
|
||
struct wlr_box *mapping = get_mapping(cur, dev); | ||
if (!mapping) { | ||
mapping = wlr_output_layout_get_box(cur->state->layout, NULL); | ||
struct wlr_box mapping; | ||
if (!get_mapping(cur, dev, &mapping) && | ||
!wlr_output_layout_get_box(cur->state->layout, NULL, &mapping)) { | ||
// no outputs in the layout | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dunno what to do here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think setting everything to zero is sane. |
||
*lx = 0; | ||
*ly = 0; | ||
return; | ||
} | ||
|
||
*lx = !isnan(x) ? mapping->width * x + mapping->x : cur->x; | ||
*ly = !isnan(y) ? mapping->height * y + mapping->y : cur->y; | ||
*lx = !isnan(x) ? mapping.width * x + mapping.x : cur->x; | ||
*ly = !isnan(y) ? mapping.height * y + mapping.y : cur->y; | ||
} | ||
|
||
void wlr_cursor_warp_absolute(struct wlr_cursor *cur, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to keep this around?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I think the whole point of this state struct was to keep some stuff private.