Add experimental mode to use native scaling of Xwayland clients
Allow scale-aware Xwayland clients to scale by an integer scale themselves, instead of letting them render them at 1x scale and then scaling up the texture, making it look blurry. When monitor framebuffers are scaled, this special cases Xwayland and sends output regions in a way that Xwayland think everything is N times as large as the logical region, where N is the ceil of the max monitor scale. This is done by introducing a "stage" vs "protocol" coordinate space for X11, where the "protocol" coordinate space is "stage" multiplied by a scaling factor. Xwayland thus will have its own "effective scale", sent via wl_output.scale. The effective Xwayland scale is also used for the internal MetaWaylandSurface scale internally, unless there is a viewport dst size set on the same surface, in which case the scale is still set to 1, to not interfere with wp_viewport semantics. We're guarding this behind a new experimental feature "xwayland-native-scaling", which can only come into effect when enabled together with "scale-monitor-framebuffer". [v2]: Move stage_to_protocol/protocol_to_stage to generic window class. This means parts that aren't aware of any windowing system specific logic, only that coordinates originate from there for a given window, can still get their coordinates properly handled. In particular, this means coordinates from IBus that originates from the client, can be scaled properly when that client is using X11. Also make them properly introspected. [v3]: Split up coordinate transform API. Make it one that takes a MtkRectangle, and another that takes a point. This means the rounding strategy becames explicit when transforming a point, while when it's a rectangle, it's still always "grow". Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3567>
This commit is contained in:
@ -8037,3 +8037,103 @@ meta_window_set_normal_hints (MetaWindow *window,
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_window_stage_to_protocol_rect:
|
||||
* @window: A #MetaWindow
|
||||
* @stage_rect: x #MtkRectangle in stage coordinate space
|
||||
* @protocol_rect: (out): x #MtkRectangle in protocol coordinate space
|
||||
*
|
||||
* Transform the coordinates from stage coordinates to protocol coordinates
|
||||
*/
|
||||
void
|
||||
meta_window_stage_to_protocol_rect (MetaWindow *window,
|
||||
const MtkRectangle *stage_rect,
|
||||
MtkRectangle *protocol_rect)
|
||||
{
|
||||
MetaWindowClass *klass = META_WINDOW_GET_CLASS (window);
|
||||
|
||||
klass->stage_to_protocol (window,
|
||||
stage_rect->x, stage_rect->y,
|
||||
&protocol_rect->x, &protocol_rect->y);
|
||||
klass->stage_to_protocol (window,
|
||||
stage_rect->width, stage_rect->height,
|
||||
&protocol_rect->width, &protocol_rect->height);
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_window_stage_to_protocol_point:
|
||||
* @window: A #MetaWindow
|
||||
* @stage_x: x cordinate in stage coordinate space
|
||||
* @stage_y: y cordinate in stage coordinate space
|
||||
* @protocol_x: (out): x cordinate in protocol coordinate space
|
||||
* @protocol_y: (out): y cordinate in protocol coordinate space
|
||||
*
|
||||
* Transform the coordinates from stage coordinates to protocol coordinates
|
||||
*/
|
||||
void
|
||||
meta_window_stage_to_protocol_point (MetaWindow *window,
|
||||
int stage_x,
|
||||
int stage_y,
|
||||
int *protocol_x,
|
||||
int *protocol_y)
|
||||
{
|
||||
MetaWindowClass *klass = META_WINDOW_GET_CLASS (window);
|
||||
|
||||
klass->stage_to_protocol (window,
|
||||
stage_x, stage_y,
|
||||
protocol_x, protocol_y);
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_window_protocol_to_stage_rect:
|
||||
* @window: A #MetaWindow
|
||||
* @protocol_rect: rectangle in protocol coordinate space
|
||||
* @stage_rect: (out): rect in stage coordinate space
|
||||
*
|
||||
* Transform the coordinates from protocol coordinates to coordinates expected
|
||||
* by the stage and internal window management logic.
|
||||
*/
|
||||
void
|
||||
meta_window_protocol_to_stage_rect (MetaWindow *window,
|
||||
const MtkRectangle *protocol_rect,
|
||||
MtkRectangle *stage_rect)
|
||||
{
|
||||
MetaWindowClass *klass = META_WINDOW_GET_CLASS (window);
|
||||
|
||||
klass->protocol_to_stage (window,
|
||||
protocol_rect->x, protocol_rect->y,
|
||||
&stage_rect->x, &stage_rect->y,
|
||||
MTK_ROUNDING_STRATEGY_SHRINK);
|
||||
klass->protocol_to_stage (window,
|
||||
protocol_rect->width, protocol_rect->height,
|
||||
&stage_rect->width, &stage_rect->height,
|
||||
MTK_ROUNDING_STRATEGY_GROW);
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_window_protocol_to_stage_point:
|
||||
* @window: A #MetaWindow
|
||||
* @protocol_x: x cordinate in protocol coordinate space
|
||||
* @protocol_y: y cordinate in protocol coordinate space
|
||||
* @stage_x: (out): x cordinate in stage coordinate space
|
||||
* @stage_y: (out): y cordinate in stage coordinate space
|
||||
*
|
||||
* Transform the coordinates from protocol coordinates to coordinates expected
|
||||
* by the stage and internal window management logic.
|
||||
*/
|
||||
void
|
||||
meta_window_protocol_to_stage_point (MetaWindow *window,
|
||||
int protocol_x,
|
||||
int protocol_y,
|
||||
int *stage_x,
|
||||
int *stage_y,
|
||||
MtkRoundingStrategy rounding_strategy)
|
||||
{
|
||||
MetaWindowClass *klass = META_WINDOW_GET_CLASS (window);
|
||||
|
||||
klass->protocol_to_stage (window,
|
||||
protocol_x, protocol_y,
|
||||
stage_x, stage_y,
|
||||
rounding_strategy);
|
||||
}
|
||||
|
Reference in New Issue
Block a user