Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 04-27-2009, 12:54 PM   #1
Registered: Mar 2006
Posts: 622

Rep: Reputation: 42
setting the window position in X

Hi all,
I've recently been using code which opens up a few windows, however for the life of me I can't set the window position? I thought XGetGeometry x and y parameters set where it would be however this seems to make no difference. I've also set x and y in XCreateWindow with no luck. Is there a way I can set my window positions?

Last edited by knobby67; 04-27-2009 at 01:03 PM.
Old 04-28-2009, 05:52 AM   #2
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
That does sound strange, can we see the XCreateWindow code?
Old 04-29-2009, 05:37 AM   #3
Registered: Mar 2006
Posts: 622

Original Poster
Rep: Reputation: 42
he's my code

   else       /*window mode rather than full screen*/
        /* create a window in window mode*/
        (*screenlist)->attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask |
        screenlist[count]->win = XCreateWindow( screenlist[count]->displaypointer, RootWindow(screenlist[count]->displaypointer, vi->screen),
           screenlist[count]->xpos,screenlist[count]->ypos, screenlist[count]->width, screenlist[count]->height, 0, vi->depth, InputOutput, vi->visual,
            CWBorderPixel | CWColormap | CWEventMask, &screenlist[count]->attr);
        wmDelete = XInternAtom( screenlist[count]->displaypointer, "WM_DELETE_WINDOW", True);
        XSetWMProtocols( screenlist[count]->displaypointer, screenlist[count]->win, &wmDelete, 1);
        XSetStandardProperties( screenlist[count]->displaypointer, screenlist[count]->win, "screen",
            "screen", None, NULL, 0, NULL); /*need to add screen number*/
        XMapRaised( screenlist[count]->displaypointer, screenlist[count]->win);

Old 04-29-2009, 07:30 AM   #4
Registered: Sep 2007
Location: Mariposa
Distribution: FreeBSD,Debian wheezy
Posts: 811

Rep: Reputation: 178Reputation: 178
If you were to make the new window a child of a window that's not the root window, you'd have no problem.

But since this new window is a child of the root window, then whatever window manager you're running intercepts the XCreateWindow() call and gets to enforce whatever policies it wishes about the placement of windows which are children of the root window.

In theory, your window manager could in some way allow you to have complete control over this; you'd have to take a look at its documentation.
Old 04-29-2009, 11:38 AM   #5
Registered: Jun 2007
Location: Bavaria
Distribution: slackware, xubuntu
Posts: 143

Rep: Reputation: 22
XGetGeometry will only tell you where the window currently is. For window placement and size manipulation there are functions like XMoveWindow / XMoveResizeWindow and XResizeWindow. Did you try those yet ? If those don't work you're probably indeed having a very restrictive window manager, and need to look there first.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trouble with window position kaelthas Linux - Software 4 04-22-2011 09:42 AM
Kdialog--control position of window pixellany Programming 1 06-08-2010 04:25 AM
Window Position txmedic03 Linux - General 1 03-26-2007 11:10 PM
default x window position bm1 Slackware 1 08-01-2005 05:03 PM
fluxbox window position BroX Linux - Software 0 12-15-2003 05:51 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:29 AM.

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