LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-13-2018, 07:17 PM   #1
Kamikadze
LQ Newbie
 
Registered: May 2018
Posts: 14

Rep: Reputation: Disabled
Exclamation The program on xlib is not set by coordinates


I'm using a graphical environment IceWM.
I wrote a gui program! Here's the code:
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: imgur.com/a/8FbELpo

I replaced this line:
Code:
w = XCreateWindow(d, root, 0, 0, 300, 100, 0,
		DefaultDepth(d, dscr), InputOutput, DefaultVisual(d, dscr), 
		CWBackPixel, &attrs);
to this:
Code:
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: 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?
 
Old 05-13-2018, 08:35 PM   #2
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
"A window manager may want to control the placement of subwindows"

from what I read and or remember from what I read the window Manager has the ultimate control over window placement.

X allows you (or, actually, the window manager) to control the placement and visibility of an entire client made up of a hierarchy of windows simply by manipulating the top-level window.




I'm still reading through this
http://menehune.opt.wfu.edu/Kokua/Ir...tml/index.html


here is another one
https://www.x.org/releases/X11R7.6/d...eating_Windows

another one
http://math.msu.su/~vvb/2course/Bori...ow/xintro.html

Last edited by BW-userx; 05-13-2018 at 08:53 PM.
 
Old 05-14-2018, 09:17 PM   #3
Kamikadze
LQ Newbie
 
Registered: May 2018
Posts: 14

Original Poster
Rep: Reputation: Disabled
Cool

Quote:
Originally Posted by BW-userx View Post
"A window manager may want to control the placement of subwindows"

from what I read and or remember from what I read the window Manager has the ultimate control over window placement.

X allows you (or, actually, the window manager) to control the placement and visibility of an entire client made up of a hierarchy of windows simply by manipulating the top-level window.




I'm still reading through this
http://menehune.opt.wfu.edu/Kokua/Ir...tml/index.html


here is another one
https://www.x.org/releases/X11R7.6/d...eating_Windows

another one
http://math.msu.su/~vvb/2course/Bori...ow/xintro.html
Does this mean that the developer of my graphics environment is at fault? Right now, I'll write to him.
 
Old 05-15-2018, 03:39 PM   #4
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by Kamikadze View Post
Does this mean that the developer of my graphics environment is at fault? Right now, I'll write to him.
I do not know, what did he tell you?
I forget which chap I read this, don't quote me, that the window manager has control over the window placement, hence the term "window manager", But, I too remember it stating that their is a way to get around that too, But I never made it that far into the doc yet. but it is within the first 3 or 4 chaps.

here it is, chap 1
Code:
Another important concept in X programming is that applications do not actually control such things
as where a window appears or what size it is. Given multiprocessor, multiclient access to the same 
workstation display, clients must not be dependent on a particular window configuration. Instead, a 
client gives hints about how long and where it would like to be displayed.

The screen layout or appearance and the style of user interaction with the system are left up to a 
separate program, called the window manager.
source:
http://menehune.opt.wfu.edu/Kokua/Ir...html/ch01.html

you might want to read through that how to.
 
Old 05-15-2018, 04:42 PM   #5
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,917

Rep: Reputation: 5035Reputation: 5035Reputation: 5035Reputation: 5035Reputation: 5035Reputation: 5035Reputation: 5035Reputation: 5035Reputation: 5035Reputation: 5035Reputation: 5035
When a window manager is running you can't rely on getting the geometry you pass to XCreateSimpleWindow(). Go read up on how to use size_hints and XSetWMProperties().

Last edited by GazL; 05-20-2018 at 08:09 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] CLI Program to do math transformation on a set of x,y coordinates ArcreVuch Linux - Software 6 08-22-2017 06:48 PM
how to set background image on display xlib Roy_SRC Programming 7 01-15-2017 05:41 PM
[Xlib/motif] Xlib: sequence lost in reply type tentoni Programming 2 01-10-2014 12:18 PM
run set-uid shell program in ubuntu and set premission 4755 goldengriff Ubuntu 12 11-20-2013 02:51 AM
XLib program crashes with BadWindow jasonar79 Programming 0 03-15-2004 03:34 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration