fix: tearing
This commit is contained in:
parent
8e2ccebe69
commit
5a09672698
1 changed files with 9 additions and 5 deletions
|
|
@ -68,7 +68,6 @@ void WindowManager::handle_events(XEvent &GeneralEvent) {
|
||||||
{
|
{
|
||||||
if (!isDisplayReady)
|
if (!isDisplayReady)
|
||||||
isDisplayReady = true;
|
isDisplayReady = true;
|
||||||
display_image();
|
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -82,9 +81,11 @@ void WindowManager::loop() {
|
||||||
handle_events(GeneralEvent);
|
handle_events(GeneralEvent);
|
||||||
}
|
}
|
||||||
if (isDisplayReady) {
|
if (isDisplayReady) {
|
||||||
update_image(this->render);
|
if (this->needUpdate) {
|
||||||
display_image();
|
update_image(this->render);
|
||||||
XSync(this->MainDisplay, false);
|
display_image();
|
||||||
|
}
|
||||||
|
// XSync(this->MainDisplay, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -104,7 +105,10 @@ void WindowManager::display_image() {
|
||||||
image.bytes_per_line = this->WindowWidth * 4;
|
image.bytes_per_line = this->WindowWidth * 4;
|
||||||
image.bits_per_pixel = 32;
|
image.bits_per_pixel = 32;
|
||||||
|
|
||||||
XPutImage(MainDisplay, MainWindow, DefaultGC(MainDisplay, 0), &image, 0, 0, 0, 0, WindowWidth, WindowHeight);
|
const Pixmap pixmap = XCreatePixmap(MainDisplay, MainWindow, WindowWidth, WindowHeight, image.depth);
|
||||||
|
XPutImage(MainDisplay, pixmap, DefaultGC(MainDisplay, 0), &image, 0, 0, 0, 0, WindowWidth, WindowHeight);
|
||||||
|
XCopyArea(MainDisplay, pixmap, MainWindow, DefaultGC(MainDisplay, 0), 0, 0, WindowWidth, WindowHeight, 0, 0);
|
||||||
|
XFreePixmap(MainDisplay, pixmap);
|
||||||
XFlush(MainDisplay);
|
XFlush(MainDisplay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue