Skip to content

Commit 7ddfe20

Browse files
committed
Update cursor for resizing SSDs
1 parent 4b1cd34 commit 7ddfe20

File tree

3 files changed

+57
-5
lines changed

3 files changed

+57
-5
lines changed

src/decorations/ssd.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ constexpr uint8_t TITLEBAR_HEIGHT = 24;
77
constexpr uint32_t TITLEBAR_ACTIVE_COLOR = 0x303030;
88
constexpr uint32_t TITLEBAR_INACTIVE_COLOR = 0x202020;
99
constexpr uint8_t BORDER_WIDTH = 1;
10-
constexpr uint8_t EXTENTS_WIDTH = 8;
10+
constexpr uint8_t EXTENTS_WIDTH = 12;
1111
constexpr uint32_t BORDER_ACTIVE_COLOR = 0x505050;
1212
constexpr uint32_t BORDER_INACTIVE_COLOR = 0x404040;
1313

@@ -73,7 +73,7 @@ Ssd::~Ssd() {
7373
}
7474

7575
void Ssd::update() const {
76-
auto view_geo = view.get_surface_geometry();
76+
auto view_geo = view.surface_current;
7777
wlr_scene_rect_set_size(titlebar_rect, view_geo.width, TITLEBAR_HEIGHT);
7878

7979
auto border_box = border_dimensions(view_geo);
@@ -92,13 +92,21 @@ void Ssd::set_activated(const bool activated) const {
9292
}
9393

9494
wlr_box Ssd::get_geometry() const {
95-
auto view_geo = view.get_surface_geometry();
95+
auto view_geo = view.surface_current;
9696
return {.x = view_geo.x - get_horizontal_offset(),
9797
.y = view_geo.y - get_vertical_offset(),
9898
.width = view_geo.width + get_extra_width(),
9999
.height = view_geo.height + get_extra_height()};
100100
}
101101

102+
wlr_box Ssd::get_extentless_geometry() const {
103+
auto view_geo = view.surface_current;
104+
return {.x = view_geo.x,
105+
.y = view_geo.y - TITLEBAR_HEIGHT,
106+
.width = view_geo.width,
107+
.height = view_geo.height + TITLEBAR_HEIGHT};
108+
}
109+
102110
uint8_t Ssd::get_vertical_offset() const {
103111
return TITLEBAR_HEIGHT + BORDER_WIDTH + EXTENTS_WIDTH;
104112
}

src/decorations/ssd.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class Ssd final : public std::enable_shared_from_this<Ssd> {
2424
void set_activated(bool activated) const;
2525

2626
wlr_box get_geometry() const;
27+
wlr_box get_extentless_geometry() const;
2728
uint8_t get_vertical_offset() const;
2829
uint8_t get_visual_vertical_offset() const;
2930
uint8_t get_horizontal_offset() const;

src/input/cursor.cpp

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "output.hpp"
55
#include "seat.hpp"
66
#include "server.hpp"
7-
#include "surface/surface.hpp"
87
#include "surface/view.hpp"
98

109
#include <algorithm>
@@ -468,7 +467,51 @@ void Cursor::process_motion(const uint32_t time) {
468467
* around the screen, not over any views. */
469468
set_image("left_ptr");
470469
} else if (ssd_at_cursor == SceneRectType::BORDER || ssd_at_cursor == SceneRectType::EXTENTS) {
471-
set_image("fleur");
470+
auto view = std::dynamic_pointer_cast<View>(magpie_surface);
471+
auto surface_geo = view->ssd.has_value() ? view->ssd->get_extentless_geometry() : view->surface_current;
472+
473+
uint8_t edges = WLR_EDGE_NONE;
474+
if (wlr.x < surface_geo.x) {
475+
edges |= WLR_EDGE_LEFT;
476+
}
477+
if (wlr.y < surface_geo.y) {
478+
edges |= WLR_EDGE_TOP;
479+
}
480+
if (wlr.x > surface_geo.x + surface_geo.width) {
481+
edges |= WLR_EDGE_RIGHT;
482+
}
483+
if (wlr.y > surface_geo.y + surface_geo.height) {
484+
edges |= WLR_EDGE_BOTTOM;
485+
}
486+
487+
switch (edges) {
488+
case WLR_EDGE_LEFT:
489+
set_image("left_side");
490+
break;
491+
case WLR_EDGE_LEFT | WLR_EDGE_TOP:
492+
set_image("top_left_corner");
493+
break;
494+
case WLR_EDGE_TOP:
495+
set_image("top_side");
496+
break;
497+
case WLR_EDGE_TOP | WLR_EDGE_RIGHT:
498+
set_image("top_right_corner");
499+
break;
500+
case WLR_EDGE_RIGHT:
501+
set_image("right_side");
502+
break;
503+
case WLR_EDGE_RIGHT | WLR_EDGE_BOTTOM:
504+
set_image("bottom_right_corner");
505+
break;
506+
case WLR_EDGE_BOTTOM:
507+
set_image("bottom_side");
508+
break;
509+
case WLR_EDGE_BOTTOM | WLR_EDGE_LEFT:
510+
set_image("bottom_left_corner");
511+
break;
512+
default:
513+
break;
514+
}
472515
}
473516

474517
if (ssd_at_cursor == SceneRectType::NONE && surface != nullptr) {

0 commit comments

Comments
 (0)