Skip to content

Commit 47e6271

Browse files
committed
expo: add a scroll overview
1 parent 4d940a1 commit 47e6271

File tree

9 files changed

+544
-26
lines changed

9 files changed

+544
-26
lines changed

hyprexpo/ExpoGesture.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void CExpoGesture::begin(const ITrackpadGesture::STrackpadGestureBegin& e) {
1212
m_firstUpdate = true;
1313

1414
if (!g_pOverview)
15-
g_pOverview = std::make_unique<COverview>(g_pCompositor->m_lastMonitor->m_activeWorkspace);
15+
g_pOverview = makeShared<COverview>(g_pCompositor->m_lastMonitor->m_activeWorkspace);
1616
else {
1717
g_pOverview->selectHoveredWorkspace();
1818
g_pOverview->setClosing(true);

hyprexpo/IOverview.hpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#pragma once
2+
#include <hyprland/src/helpers/memory/Memory.hpp>
3+
4+
class IOverview {
5+
public:
6+
IOverview() = default;
7+
virtual ~IOverview() = default;
8+
9+
virtual void render() = 0;
10+
virtual void damage() = 0;
11+
virtual void onDamageReported() = 0;
12+
virtual void onPreRender() = 0;
13+
14+
virtual void setClosing(bool closing) = 0;
15+
16+
virtual void resetSwipe() = 0;
17+
virtual void onSwipeUpdate(double delta) = 0;
18+
virtual void onSwipeEnd() = 0;
19+
20+
virtual void close() = 0;
21+
virtual void selectHoveredWorkspace() = 0;
22+
23+
virtual void fullRender() = 0;
24+
25+
bool blockOverviewRendering = false;
26+
bool blockDamageReporting = false;
27+
28+
PHLMONITORREF pMonitor;
29+
bool m_isSwiping = false;
30+
};
31+
32+
inline SP<IOverview> g_pOverview;

hyprexpo/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ else
66
endif
77

88
all:
9-
$(CXX) -shared -fPIC $(EXTRA_FLAGS) main.cpp overview.cpp ExpoGesture.cpp OverviewPassElement.cpp -o hyprexpo.so -g `pkg-config --cflags pixman-1 libdrm hyprland pangocairo libinput libudev wayland-server xkbcommon` -std=c++2b -Wno-narrowing
9+
$(CXX) -shared -fPIC $(EXTRA_FLAGS) main.cpp overview.cpp ExpoGesture.cpp OverviewPassElement.cpp scrollOverview.cpp -o hyprexpo.so -g `pkg-config --cflags pixman-1 libdrm hyprland pangocairo libinput libudev wayland-server xkbcommon` -std=c++2b -Wno-narrowing
1010
clean:
1111
rm ./hyprexpo.so

hyprexpo/globals.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
#include <hyprland/src/plugins/PluginAPI.hpp>
44

5-
inline HANDLE PHANDLE = nullptr;
5+
inline HANDLE PHANDLE = nullptr;
6+
inline bool IS_SCROLLING = false;

hyprexpo/main.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
#include <hyprland/src/render/Renderer.hpp>
1010
#include <hyprland/src/managers/input/trackpad/GestureTypes.hpp>
1111
#include <hyprland/src/managers/input/trackpad/TrackpadGestures.hpp>
12+
#include <hyprland/src/managers/LayoutManager.hpp>
1213

1314
#include <hyprutils/string/ConstVarList.hpp>
1415
using namespace Hyprutils::String;
1516

1617
#include "globals.hpp"
1718
#include "overview.hpp"
19+
#include "scrollOverview.hpp"
1820
#include "ExpoGesture.hpp"
1921

2022
// Methods
@@ -66,6 +68,8 @@ static void hkAddDamageB(void* thisptr, const pixman_region32_t* rg) {
6668

6769
static SDispatchResult onExpoDispatcher(std::string arg) {
6870

71+
IS_SCROLLING = g_pLayoutManager->getCurrentLayout()->getLayoutName() == "scrolling";
72+
6973
if (g_pOverview && g_pOverview->m_isSwiping)
7074
return {.success = false, .error = "already swiping"};
7175

@@ -81,7 +85,10 @@ static SDispatchResult onExpoDispatcher(std::string arg) {
8185
g_pOverview->close();
8286
else {
8387
renderingOverview = true;
84-
g_pOverview = std::make_unique<COverview>(g_pCompositor->m_lastMonitor->m_activeWorkspace);
88+
if (IS_SCROLLING)
89+
g_pOverview = makeShared<CScrollOverview>(g_pCompositor->m_lastMonitor->m_activeWorkspace);
90+
else
91+
makeShared<COverview>(g_pCompositor->m_lastMonitor->m_activeWorkspace);
8592
renderingOverview = false;
8693
}
8794
return {};
@@ -97,7 +104,10 @@ static SDispatchResult onExpoDispatcher(std::string arg) {
97104
return {};
98105

99106
renderingOverview = true;
100-
g_pOverview = std::make_unique<COverview>(g_pCompositor->m_lastMonitor->m_activeWorkspace);
107+
if (IS_SCROLLING)
108+
g_pOverview = makeShared<CScrollOverview>(g_pCompositor->m_lastMonitor->m_activeWorkspace);
109+
else
110+
makeShared<COverview>(g_pCompositor->m_lastMonitor->m_activeWorkspace);
101111
renderingOverview = false;
102112
return {};
103113
}
@@ -107,7 +117,7 @@ static void failNotif(const std::string& reason) {
107117
}
108118

109119
static Hyprlang::CParseResult expoGestureKeyword(const char* LHS, const char* RHS) {
110-
Hyprlang::CParseResult result;
120+
Hyprlang::CParseResult result;
111121

112122
if (g_unloading)
113123
return result;

hyprexpo/overview.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <hyprland/src/managers/animation/AnimationManager.hpp>
99
#include <hyprland/src/managers/animation/DesktopAnimationManager.hpp>
1010
#include <hyprland/src/managers/input/InputManager.hpp>
11+
#include <hyprland/src/managers/LayoutManager.hpp>
1112
#include <hyprland/src/helpers/time/Time.hpp>
1213
#undef private
1314
#include "OverviewPassElement.hpp"

hyprexpo/overview.hpp

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,40 @@
99
#include <hyprland/src/managers/HookSystemManager.hpp>
1010
#include <vector>
1111

12+
#include "IOverview.hpp"
13+
1214
// saves on resources, but is a bit broken rn with blur.
1315
// hyprland's fault, but cba to fix.
1416
constexpr bool ENABLE_LOWRES = false;
1517

1618
class CMonitor;
1719

18-
class COverview {
20+
class COverview : public IOverview {
1921
public:
2022
COverview(PHLWORKSPACE startedOn_, bool swipe = false);
21-
~COverview();
23+
virtual ~COverview();
2224

23-
void render();
24-
void damage();
25-
void onDamageReported();
26-
void onPreRender();
25+
virtual void render();
26+
virtual void damage();
27+
virtual void onDamageReported();
28+
virtual void onPreRender();
2729

28-
void setClosing(bool closing);
30+
virtual void setClosing(bool closing);
2931

30-
void resetSwipe();
31-
void onSwipeUpdate(double delta);
32-
void onSwipeEnd();
32+
virtual void resetSwipe();
33+
virtual void onSwipeUpdate(double delta);
34+
virtual void onSwipeEnd();
3335

3436
// close without a selection
35-
void close();
36-
void selectHoveredWorkspace();
37-
38-
bool blockOverviewRendering = false;
39-
bool blockDamageReporting = false;
37+
virtual void close();
38+
virtual void selectHoveredWorkspace();
4039

41-
PHLMONITORREF pMonitor;
42-
bool m_isSwiping = false;
40+
virtual void fullRender();
4341

4442
private:
4543
void redrawID(int id, bool forcelowres = false);
4644
void redrawAll(bool forcelowres = false);
4745
void onWorkspaceChange();
48-
void fullRender();
4946

5047
int SIDE_LENGTH = 3;
5148
int GAP_WIDTH = 5;
@@ -84,5 +81,3 @@ class COverview {
8481

8582
friend class COverviewPassElement;
8683
};
87-
88-
inline std::unique_ptr<COverview> g_pOverview;

0 commit comments

Comments
 (0)