mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
Unmaximize on Move
This commit is contained in:
parent
a6a923c506
commit
ae43d4b9d1
1 changed files with 35 additions and 2 deletions
|
|
@ -1,16 +1,49 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
|
|
||||||
|
static int
|
||||||
|
max_move_scale(double pos_cursor, double pos_current,
|
||||||
|
double size_current, double size_orig)
|
||||||
|
{
|
||||||
|
double anchor_frac = (pos_cursor - pos_current) / size_current;
|
||||||
|
int pos_new = pos_cursor - (size_orig * anchor_frac);
|
||||||
|
if (pos_new < pos_current) {
|
||||||
|
/* Clamp by using the old offsets of the maximized window */
|
||||||
|
pos_new = pos_current;
|
||||||
|
}
|
||||||
|
return pos_new;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
interactive_begin(struct view *view, enum input_mode mode, uint32_t edges)
|
interactive_begin(struct view *view, enum input_mode mode, uint32_t edges)
|
||||||
{
|
{
|
||||||
if (view->maximized) {
|
if (view->maximized) {
|
||||||
|
if (mode == LAB_INPUT_STATE_MOVE) {
|
||||||
|
int new_x = max_move_scale(view->server->seat.cursor->x,
|
||||||
|
view->x, view->w, view->unmaximized_geometry.width);
|
||||||
|
int new_y = max_move_scale(view->server->seat.cursor->y,
|
||||||
|
view->y, view->h, view->unmaximized_geometry.height);
|
||||||
|
view->unmaximized_geometry.x = new_x;
|
||||||
|
view->unmaximized_geometry.y = new_y;
|
||||||
|
view_maximize(view, false);
|
||||||
|
/*
|
||||||
|
* view_maximize() indirectly calls view->impl->configure
|
||||||
|
* which is async but we are using the current values in
|
||||||
|
* server->grab_box. We pretend the configure already
|
||||||
|
* happened by setting them manually.
|
||||||
|
*/
|
||||||
|
view->x = new_x;
|
||||||
|
view->y = new_y;
|
||||||
|
view->w = view->unmaximized_geometry.width;
|
||||||
|
view->h = view->unmaximized_geometry.height;
|
||||||
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function sets up an interactive move or resize operation, where
|
* This function sets up an interactive move or resize operation, where
|
||||||
* the compositor stops propegating pointer events to clients and
|
* the compositor stops propagating pointer events to clients and
|
||||||
* instead consumes them itself, to move or resize windows.
|
* instead consumes them itself, to move or resize windows.
|
||||||
*/
|
*/
|
||||||
struct seat *seat = &view->server->seat;
|
struct seat *seat = &view->server->seat;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue