7

This is more of a vocabulary question than anything else.

Introduction

I'm using the Point Cloud Library to get face tracking data. Using this data I want to track where a user is facing on the screen. This is not a problem.

Problem

To give user-feedback, I would like to draw the estimation of the user's face-direction as a red circle on the screen, basically as seen here (they just create a tiny window). I would like this circle to be able to go everywhere on the screen and I want it to be always visible. I do not want it to be covered by another active window. If it impedes interaction with the window, I'm fine with that.

My problem is that I do not know where to start.

I could just control the cursor, but that is less then ideal, because I would like to still be able to move the cursor while I'm using face detection.

I think I need to use OpenGL, but all the examples I've seen have been inside X windows. For example, the code I found here after getting a hint here, give me a nice permanent window, but the window still captures all my mouse clicks. How do I draw something on a screen with OpenGL that is X-window independent?

Am I approaching this from the wrong direction completely? If so, what should I be googling?

I will accept any answer that gives me a starting point.

Platform

I am using Ubuntu 12.04 with the Unity desktop.

Community
  • 1
  • 1
Seanny123
  • 8,776
  • 13
  • 68
  • 124
  • This might get you started: http://stackoverflow.com/questions/9363491/how-to-make-transparent-window-on-linux – Ben Jackson Jul 22 '13 at 06:43
  • I read that and ran the code, but it looks like the window would still be hidden if I activated another window. – Seanny123 Jul 22 '13 at 06:58
  • 3
    You don't _need_ to use OpenGL, though it would be a good idea (for performance reasons, and maybe it would be easier, for drawing). Now, for the actual question, I'd recommend looking into the "composite" X.org extension ( http://www.x.org/archive/X11R7.5/doc/compositeproto/compositeproto.txt ). That should get you started somewhere =) – MiJyn Jul 22 '13 at 07:56
  • @MiJyn I'm currently investigating the composite windows that are mentioned in your link (and will probably end up starting a new question based on that info), however if anyone knows if this is possible to accomplish without opening an X-window, I would still accept that as an answer. – Seanny123 Jul 22 '13 at 08:54
  • @MiJyn: Composite is huge overkill. A simple nonrectangular window, created using the X Shape extension will do. You don't even need a compositing window manager for Shape to work (it's been around for almost forever long before there were compositors). – datenwolf Jul 22 '13 at 10:14
  • @Seanny123: To stay on top will require some assistance from the window manager. You can ask it to keep you on top with hints or configure it in the WM to always put it on top. – Ben Jackson Jul 22 '13 at 18:15
  • @datenwolf, yes, but then how do you redirect input to the window below it? Say you click on the shape, but you actually wanted to click on a button (or something) from the window below... you'd have an issue there. – MiJyn Jul 22 '13 at 20:58
  • @MiJyn: Using XFixes you can define an area different from the appearance of an window, where the window will receive pointer events. If that area is empty, all pointer events will "fall through". – datenwolf Jul 22 '13 at 23:51
  • @datenwolf ah okay, thanks, that clarifies a lot! – MiJyn Jul 23 '13 at 00:12

1 Answers1

5

Create a regular window. Tell the WM to skip decorations ant to keep the window always on top. Use XFixesSetWindowShapeRegion() to separately set a circular output region and an empty input region. You need a compositing window manager XFixes extensions for this to work.

You can also make your window semi-transparent (this needs a compositing window manager).

A modern toolkit such as gtk should have easy to use APIs to do all of the above.

No OpenGL is needed at any stage.

n. m. could be an AI
  • 112,515
  • 14
  • 128
  • 243
  • Would this window still capture any mouse clicks executed on it? – Seanny123 Jul 22 '13 at 09:59
  • No it wouldn't, the empty input shape takes care of this. Basically it will not receive any mouse input. Not sure about the keyboard input though. – n. m. could be an AI Jul 22 '13 at 10:01
  • @n.m.: Shape extension does not require a compositing WM to work. Shape has been around for about forever, long before compositing was even heared of. – datenwolf Jul 22 '13 at 10:12
  • I'm going to accept this answer, with the caveat that I have not verified it. – Seanny123 Jul 22 '13 at 10:25
  • @datenwolf: XShape doesn't support input shapes separate from output shapes. XFixes does. I *think* it requires compositing for input shapes to work though I'm now not sure. – n. m. could be an AI Jul 22 '13 at 10:56
  • Shape and XFixes shape is completely independent from composite. The only mentioning of composite managers in XFixes is related to composited cursor drawing for which the X server side cursor drawing must be disabled, and XFixes provides that. – datenwolf Jul 22 '13 at 11:50
  • @datenwolf: indeed there's nothing in the XFixes documentation that would require compositing for shapes. I have updated the answer. – n. m. could be an AI Jul 22 '13 at 12:09