Fix bug causing a crash when changing resolution of the monitor while in a session

This commit is contained in:
loki
2019-12-14 16:47:17 +01:00
parent 072fc00aca
commit 5541f9dca8
2 changed files with 24 additions and 11 deletions

View File

@@ -86,13 +86,17 @@ std::string get_local_ip() { return get_local_ip(AF_INET); }
struct display_attr_t {
display_attr_t() : display { XOpenDisplay(nullptr) }, window { DefaultRootWindow(display) }, attr {} {
XGetWindowAttributes(display, window, &attr);
refresh();
}
~display_attr_t() {
XCloseDisplay(display);
}
void refresh() {
XGetWindowAttributes(display, window, &attr);
}
Display *display;
Window window;
XWindowAttributes attr;
@@ -110,6 +114,7 @@ display_t display() {
img_t snapshot(display_t &display_void) {
auto &display = *((display_attr_t*)display_void.get());
display.refresh();
XImage *img { XGetImage(
display.display,
display.window,