mirror of
https://github.com/hyprwm/Hypr.git
synced 2024-11-22 21:35:58 +01:00
Added cheap animations
This commit is contained in:
parent
7d39393cf8
commit
9e759fe39e
8 changed files with 52 additions and 15 deletions
|
@ -45,8 +45,9 @@ col.inactive_border=0x77222222
|
||||||
#
|
#
|
||||||
|
|
||||||
# animations
|
# animations
|
||||||
anim.enabled=0
|
anim.enabled=1
|
||||||
anim.speed=8
|
anim.speed=5
|
||||||
|
anim.cheap=1 # highly recommended
|
||||||
|
|
||||||
# keybinds
|
# keybinds
|
||||||
bind=SUPER,R,exec,dmenu_run
|
bind=SUPER,R,exec,dmenu_run
|
||||||
|
|
|
@ -38,7 +38,8 @@ void ConfigManager::init() {
|
||||||
|
|
||||||
// animations
|
// animations
|
||||||
configValues["anim.speed"].floatValue = 1;
|
configValues["anim.speed"].floatValue = 1;
|
||||||
configValues["anim.enabled"].intValue = 1;
|
configValues["anim.enabled"].intValue = 0;
|
||||||
|
configValues["anim.cheap"].intValue = 1;
|
||||||
|
|
||||||
if (!g_pWindowManager->statusBar) {
|
if (!g_pWindowManager->statusBar) {
|
||||||
isFirstLaunch = true;
|
isFirstLaunch = true;
|
||||||
|
|
|
@ -328,6 +328,10 @@ CWindow* Events::remapWindow(int windowID, bool wasfloating, int forcemonitor) {
|
||||||
g_pWindowManager->Values[0] = XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_FOCUS_CHANGE;
|
g_pWindowManager->Values[0] = XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_FOCUS_CHANGE;
|
||||||
xcb_change_window_attributes_checked(g_pWindowManager->DisplayConnection, windowID, XCB_CW_EVENT_MASK, g_pWindowManager->Values);
|
xcb_change_window_attributes_checked(g_pWindowManager->DisplayConnection, windowID, XCB_CW_EVENT_MASK, g_pWindowManager->Values);
|
||||||
|
|
||||||
|
// make the last window top (animations look better)
|
||||||
|
g_pWindowManager->setAWindowTop(g_pWindowManager->LastWindow);
|
||||||
|
|
||||||
|
// Focus
|
||||||
g_pWindowManager->setFocusedWindow(windowID);
|
g_pWindowManager->setFocusedWindow(windowID);
|
||||||
|
|
||||||
// Make all floating windows above
|
// Make all floating windows above
|
||||||
|
|
|
@ -13,6 +13,7 @@ void AnimationUtil::move() {
|
||||||
// Now we are (or should be, lul) thread-safe.
|
// Now we are (or should be, lul) thread-safe.
|
||||||
for (auto& window : g_pWindowManager->windows) {
|
for (auto& window : g_pWindowManager->windows) {
|
||||||
// check if window needs an animation.
|
// check if window needs an animation.
|
||||||
|
window.setIsAnimated(false);
|
||||||
|
|
||||||
if (ConfigManager::getInt("anim.enabled") == 0 || window.getIsFloating()) {
|
if (ConfigManager::getInt("anim.enabled") == 0 || window.getIsFloating()) {
|
||||||
// Disabled animations. instant warps.
|
// Disabled animations. instant warps.
|
||||||
|
@ -31,6 +32,7 @@ void AnimationUtil::move() {
|
||||||
|
|
||||||
if (VECTORDELTANONZERO(window.getRealPosition(), window.getEffectivePosition())) {
|
if (VECTORDELTANONZERO(window.getRealPosition(), window.getEffectivePosition())) {
|
||||||
Debug::log(LOG, "Updating position animations for " + std::to_string(window.getDrawable()) + " delta: " + std::to_string(ANIMATIONSPEED));
|
Debug::log(LOG, "Updating position animations for " + std::to_string(window.getDrawable()) + " delta: " + std::to_string(ANIMATIONSPEED));
|
||||||
|
window.setIsAnimated(true);
|
||||||
|
|
||||||
// we need to update it.
|
// we need to update it.
|
||||||
window.setDirty(true);
|
window.setDirty(true);
|
||||||
|
@ -44,6 +46,7 @@ void AnimationUtil::move() {
|
||||||
|
|
||||||
if (VECTORDELTANONZERO(window.getRealSize(), window.getEffectiveSize())) {
|
if (VECTORDELTANONZERO(window.getRealSize(), window.getEffectiveSize())) {
|
||||||
Debug::log(LOG, "Updating size animations for " + std::to_string(window.getDrawable()) + " delta: " + std::to_string(ANIMATIONSPEED));
|
Debug::log(LOG, "Updating size animations for " + std::to_string(window.getDrawable()) + " delta: " + std::to_string(ANIMATIONSPEED));
|
||||||
|
window.setIsAnimated(true);
|
||||||
|
|
||||||
// we need to update it.
|
// we need to update it.
|
||||||
window.setDirty(true);
|
window.setDirty(true);
|
||||||
|
@ -54,6 +57,12 @@ void AnimationUtil::move() {
|
||||||
|
|
||||||
window.setRealSize(Vector2D(parabolic(REALSIZ.x, EFFSIZ.x, ANIMATIONSPEED), parabolic(REALSIZ.y, EFFSIZ.y, ANIMATIONSPEED)));
|
window.setRealSize(Vector2D(parabolic(REALSIZ.x, EFFSIZ.x, ANIMATIONSPEED), parabolic(REALSIZ.y, EFFSIZ.y, ANIMATIONSPEED)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set not animated if already done here
|
||||||
|
if (!VECTORDELTANONZERO(window.getRealPosition(), window.getEffectivePosition())
|
||||||
|
&& !VECTORDELTANONZERO(window.getRealSize(), window.getEffectiveSize())) {
|
||||||
|
window.setIsAnimated(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updateRequired)
|
if (updateRequired)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "window.hpp"
|
#include "window.hpp"
|
||||||
#include "windowManager.hpp"
|
#include "windowManager.hpp"
|
||||||
|
|
||||||
CWindow::CWindow() { this->setDead(false); this->setMasterChildIndex(0); this->setMaster(false); this->setCanKill(false); this->setImmovable(false); this->setNoInterventions(false); this->setDirty(true); this->setFullscreen(false); this->setIsFloating(false); this->setParentNodeID(0); this->setChildNodeAID(0); this->setChildNodeBID(0); this->setName(""); }
|
CWindow::CWindow() { this->setFirstAnimFrame(true); this->setIsAnimated(false); this->setDead(false); this->setMasterChildIndex(0); this->setMaster(false); this->setCanKill(false); this->setImmovable(false); this->setNoInterventions(false); this->setDirty(true); this->setFullscreen(false); this->setIsFloating(false); this->setParentNodeID(0); this->setChildNodeAID(0); this->setChildNodeBID(0); this->setName(""); }
|
||||||
CWindow::~CWindow() { }
|
CWindow::~CWindow() { }
|
||||||
|
|
||||||
void CWindow::generateNodeID() {
|
void CWindow::generateNodeID() {
|
||||||
|
|
|
@ -76,6 +76,9 @@ public:
|
||||||
EXPOSED_MEMBER(MasterChildIndex, int, i);
|
EXPOSED_MEMBER(MasterChildIndex, int, i);
|
||||||
EXPOSED_MEMBER(Dead, bool, b);
|
EXPOSED_MEMBER(Dead, bool, b);
|
||||||
|
|
||||||
|
// Animating cheaply
|
||||||
|
EXPOSED_MEMBER(IsAnimated, bool, b);
|
||||||
|
EXPOSED_MEMBER(FirstAnimFrame, bool, b);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -380,15 +380,11 @@ void CWindowManager::refreshDirtyWindows() {
|
||||||
xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, Values);
|
xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, Values);
|
||||||
|
|
||||||
// Apply rounded corners, does all the checks inside
|
// Apply rounded corners, does all the checks inside
|
||||||
applyRoundedCornersToWindow(&window);
|
applyShapeToWindow(&window);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Values[0] = (int)window.getRealSize().x;
|
|
||||||
Values[1] = (int)window.getRealSize().y;
|
|
||||||
xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, Values);
|
|
||||||
|
|
||||||
// Update the position because the border makes the window jump
|
// Update the position because the border makes the window jump
|
||||||
// I have added the bordersize vec2d before in the setEffectiveSizePosUsingConfig function.
|
// I have added the bordersize vec2d before in the setEffectiveSizePosUsingConfig function.
|
||||||
Values[0] = (int)window.getRealPosition().x - ConfigManager::getInt("border_size");
|
Values[0] = (int)window.getRealPosition().x - ConfigManager::getInt("border_size");
|
||||||
|
@ -407,8 +403,25 @@ void CWindowManager::refreshDirtyWindows() {
|
||||||
xcb_change_window_attributes(DisplayConnection, window.getDrawable(), XCB_CW_BORDER_PIXEL, Values);
|
xcb_change_window_attributes(DisplayConnection, window.getDrawable(), XCB_CW_BORDER_PIXEL, Values);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply rounded corners, does all the checks inside
|
// If it isn't animated or we have non-cheap animations, update the real size
|
||||||
applyRoundedCornersToWindow(&window);
|
if (!window.getIsAnimated() || ConfigManager::getInt("anim.cheap") == 0) {
|
||||||
|
Values[0] = (int)window.getRealSize().x;
|
||||||
|
Values[1] = (int)window.getRealSize().y;
|
||||||
|
xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, Values);
|
||||||
|
window.setFirstAnimFrame(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ConfigManager::getInt("anim.cheap") == 1 && window.getFirstAnimFrame() && window.getIsAnimated()) {
|
||||||
|
// first frame, fix the size if smaller
|
||||||
|
window.setFirstAnimFrame(false);
|
||||||
|
if (window.getRealSize().x < window.getEffectiveSize().x || window.getRealSize().y < window.getEffectiveSize().y) {
|
||||||
|
Values[0] = (int)window.getEffectiveSize().x;
|
||||||
|
Values[1] = (int)window.getEffectiveSize().y;
|
||||||
|
xcb_configure_window(DisplayConnection, window.getDrawable(), XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, Values);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
applyShapeToWindow(&window);
|
||||||
|
|
||||||
Debug::log(LOG, "Refreshed dirty window, with an ID of " + std::to_string(window.getDrawable()));
|
Debug::log(LOG, "Refreshed dirty window, with an ID of " + std::to_string(window.getDrawable()));
|
||||||
}
|
}
|
||||||
|
@ -432,11 +445,11 @@ void CWindowManager::setFocusedWindow(xcb_drawable_t window) {
|
||||||
|
|
||||||
// Apply rounded corners, does all the checks inside.
|
// Apply rounded corners, does all the checks inside.
|
||||||
// The border changed so let's not make it rectangular maybe
|
// The border changed so let's not make it rectangular maybe
|
||||||
applyRoundedCornersToWindow(g_pWindowManager->getWindowFromDrawable(window));
|
applyShapeToWindow(g_pWindowManager->getWindowFromDrawable(window));
|
||||||
|
|
||||||
LastWindow = window;
|
LastWindow = window;
|
||||||
|
|
||||||
applyRoundedCornersToWindow(g_pWindowManager->getWindowFromDrawable(window));
|
applyShapeToWindow(g_pWindowManager->getWindowFromDrawable(window));
|
||||||
|
|
||||||
// set focus in X11
|
// set focus in X11
|
||||||
xcb_set_input_focus(DisplayConnection, XCB_INPUT_FOCUS_POINTER_ROOT, window, XCB_CURRENT_TIME);
|
xcb_set_input_focus(DisplayConnection, XCB_INPUT_FOCUS_POINTER_ROOT, window, XCB_CURRENT_TIME);
|
||||||
|
@ -600,7 +613,7 @@ void CWindowManager::removeWindowFromVectorSafe(int64_t window) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWindowManager::applyRoundedCornersToWindow(CWindow* pWindow) {
|
void CWindowManager::applyShapeToWindow(CWindow* pWindow) {
|
||||||
if (!pWindow)
|
if (!pWindow)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1513,6 +1526,11 @@ void CWindowManager::setAllFloatingWindowsTop() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CWindowManager::setAWindowTop(xcb_window_t window) {
|
||||||
|
Values[0] = XCB_STACK_MODE_ABOVE;
|
||||||
|
xcb_configure_window(g_pWindowManager->DisplayConnection, window, XCB_CONFIG_WINDOW_STACK_MODE, Values);
|
||||||
|
}
|
||||||
|
|
||||||
bool CWindowManager::shouldBeFloatedOnInit(int64_t window) {
|
bool CWindowManager::shouldBeFloatedOnInit(int64_t window) {
|
||||||
// Should be floated also sets some properties
|
// Should be floated also sets some properties
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,7 @@ public:
|
||||||
|
|
||||||
void setAllWindowsDirty();
|
void setAllWindowsDirty();
|
||||||
void setAllFloatingWindowsTop();
|
void setAllFloatingWindowsTop();
|
||||||
|
void setAWindowTop(xcb_window_t);
|
||||||
|
|
||||||
SMonitor* getMonitorFromWindow(CWindow*);
|
SMonitor* getMonitorFromWindow(CWindow*);
|
||||||
SMonitor* getMonitorFromCursor();
|
SMonitor* getMonitorFromCursor();
|
||||||
|
@ -130,7 +131,7 @@ private:
|
||||||
void cleanupUnusedWorkspaces();
|
void cleanupUnusedWorkspaces();
|
||||||
xcb_visualtype_t* setupColors(const int&);
|
xcb_visualtype_t* setupColors(const int&);
|
||||||
void updateRootCursor();
|
void updateRootCursor();
|
||||||
void applyRoundedCornersToWindow(CWindow* pWindow);
|
void applyShapeToWindow(CWindow* pWindow);
|
||||||
SMonitor* getMonitorFromWorkspace(const int&);
|
SMonitor* getMonitorFromWorkspace(const int&);
|
||||||
void recalcEntireWorkspace(const int&);
|
void recalcEntireWorkspace(const int&);
|
||||||
void fixMasterWorkspaceOnClosed(CWindow* pWindow);
|
void fixMasterWorkspaceOnClosed(CWindow* pWindow);
|
||||||
|
|
Loading…
Reference in a new issue