Sponsored Content
Top Forums Programming Xlib search window by his name Post 302932168 by Loustak on Monday 19th of January 2015 03:16:45 PM
Old 01-19-2015
Xlib search window by his name

Hello,
I just try to get the control of a Window by searching his name. I curretly do that :


Code:
Window CMD::window_from_name_search(Display *display, Window current, char const *needle)
{
    Window retval, root, parent, *children;
    unsigned children_count;
    char *name = NULL;

    /* Check if this window has the name we seek */
    if(XFetchName(display, current, &name) > 0) {
        int r = strcmp(needle, name);
        XFree(name);
        if(r == 0) {
            return current;
        }
    }

    retval = 0;

    /* If it does not: check all subwindows recursively. */
    if(0 != XQueryTree(display, current, &root, &parent, &children, &children_count)) {
        unsigned i;
        for(i = 0; i < children_count; ++i) {
            Window win = window_from_name_search(display, children[i], needle);

            if(win != 0) {
                    retval = win;
                break;
            }
        }
        XFree(children);
    }
    return retval;
}

void CMD::window_from_name(char const *name)
{
    m_display = XOpenDisplay(NULL);
    m_root_win = XDefaultRootWindow(m_display);
    m_screen = DefaultScreenOfDisplay(m_display);
    m_window_terminal = window_from_name_search(m_display, m_root_win, name);
}

That previous code should let me play with the window, no ?
But I get an error, a bad window value. I don't Know why. Ps: I'm closing the connection with the X server in the destructor of my class CMD, and I think the problem is here.
Thanks for helping.

EDIT: After some search the m_window_terminal is set to NULL if I don't add a std::cout << "" << std::endl; in the previous function. WHY ?

Last edited by Loustak; 01-19-2015 at 04:22 PM..
 

10 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

window 2000 professional not pinging my window 98 system.

Hello, We someone help me resolve this problem. I have window 2000 professional, windows 98 and Unixware 7.0.1 on the network. I was able to establish connection with all. However, l was unable to ping window 98 from window 2000 professional. I was able to ping the window 2000 from the window... (10 Replies)
Discussion started by: kayode
10 Replies

2. UNIX for Advanced & Expert Users

xlib error

Hello! Im running tight VNC on Red Hat Enterprise Linux 4.0. How can I increase the number of X clients that I can run in a VNC session?I need to run aproximately 500 programs in one VNC session, but at this time I can only 236 -> i've tryed to launch 250 xclock's in background and when it... (3 Replies)
Discussion started by: karpoand
3 Replies

3. UNIX and Linux Applications

vncserver xlib error

Hello! Im running tight VNC on Red Hat Enterprise Linux 4.0. How can I increase the number of X clients that I can run in a VNC session?I need to run aproximately 500 programs in one VNC session, but at this time I can only 236 -> i've tryed to launch 250 xclock's in background and when it... (0 Replies)
Discussion started by: karpoand
0 Replies

4. Programming

problems with drawing in x using xlib

Hi all, I'm currently learning xlib and I've encountered a bizarre mistake: function calls such as XDrawPoint, XDrawLine, etc., don't seem to work; a blank window with nothing in is appears. I believe this has something to do with the window manager I use, fluxbox. After checking the code and... (0 Replies)
Discussion started by: hydronium
0 Replies

5. Red Hat

Maximizing X window without Window Switcher

Hi everyone! I have a strange situation. I'm running an NX remote Gnome desktop session. On the remote machine, there is a whole load of unsaved data in a window. A problem that I've been having with this NX session is that I can't load Gnome Applets, including the Window Switcher. So.. when I... (0 Replies)
Discussion started by: alexandicity
0 Replies

6. UNIX for Dummies Questions & Answers

Xlib Errors

Hi, I am handling user issues in my team. Users have their Unix session running on Citrix MFU. Recently, I was suppose to address a user issue which is as below: Gets the below error when tries to open nedit: Xlib: connection to ":165.0" refused by server Xlib: Client is not... (1 Reply)
Discussion started by: mspatil0037
1 Replies

7. Programming

Xlib registering

hey, Im new to the linux world. Lately, I have tried to create a glx window with xlib, making it a popup window(fullscreen) so I set override_redirect to true. Im happy with the removed borders, but apparantly, the application doesnt show up in the left bar in ubuntu, neither when I press alt... (4 Replies)
Discussion started by: thedardanius
4 Replies

8. Solaris

Restacking x11/Xlib Window

I have a full screen top level window (application) on Solaris 10. We have a minimal window manager (DTWM), because of the critical nature of the app. On top of the first application, we have another application with a top level window, that covers the upper left area of the first application. Now,... (0 Replies)
Discussion started by: JenniferKuiper
0 Replies

9. UNIX for Dummies Questions & Answers

Search and replace with a sliding window

Hi Unix Gurus, I have a file with data like: >header_1 TCCCCGA >header_2 CCAATTGGGTA The data to work with starts from the next line after '>header_xx'. (1) I want to search the three letter patterns 'CHH' or 'DDG' and replace C and G by exclamation ! so that CHH becomes !HH and DDG... (3 Replies)
Discussion started by: Fahmida
3 Replies

10. UNIX for Beginners Questions & Answers

Toggle between xterm window and standard terminal window

Is it possible to toggle back and forth between an xterm invoked from one tty, and a shell invoked from a different tty? I am running Centos 7 with KDE and booting in non-graphic mode. After logging in on the default window (/dev/tty1) , I can then use ALT-F2 to access a new window (/dev/tty2),... (1 Reply)
Discussion started by: rhgscty
1 Replies
XReparentWindow(3)						  XLIB FUNCTIONS						XReparentWindow(3)

NAME
XReparentWindow - reparent windows SYNTAX
int XReparentWindow(Display *display, Window w, Window parent, int x, int y); ARGUMENTS
display Specifies the connection to the X server. parent Specifies the parent window. w Specifies the window. x y Specify the x and y coordinatesof the position in the new parent window. DESCRIPTION
If the specified window is mapped, XReparentWindow automatically performs an UnmapWindow request on it, removes it from its current posi- tion in the hierarchy, and inserts it as the child of the specified parent. The window is placed in the stacking order on top with respect to sibling windows. After reparenting the specified window, XReparentWindow causes the X server to generate a ReparentNotify event. The override_redirect mem- ber returned in this event is set to the window's corresponding attribute. Window manager clients usually should ignore this window if this member is set to True. Finally, if the specified window was originally mapped, the X server automatically performs a MapWindow request on it. The X server performs normal exposure processing on formerly obscured windows. The X server might not generate Expose events for regions from the initial UnmapWindow request that are immediately obscured by the final MapWindow request. A BadMatch error results if: o The new parent window is not on the same screen as the old parent window. o The new parent window is the specified window or an inferior of the specified window. o The new parent is InputOnly, and the window is not. o The specified window has a ParentRelative background, and the new parent window is not the same depth as the specified window. XReparentWindow can generate BadMatch and BadWindow errors. DIAGNOSTICS
BadWindow A value for a Window argument does not name a defined Window. SEE ALSO
XChangeSaveSet(3) Xlib - C Language X Interface X Version 11 libX11 1.5.0 XReparentWindow(3)
All times are GMT -4. The time now is 02:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy