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
XSetWMName(3X11)						     MIT X11R4							  XSetWMName(3X11)

Name
       XSetWMName, XGetWMName, XStoreName, XFetchName - set or read a window's WM_NAME property

Syntax
       void XSetWMName(display, w, text_prop)
	  Display *display;
	  Window w;
	  XTextProperty *text_prop;

       Status XGetWMName(display, w, text_prop_return)
	  Display *display;
	  Window w;
	  XTextProperty *text_prop_return;

       XStoreName(display, w, window_name)
	  Display *display;
	  Window w;
	  char *window_name;

       Status XFetchName(display, w, window_name_return)
	  Display *display;
	  Window w;
	  char **window_name_return;

Arguments
       display	 Specifies the connection to the X server.

       text_prop Specifies the structure to be used.

       text_prop_return
		 Returns the structure.

       w	 Specifies the window.

       window_name
		 Specifies the window name, which should be a null-terminated string.

       window_name_return
		 Returns a pointer to the window name, which is a null-terminated string.

Description
       The convenience function performs a on the WM_NAME property.

       The convenience function performs an on the WM_NAME property.

       The function assigns the name passed to window_name to the specified window.  A window manager can display the window name in some promi-
       nent place, such as the title bar, to allow users to identify windows easily.  Some window managers may display a window's name in the win-
       dow's icon, although they are encouraged to use the window's icon name if one is provided by the application.

       can generate and errors.

       The function returns the name of the specified window.  If it succeeds, it returns nonzero; otherwise, no name has been set for the window,
       and it returns zero.  If the WM_NAME property has not been set for this window, sets window_name_return to NULL.  When finished with it, a
       client must free the window name string using

       can generate a error.

Properties
       WM_NAME	 Name of the application.

Diagnostics
       The server failed to allocate the requested resource or server memory.

       A value for a Window argument does not name a defined Window.

See Also
       XAllocClassHint(3X11), XAllocIconSize(3X11), XAllocSizeHints(3X11), XAllocWMHints(3X11), XFree(3X11), XSetCommand(3X11), XSetTransient-
       ForHint(3X11), XSetTextProperty(3X11), XSetWMClientMachine(3X11), XSetWMColormapWindows(3X11), XSetWMIconName(3X11), XSetWMProper-
       ties(3X11), XSetWMProtocols(3X11), XStringListToTextProperty(3X11)
       X Window System: The Complete Reference, Second Edition, Robert W. Scheifler and James Gettys

																  XSetWMName(3X11)
All times are GMT -4. The time now is 06:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy