Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more tests, fixed multi test compiling #379

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions tests/centerpixel.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@


#include <X11/Xlib.h>
#include <X11/X.h>
#include "helper.h"







int
jnzjmp(void)
{
Expand Down
25 changes: 17 additions & 8 deletions tests/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>


Display *dpy;
int screen;
int sw;
int sh;
Window win;
Window root;
static Display *dpy;
static int screen;
static int sw;
static int sh;
static Window win;
static Window root;

static void
__test__start_basic(void)
Expand All @@ -29,14 +30,22 @@ __test__start_basic(void)


root = DefaultRootWindow(dpy);
srand(time(NULL));
}

static Window
__Create_Window(unsigned int color, int bw, int bwcolor)
{
XSetWindowAttributes wa =
{
.bit_gravity = NorthWestGravity,
///NorthWestGravity,
.backing_store = WhenMapped,
.border_pixel = bwcolor,
.background_pixel = color
};
unsigned int mask = CWBitGravity|CWBackingStore;
win = XCreateWindow(dpy, root, 0, 0, sw, sh, 0, DefaultDepth(dpy, screen), InputOutput, 0, mask, &wa);
unsigned long int mask = CWBitGravity|CWBackingStore|CWBorderPixel|CWBorderWidth|CWBackPixel;
win = XCreateWindow(dpy, root, 0, 0, sw, sh, bw, DefaultDepth(dpy, screen), InputOutput, 0, mask, &wa);
XMapWindow(dpy, win);
return win;
}
79 changes: 79 additions & 0 deletions tests/restack.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#include "helper.h"

#include <stdint.h>


int
jzjmp(void)
{
__test__start_basic();
Atom wtype = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
Atom wstate = XInternAtom(dpy, "_NET_WM_STATE", False);

Atom above = XInternAtom(dpy, "_NET_WM_STATE_ABOVE", False);
Atom modal = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_MODAL", False);
Atom dialog= XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
Atom dock = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DOCK", False);
Atom below = XInternAtom(dpy, "_NET_WM_STATE_BELOW", False);
__test__start_basic();


const int win_count = 5;
Window wins[win_count];


unsigned int red = 255;
unsigned int blue = 255 << 8;
unsigned int green = 255 << 16;


unsigned int color = 0;
int i;
for(i = 0; i < win_count; ++i)
{
switch(i % 3)
{
case 0:
color ^= red * rand();
case 1:
color ^= blue * rand();
case 2:
color ^= green * rand();
default:
color ^= rand();
while(color == UINT32_MAX || color == 0)
{ color ^= 255 * rand();
}
break;
}
Atom atom;
Atom state;
wins[i] = __Create_Window(color, 0, 0);
if((color & red) % 255 > 150)
{
atom = above;
state = wstate;
}
else if((color & blue) % 255 > 100)
{
atom = dock;
state = wtype;
}
else if((color & green) % 255 > 50)
{
atom = below;
state = wstate;
}
else
{
atom = above;
state = wstate;
}
XChangeProperty(dpy, wins[i], state, XA_ATOM, 32, PropModeReplace, (const unsigned char *)&atom, 1);
}

XEvent ev;
while(!XNextEvent(dpy, &ev));

return 0;
}