mirror of
https://github.com/hyprwm/Hypr.git
synced 2024-11-22 13:35:57 +01:00
sloppy fix for new windows frozen sometimes
if anyone knows a better one feel free
This commit is contained in:
parent
24db17f139
commit
8aadccd9e4
6 changed files with 48 additions and 15 deletions
|
@ -69,6 +69,12 @@ void Events::eventEnter(xcb_generic_event_t* event) {
|
|||
g_pWindowManager->setFocusedWindow(E->event);
|
||||
|
||||
PENTERWINDOW->setDirty(true);
|
||||
|
||||
if (PENTERWINDOW->getIsSleeping()) {
|
||||
// Wake it up, fixes some weird shenaningans
|
||||
wakeUpEvent(E->event);
|
||||
PENTERWINDOW->setIsSleeping(false);
|
||||
}
|
||||
}
|
||||
|
||||
void Events::eventLeave(xcb_generic_event_t* event) {
|
||||
|
@ -76,7 +82,16 @@ void Events::eventLeave(xcb_generic_event_t* event) {
|
|||
|
||||
RETURNIFBAR;
|
||||
|
||||
//
|
||||
const auto PENTERWINDOW = g_pWindowManager->getWindowFromDrawable(E->event);
|
||||
|
||||
if (!PENTERWINDOW)
|
||||
return;
|
||||
|
||||
if (PENTERWINDOW->getIsSleeping()) {
|
||||
// Wake it up, fixes some weird shenaningans
|
||||
wakeUpEvent(E->event);
|
||||
PENTERWINDOW->setIsSleeping(false);
|
||||
}
|
||||
}
|
||||
|
||||
void Events::eventDestroy(xcb_generic_event_t* event) {
|
||||
|
@ -190,16 +205,14 @@ CWindow* Events::remapFloatingWindow(int windowID, int forcemonitor) {
|
|||
|
||||
window.setSize(window.getDefaultSize());
|
||||
window.setPosition(window.getDefaultPosition());
|
||||
|
||||
// The anim util will take care of this.
|
||||
window.setEffectiveSize(window.getDefaultSize());
|
||||
window.setEffectivePosition(window.getDefaultPosition());
|
||||
|
||||
// Also sets the old one
|
||||
g_pWindowManager->calculateNewWindowParams(&window);
|
||||
|
||||
// Set real size. No animations in the beginning. Maybe later. TODO?
|
||||
window.setRealPosition(window.getEffectivePosition());
|
||||
window.setRealSize(window.getEffectiveSize());
|
||||
|
||||
// Add to arr
|
||||
g_pWindowManager->addWindowToVectorSafe(window);
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ void AnimationUtil::move() {
|
|||
|
||||
static std::chrono::time_point lastFrame = std::chrono::high_resolution_clock::now();
|
||||
const double DELTA = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - lastFrame).count();
|
||||
lastFrame = std::chrono::high_resolution_clock::now();
|
||||
|
||||
const double ANIMATIONSPEED = ((double)1 / (double)ConfigManager::getFloat("anim.speed")) * DELTA;
|
||||
|
||||
|
@ -22,10 +23,10 @@ void AnimationUtil::move() {
|
|||
|| VECTORDELTANONZERO(window.getRealSize(), window.getEffectiveSize())) {
|
||||
window.setDirty(true);
|
||||
updateRequired = true;
|
||||
}
|
||||
|
||||
window.setRealPosition(window.getEffectivePosition());
|
||||
window.setRealSize(window.getEffectiveSize());
|
||||
window.setRealPosition(window.getEffectivePosition());
|
||||
window.setRealSize(window.getEffectiveSize());
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
@ -67,6 +68,4 @@ void AnimationUtil::move() {
|
|||
|
||||
if (updateRequired)
|
||||
emptyEvent(); // send a fake request to update dirty windows
|
||||
|
||||
lastFrame = std::chrono::high_resolution_clock::now();
|
||||
}
|
|
@ -29,18 +29,35 @@ double parabolic(double from, double to, double incline) {
|
|||
return from + ((to - from) / incline);
|
||||
}
|
||||
|
||||
void emptyEvent() {
|
||||
void emptyEvent(xcb_drawable_t window) {
|
||||
xcb_expose_event_t exposeEvent;
|
||||
exposeEvent.window = 0;
|
||||
exposeEvent.window = window;
|
||||
exposeEvent.response_type = 0;
|
||||
exposeEvent.x = 0;
|
||||
exposeEvent.y = 0;
|
||||
exposeEvent.width = g_pWindowManager->Screen->width_in_pixels;
|
||||
exposeEvent.height = g_pWindowManager->Screen->height_in_pixels;
|
||||
xcb_send_event(g_pWindowManager->DisplayConnection, false, g_pWindowManager->Screen->root, XCB_EVENT_MASK_EXPOSURE, (char*)&exposeEvent);
|
||||
xcb_send_event(g_pWindowManager->DisplayConnection, false, window, XCB_EVENT_MASK_EXPOSURE, (char*)&exposeEvent);
|
||||
xcb_flush(g_pWindowManager->DisplayConnection);
|
||||
}
|
||||
|
||||
void wakeUpEvent(xcb_drawable_t window) {
|
||||
const auto PWINDOW = g_pWindowManager->getWindowFromDrawable(window);
|
||||
|
||||
if (!PWINDOW)
|
||||
return;
|
||||
|
||||
PWINDOW->setRealPosition(PWINDOW->getRealPosition() + Vector2D(1, 1));
|
||||
PWINDOW->setDirty(true);
|
||||
|
||||
g_pWindowManager->refreshDirtyWindows();
|
||||
|
||||
xcb_flush(g_pWindowManager->DisplayConnection);
|
||||
|
||||
PWINDOW->setRealPosition(PWINDOW->getRealPosition() - Vector2D(1, 1));
|
||||
PWINDOW->setDirty(true);
|
||||
}
|
||||
|
||||
bool xcbContainsAtom(xcb_get_property_reply_t* PROP, xcb_atom_t ATOM) {
|
||||
if (PROP == NULL || xcb_get_property_value_length(PROP) == 0)
|
||||
return false;
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
|
||||
std::string exec(const char* cmd);
|
||||
void clearLogs();
|
||||
void emptyEvent();
|
||||
void emptyEvent(xcb_drawable_t window = 0);
|
||||
void wakeUpEvent(xcb_drawable_t window);
|
||||
bool xcbContainsAtom(xcb_get_property_reply_t* PROP, xcb_atom_t ATOM);
|
||||
|
||||
double parabolic(double from, double to, double incline);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "window.hpp"
|
||||
#include "windowManager.hpp"
|
||||
|
||||
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() { this->setIsSleeping(true); 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() { }
|
||||
|
||||
void CWindow::generateNodeID() {
|
||||
|
|
|
@ -80,6 +80,9 @@ public:
|
|||
EXPOSED_MEMBER(IsAnimated, bool, b);
|
||||
EXPOSED_MEMBER(FirstAnimFrame, bool, b);
|
||||
|
||||
// Weird shenaningans
|
||||
EXPOSED_MEMBER(IsSleeping, bool, b);
|
||||
|
||||
private:
|
||||
|
||||
};
|
Loading…
Reference in a new issue