Find the answer to your Linux question:
Results 1 to 7 of 7
Hi, I'm trying to code a simple window manager. I use MapRequest event to know about all windows which are going to be mapped (let's call them A-win). I create ...
  1. #1
    Just Joined!
    Join Date
    Jun 2008
    Posts
    13

    Coding WM - windows sizes problem

    Hi,
    I'm trying to code a simple window manager. I use MapRequest event to know about all windows which are going to be mapped (let's call them A-win). I create my own window (call it MY-win), reparent A-win and put it onto MY-win as a child. This works fine.
    But I'm facing a problem with size of the A-win. At the time when MapRequest event arrives, I use XGetWindowAttributes to get the size of A-win window and according to this site I set the size of MY-win. The problem is that this size is usually smaller than I expect it to be. (This usually happens for QT apps). The A-win must be then resized (by someone) to its real size, but even if I capture ConfigureRequest and ResizeRequest, I don't get any of these events for the A-win.
    So the result is that I see only a part of the A-win, because MY-win is too small.

    What should I do to get know about changing of size of the A-win?

    Hope it's at least a little understandable.
    Thanks for any suggestions.

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    Could you please post the code that extracts the window size from the XWindowAttributes * structure?
    --
    Bill

    Old age and treachery will overcome youth and skill.

  3. #3
    Just Joined!
    Join Date
    Jun 2008
    Posts
    13
    Sure I can. But there's no trick there, at least I hope so.
    Code:
    XEvent event;
    XNextEvent(display,&event);
    switch (event.type) {
       case MapRequest:
          int width, height;
          XWindowAttributes wa;
          XGetWindowAttributes(display,event.xmaprequest.window,&wa);
          width=wa.width;
          height=wa.height;
    }
    This works fine for xcalc, xterm, xclock, but not for Kate, KEdit, Seamonkey...

  4. #4
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    XWindowAttributes structure members width and height do not include the window border.

    Try this and see whether your problem changes any:
    Code:
    XEvent event;
    XNextEvent(display,&event);
    switch (event.type) {
       case MapRequest:
          int width, height;
          XWindowAttributes wa;
          XGetWindowAttributes(display,event.xmaprequest.window,&wa);
          width=wa.width+2*wa.border_width;
          height=wa.height+2*wa.border_width;
    }
    --
    Bill

    Old age and treachery will overcome youth and skill.

  5. #5
    Just Joined!
    Join Date
    Jun 2008
    Posts
    13
    Thanks for reply, but this is not the problem. Because sometimes my window is even bigger than it should be (eg. Kate->OpenFile dialog) and sometimes it is twice smaller than it should be. I assume the border cannot be that big.

  6. #6
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    I've never coded a window manager, so I'm out of my depth here. I do know that you'll eventually want the corrections I made in my previous post, so you may as well put them in.

    After that, get the source for a relatively simple window manager. If you don't have a favorite simple window manager, I'd recommend fvwm2, which is what I use. From what I've heard, twm might also be a good candidate. (That's "Tom's Window Manager".)

    Then compile that window manager, get it running, and add code which logs anything of interest to you to a log file. I'd start with recording events which come to the main event loop. Make sure that QT applications and Kate (including the open file dialog) run ok.

    Then try the same thing with your own window manager. Log events and other items of interest.

    Compare the two log files to see what's different.

    I wish I could help more. Sorry.
    --
    Bill

    Old age and treachery will overcome youth and skill.

  7. #7
    Just Joined!
    Join Date
    Jun 2008
    Posts
    13
    Hi all,
    I partially resolved the problem. The trick is in using window size hints. Call XGetWMNormalHints, look at flags which hints it returned and use the suggested sizes.
    This resolves the QT apps and works fine. However, it doesn't work with SeaMonkey. A new SeaMonkey window size is set to 200x200, it has PMinSize and PWinGravity flags, but minimal sizes are set to zero. So 200x200 are the only sizes I know and they are incorrect, of course.
    If anyone knows the solution, it would be highly appreciated.
    Thanks in advance.
    --pitris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...