You are not logged in.

#1 2018-05-12 20:01:40

Kamikadze
Member
From: London
Registered: 2018-04-22
Posts: 16

The program on xlib is not set by coordinates

I wrote a gui program! Here's the code:

#include <stdio.h>
#include <X11/Xlib.h>
#include <unistd.h>

int main()
{
	Display *d;
	d = XOpenDisplay(NULL);
	if(d == NULL) {
		printf("Fail\n");
		return 1;
	}

	int dscr = DefaultScreen(d);
	XSetWindowAttributes attrs;
	attrs.background_pixel = WhitePixel(d, dscr);

	int root = RootWindow(d, dscr);
	Window w;
	w = XCreateWindow(d, root, 0, 0, 300, 100, 0,
		DefaultDepth(d, dscr), InputOutput, DefaultVisual(d, dscr), 
		CWBackPixel, &attrs);
	XStoreName(d, w, "Hello!");

	XMapWindow(d, w);
	XFlush(d);

	sleep(3);

	XDestroyWindow(d, w);

	XCloseDisplay(d);
	return 0;
}

Here is the screenshot of the result: https://imgur.com/a/8FbELpo

I replaced this line:

w = XCreateWindow(d, root, 0, 0, 300, 100, 0,
		DefaultDepth(d, dscr), InputOutput, DefaultVisual(d, dscr), 
		CWBackPixel, &attrs);

to this:

w = XCreateWindow(d, root, 400, 300, 300, 100, 0,
		DefaultDepth(d, dscr), InputOutput, DefaultVisual(d, dscr), 
		CWBackPixel, &attrs);

And here is the screenshot of the result: https://imgur.com/a/G6lqvIk

As you can see, the window did not change its coordinates, although everything was fine before. Before this recently, I updated the system. That's the problem and I do not know how to decide who will help me?

Offline

Board footer

Powered by FluxBB