-
Notifications
You must be signed in to change notification settings - Fork 343
HiDPI #329
Conversation
ddevault
commented
Oct 24, 2017
•
edited
Loading
edited
- Accept output scale in the config
- Send output enter/leave events
- Render surfaces scaled up by their scale factor
- Consider the new surface size accurately with respect to pointer events
- Scale client cursors
- Scale subsurfaces
- Correctly handle surfaces whose scale factor does not match the output
- Scale rootston cursor
- Report bug to GTK: moving window from scale=1 -> scale=2 causes incorrect cursor scale
- Input for rotated surfaces
- Increase input fidelity
@@ -135,4 +135,8 @@ struct wlr_surface *wlr_surface_get_main_surface(struct wlr_surface *surface); | |||
*/ | |||
struct wlr_subsurface *wlr_surface_subsurface_at(struct wlr_surface *surface, | |||
double sx, double sy, double *sub_x, double *sub_y); | |||
|
|||
void wlr_surface_send_enter(struct wlr_surface *surface, | |||
struct wlr_output *output); |
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.
We should send leave
too.
rootston/desktop.c
Outdated
} | ||
if (output && output != view->output) { | ||
view->output = output; | ||
wlr_surface_send_enter(view->wlr_surface, output->wlr_output); |
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.
Shouldn't we send one enter
event for each output which intersects with the view?
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.
Good question.
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.
Spec: https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_surface-event-enter
Note that a surface may be overlapping with zero or more outputs.
So yeah, we should send enter
to all outputs that intersects with the view.
types/wlr_output.c
Outdated
@@ -28,8 +28,7 @@ static void wl_output_send_to_resource(struct wl_resource *resource) { | |||
if (version >= WL_OUTPUT_MODE_SINCE_VERSION) { | |||
struct wlr_output_mode *mode; | |||
wl_list_for_each(mode, &output->modes, link) { | |||
// TODO: mode->flags should just be preferred | |||
uint32_t flags = mode->flags; | |||
uint32_t flags = mode->flags & ~WL_OUTPUT_MODE_PREFERRED; |
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.
Does this flag break things?
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.
I did this backwards.
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.
Yeah, so:
WL_OUTPUT_MODE_PREFERRED
has only one bit on~WL_OUTPUT_MODE_PREFERRED
has only one bit off, the preferred bit (all others on)mode->flags & ~WL_OUTPUT_MODE_PREFERRED
ismode->flags
with the preferred bit off
But the comment says the contrary: mode->flags
should only be able to change WL_OUTPUT_MODE_PREFERRED
(ie. should not be able to set WL_OUTPUT_MODE_CURRENT
).
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.
I already said I did it backwards -_-
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.
Oh, sorry. I though you were speaking about the ~
, saying it inverts bits so it would be fine.
I'm done for today, but if anyone is reviewing my commits and sees the reason behind this bug, I would appreciate your insight: gnome-calculator should not show up at all on the right output - but it does. |
I think I figured out an approach that will address that problem, writing it down here for poserity - We need to treat HiDPI displays in the output layout as scaled up - that is, my 4K display should be arranged as if it were 1920x1080, and its x/y position relative to this. Then, at the renderer, we can scale it up or down depending on the scale of the surface and the genuine size of the output. |
void (*activate)(struct roots_view *view, bool active); | ||
void (*resize)(struct roots_view *view, uint32_t width, uint32_t height); | ||
void (*set_position)(struct roots_view *view, double x, double y); | ||
void (*close)(struct roots_view *view); | ||
}; | ||
|
||
void view_get_size(struct roots_view *view, struct wlr_box *box); | ||
void view_get_size(const struct roots_view *view, struct wlr_box *box); |
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.
Maybe rename this to get_box
now that this also returns the position?
A similar change should probably be applied to hardware cursors, though more complicated. Also, this doesn't actually fix the issue where the cursor is too small when over a scale=2 surface. Apparently they don't set their cursor scales to 2. Seems like a client bug? idk
Something about my math is off, but I'm not certain what. Would appreciate a second opinion.
Except for subsurfaces not rendering at the right scale. But that part is (somewhat) easy.
Woo-hoo, got it working |
rootston/desktop.c
Outdated
set_view_focus(input, view->desktop, view); | ||
wlr_seat_keyboard_notify_enter(input->wl_seat, view->wlr_surface); |
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.
This is already done in set_view_focus
:
Line 209 in 975b9dc
wlr_seat_keyboard_notify_enter(input->wl_seat, view->wlr_surface); |
types/wlr_output.c
Outdated
@@ -450,6 +451,8 @@ void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor, | |||
} | |||
|
|||
bool wlr_output_cursor_move(struct wlr_output_cursor *cursor, int x, int y) { | |||
x *= cursor->output->scale; | |||
y *= cursor->output->scale; |
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.
Because of this, maybe we want to accept double
s, multiply them, and cast them to int
s right away.
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.
Yes, this is in my todo list
We could add a config field for XWayland DPI:
|
Are you sure that's the right bugzilla link? |
Whoops, here's the link: https://bugs.freedesktop.org/show_bug.cgi?id=93315 An interesting but complicated idea if we want to really support HiDPI in XWayland is this comment:
|
We wouldn't be able to move windows between them. We should run an Xwayland server at the highest DPI among our monitors and scale down views on some displays. But it will be very messy. |
We now use doubles until the last minute, which makes it so we can move the pointer more precisely. This also includes a fix for tablet tools, which move absolutely and sometimes do not update the X or Y axis.
There was an issue where it would only work within the boundaries of the unscaled resolution.
I have a proposal for how to deal with cursor scale here. Basically, we're going to need to load xcursor themes at multiple scales for them to look good on each output in a mixed-DPI setup. I want to change wlr_cursor to distinguish the surface cursor from the fallback cursor. We'll change the set pixels guy to |
Looking for feedback on this now. I'm going to spin out the remaining work into separate tickets. |
@@ -231,14 +231,15 @@ void wlr_output_destroy(struct wlr_output *output) { | |||
|
|||
void wlr_output_effective_resolution(struct wlr_output *output, | |||
int *width, int *height) { |
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.
Maybe it's worth it to have double
s here too?
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.
Hmm, I'm not sure we get any benefit from that. This isn't a place where loss of precision impacts anything.
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.
Well, we use it below for the cursor code:
What we basically do is: (int)(width / scale) * scale
.
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.
Yeah, but there are no displays (or if there are, I've never heard of them) with odd dimensions so you are always going to be dealing with integers here anyway.
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.
Okay, so we should be fine for now. We won't be anymore when we'll introduce fractional scaling.
|
I'm not convinced that weston supports hidpi
Genuine bug |