Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using Backtrack 5. As it is based on Ubuntu 10.04 I decided to ask my question to here:

I'm having problems selecting text with my mouse. For example when I try to rename a folder, sometimes I can successfully highlight the text but when I release the mouse button, it is no longer highlighted. Sometimes I can't even successfully highlight the part of the text that I want. It highlights more or less of the text then actually selected.

First I thought it was a problem caused by my mouse, however, I tried another mouse and the problem continues. This problem really bothers me while surfing on the net. Could you please help me?

share|improve this question

Possibly something is constantly stealing the X selection. To find out who it is. You could compile this:

#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>

int main() {
  printf("0x%x\n", XGetSelectionOwner (XOpenDisplay(0), XA_PRIMARY));
  return 0;


gcc that-file.c -lX11

That code is to return the window ID of the owner of the PRIMARY X selection. Then you can look up that window ID in the output of xwininfo -root -all:

xwininfo -root -all | less "+/$(./a.out)"

The window that owns the selection may not have a name, but you can look at its parent or grant parent for more clue. Once you find the ancestor that is managed by the Window manager, you can get the process ID (assuming the window is displayed by a local process) with:

xprop -id that-id _NET_WM_PID


$ xwininfo -root -wm -tree | grep -B3 $(./a.out)
        24 children:
        0x2800024 "Sun 12 May - 21:40 -      zsh (2)": ("xterm" "XTerm")  1920x1059+0+19  +0+19
           1 child:
           0x280002f (has no name): ()  1920x1059+0+0  +0+19

0x280002f owns the PRIMARY selection, whose parent is "xterm" (0x2800024 managed by the Window Manager).

$ xprop -id 0x2800024 _NET_WM_PID

$ ps -fp 9707
chazelas  9707     1  0 08:50 ?        00:00:02 xterm

And that's its pid.

Once you know who owns that selection, it may become clearer what's happening.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.