✅ Fix window size test (WM_NORMAL_HINTS handling)
This commit is contained in:
parent
a4b48b60bf
commit
24a66e41d1
11 changed files with 96 additions and 15 deletions
57
test/utils.c
Normal file
57
test/utils.c
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#include "utils.h"
|
||||
#include "test_set_up.h"
|
||||
|
||||
#define MAX_COLOR 65535
|
||||
|
||||
const time_t USER_DELAY_S = 1;
|
||||
const clock_t USER_DELAY = USER_DELAY_S * CLOCKS_PER_SEC;
|
||||
|
||||
XColor red(float intensity) {
|
||||
XColor red;
|
||||
red.red = intensity * MAX_COLOR;
|
||||
XAllocColor(test_display, XDefaultColormap(test_display, DefaultScreen(test_display)), &red);
|
||||
return red;
|
||||
}
|
||||
|
||||
XColor blue(float intensity) {
|
||||
XColor blue;
|
||||
blue.blue = intensity * MAX_COLOR;
|
||||
XAllocColor(test_display, XDefaultColormap(test_display, DefaultScreen(test_display)), &blue);
|
||||
return blue;
|
||||
}
|
||||
|
||||
int wait_visibility(Display* display, Window window) {
|
||||
int visibility;
|
||||
XSelectInput(test_display, window, VisibilityChangeMask);
|
||||
|
||||
clock_t start = clock();
|
||||
while((clock() - start) < USER_DELAY) {
|
||||
XEvent e;
|
||||
XCheckWindowEvent(test_display, window, VisibilityChangeMask, &e);
|
||||
visibility = e.xvisibility.state;
|
||||
}
|
||||
return visibility;
|
||||
}
|
||||
|
||||
void wait_array_visibility(Display* display, int N, Window* windows, int* visibilities) {
|
||||
for(auto i = 0; i < N; i++)
|
||||
XSelectInput(test_display, windows[i], VisibilityChangeMask);
|
||||
|
||||
clock_t user_time = clock();
|
||||
while((clock() - user_time) < USER_DELAY * N) {
|
||||
for(auto i = 0; i < N; i++) {
|
||||
XEvent e;
|
||||
XCheckWindowEvent(test_display, windows[i], VisibilityChangeMask, &e);
|
||||
visibilities[i] = e.xvisibility.state;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Window parent(Display* display, Window window) {
|
||||
Window _root;
|
||||
Window parent;
|
||||
Window* _children;
|
||||
unsigned int _children_count;
|
||||
XQueryTree(test_display, window, &_root, &parent, &_children, &_children_count);
|
||||
return parent;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue