mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-05-07 15:19:56 +09:00
Reduce cpu usage when ui is not visible
This commit is contained in:
@@ -39,7 +39,8 @@ namespace gsr {
|
|||||||
|
|
||||||
void handle_events();
|
void handle_events();
|
||||||
void on_event(mgl::Event &event);
|
void on_event(mgl::Event &event);
|
||||||
void draw();
|
// Returns false if not visible
|
||||||
|
bool draw();
|
||||||
|
|
||||||
void show();
|
void show();
|
||||||
void hide();
|
void hide();
|
||||||
|
|||||||
@@ -279,20 +279,20 @@ namespace gsr {
|
|||||||
process_key_bindings(event);
|
process_key_bindings(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overlay::draw() {
|
bool Overlay::draw() {
|
||||||
update_notification_process_status();
|
update_notification_process_status();
|
||||||
update_gsr_process_status();
|
update_gsr_process_status();
|
||||||
|
|
||||||
if(!visible)
|
if(!visible)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
if(page_stack.empty()) {
|
if(page_stack.empty()) {
|
||||||
hide();
|
hide();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!window)
|
if(!window)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
window->clear();
|
window->clear();
|
||||||
|
|
||||||
@@ -312,6 +312,8 @@ namespace gsr {
|
|||||||
page_stack.draw(*window, mgl::vec2f(0.0f, 0.0f));
|
page_stack.draw(*window, mgl::vec2f(0.0f, 0.0f));
|
||||||
|
|
||||||
window->display();
|
window->display();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overlay::show() {
|
void Overlay::show() {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
#include <mglpp/mglpp.hpp>
|
#include <mglpp/mglpp.hpp>
|
||||||
@@ -160,7 +161,8 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
global_hotkeys.poll_events();
|
global_hotkeys.poll_events();
|
||||||
overlay->handle_events();
|
overlay->handle_events();
|
||||||
overlay->draw();
|
if(!overlay->draw())
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "info: shutting down!\n");
|
fprintf(stderr, "info: shutting down!\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user