mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-02 11:55:59 +01:00
Always center fullscreen view on screen
This commit is contained in:
parent
17d9e2ce35
commit
9e29621ec3
2 changed files with 21 additions and 0 deletions
|
@ -53,6 +53,10 @@ static void view_update_output(const struct roots_view *view,
|
||||||
}
|
}
|
||||||
|
|
||||||
void view_move(struct roots_view *view, double x, double y) {
|
void view_move(struct roots_view *view, double x, double y) {
|
||||||
|
if (view->x == x && view->y == y) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct wlr_box before;
|
struct wlr_box before;
|
||||||
view_get_box(view, &before);
|
view_get_box(view, &before);
|
||||||
if (view->move) {
|
if (view->move) {
|
||||||
|
@ -61,6 +65,7 @@ void view_move(struct roots_view *view, double x, double y) {
|
||||||
view->x = x;
|
view->x = x;
|
||||||
view->y = y;
|
view->y = y;
|
||||||
}
|
}
|
||||||
|
view_update_output(view, &before);
|
||||||
}
|
}
|
||||||
|
|
||||||
void view_activate(struct roots_view *view, bool activate) {
|
void view_activate(struct roots_view *view, bool activate) {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <GLES2/gl2.h>
|
||||||
#include <wlr/types/wlr_output_layout.h>
|
#include <wlr/types/wlr_output_layout.h>
|
||||||
#include <wlr/types/wlr_compositor.h>
|
#include <wlr/types/wlr_compositor.h>
|
||||||
#include <wlr/types/wlr_wl_shell.h>
|
#include <wlr/types/wlr_wl_shell.h>
|
||||||
|
@ -194,11 +195,26 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
||||||
wlr_renderer_begin(server->renderer, wlr_output);
|
wlr_renderer_begin(server->renderer, wlr_output);
|
||||||
|
|
||||||
if (output->fullscreen_view != NULL) {
|
if (output->fullscreen_view != NULL) {
|
||||||
|
// Make sure the view is centered on screen
|
||||||
|
const struct wlr_box *output_box =
|
||||||
|
wlr_output_layout_get_box(desktop->layout, wlr_output);
|
||||||
|
struct wlr_box view_box;
|
||||||
|
view_get_box(output->fullscreen_view, &view_box);
|
||||||
|
double view_x = (double)(output_box->width - view_box.width) / 2 +
|
||||||
|
output_box->x;
|
||||||
|
double view_y = (double)(output_box->height - view_box.height) / 2 +
|
||||||
|
output_box->y;
|
||||||
|
view_move(output->fullscreen_view, view_x, view_y);
|
||||||
|
|
||||||
if (has_standalone_surface(output->fullscreen_view)) {
|
if (has_standalone_surface(output->fullscreen_view)) {
|
||||||
wlr_output_set_fullscreen_surface(wlr_output,
|
wlr_output_set_fullscreen_surface(wlr_output,
|
||||||
output->fullscreen_view->wlr_surface);
|
output->fullscreen_view->wlr_surface);
|
||||||
} else {
|
} else {
|
||||||
wlr_output_set_fullscreen_surface(wlr_output, NULL);
|
wlr_output_set_fullscreen_surface(wlr_output, NULL);
|
||||||
|
|
||||||
|
glClearColor(0, 0, 0, 0);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
render_view(output->fullscreen_view, desktop, wlr_output, &now);
|
render_view(output->fullscreen_view, desktop, wlr_output, &now);
|
||||||
}
|
}
|
||||||
wlr_renderer_end(server->renderer);
|
wlr_renderer_end(server->renderer);
|
||||||
|
|
Loading…
Reference in a new issue