[vlc-devel] [PATCH] Display cursor on video screenshot on X server systems using xfixes extension
Mehdi Lauters
mehdilauters at gmail.com
Tue Apr 3 10:27:18 CEST 2012
From: Mehdi Lauters <mehdilauters at orange.fr>
---
modules/access/screen/xcb.c | 112 ++++++++++++++++++++++++++++++++++++++++++-
po/fr.po | 37 +++++++-------
2 files changed, 129 insertions(+), 20 deletions(-)
diff --git a/modules/access/screen/xcb.c b/modules/access/screen/xcb.c
index 447f77a..3d87f8a 100644
--- a/modules/access/screen/xcb.c
+++ b/modules/access/screen/xcb.c
@@ -26,6 +26,7 @@
#include <stdarg.h>
#include <assert.h>
#include <xcb/xcb.h>
+//#include <xcb/xcb_image.h>
#include <xcb/composite.h>
#include <vlc_common.h>
#include <vlc_demux.h>
@@ -402,7 +403,7 @@ discard:
/* Capture screen */
xcb_drawable_t drawable =
(sys->window != geo->root) ? sys->pixmap : sys->window;
- free (geo);
+
xcb_get_image_reply_t *img;
img = xcb_get_image_reply (conn,
@@ -411,6 +412,115 @@ discard:
if (img == NULL)
return;
+
+///////////////////////////////////////////////cursor processing begining///////////////////////////////////
+// doesn't take account of cursor transparency
+
+ xcb_generic_error_t xcbError;
+
+ // initializing xfixes (to get the cursor image)
+ xcb_xfixes_query_version_reply(conn, xcb_xfixes_query_version(conn, XCB_XFIXES_MAJOR_VERSION, XCB_XFIXES_MINOR_VERSION), NULL);
+
+ // we ask for pointer informations ( on the same screen or not )
+ xcb_query_pointer_cookie_t pointerCookie= xcb_query_pointer (conn, drawable);
+ xcb_query_pointer_reply_t * pointerReply= xcb_query_pointer_reply (conn, pointerCookie, &xcbError);
+
+
+ if(xcbError.error_code!=0)
+ {
+ msg_Warn (demux, "unable to locate cursor");
+ }
+ else
+ {
+ // if the cursor is on the same screen
+ if(pointerReply->same_screen == 1)
+ {
+ // we get more information about the cursor
+ xcb_xfixes_get_cursor_image_cookie_t cursorCookie=xcb_xfixes_get_cursor_image(conn);
+ xcb_xfixes_get_cursor_image_reply_t* cursorImageReply= xcb_xfixes_get_cursor_image_reply (conn, cursorCookie, &xcbError);
+
+ if(xcbError.error_code==0)
+ {
+ // indices to browse images
+ int screenImageLinearIndice;
+ int pointerImageLinearIndice=0;
+
+ // images data
+ uint32_t *screenImageData=NULL;
+ uint32_t *pointerImageData;
+
+ // we get the cursor image data
+ pointerImageData=xcb_xfixes_get_cursor_image_cursor_image(cursorImageReply);
+
+ // we get screen image data
+ screenImageData=xcb_get_image_data (img);
+
+
+ //indices to browse the pointer picture
+ int ixCursor=0,
+ iyCursor=0;
+
+ int xMinScreen=cursorImageReply->x-cursorImageReply->xhot, // top left corner of the pointer picture on the screen picture
+ yMinScreen=cursorImageReply->y-cursorImageReply->yhot, // top right corner of the pointer picture on the screen picture
+ xMaxScreen=cursorImageReply->x+(cursorImageReply->width-cursorImageReply->xhot), // bottom left corner of the pointer picture on the screen picture
+ yMaxScreen=cursorImageReply->y+(cursorImageReply->width-cursorImageReply->yhot); // bottom right corner of the pointer picture on the screen picture
+
+
+ if(!(xMinScreen<0 || yMinScreen <0 || xMaxScreen > geo->width || yMaxScreen > geo->height)) // be sure that the entire pointer is on the screenshot
+ {
+
+ // we browse the screen picture
+ for(int ix=xMinScreen; // to center on the right point
+ ix<xMaxScreen;
+ ix++)
+ {
+ iyCursor=0;
+ for(int iy=yMinScreen; // to center on the right point
+ iy<yMaxScreen;
+ iy++)
+ {
+ //get the indice of the (ix,iy) pixel in the screen data buffer
+ screenImageLinearIndice=iy*geo->width+ix;
+
+
+ // //get the relative indice of the cursor
+ pointerImageLinearIndice=iyCursor*cursorImageReply->width+ixCursor;
+
+ // get the indice of the first color of the current pixel ( switch from uint32 to uint8 )
+ screenImageLinearIndice=screenImageLinearIndice*4;
+ pointerImageLinearIndice=pointerImageLinearIndice*4;
+
+ // /!\ no transparency
+ if(((uint8_t *)pointerImageData)[pointerImageLinearIndice+3]>100)
+ {
+ // copying pixels colors
+ ((uint8_t *)screenImageData)[screenImageLinearIndice]=((uint8_t *)pointerImageData)[pointerImageLinearIndice]; // r
+ ((uint8_t *)screenImageData)[screenImageLinearIndice+1]=((uint8_t *)pointerImageData)[pointerImageLinearIndice+1]; // g
+ ((uint8_t *)screenImageData)[screenImageLinearIndice+2]=((uint8_t *)pointerImageData)[pointerImageLinearIndice+2]; // b
+ }
+ iyCursor++;
+ }
+ ixCursor++;
+ }
+ }
+ else
+ {
+ msg_Warn (demux, "Cursor not on the picture");
+ }
+ free(cursorImageReply);
+ }
+ else
+ {
+ msg_Warn (demux, "unable to find cursor image");
+ }
+ }
+ }
+
+ free(pointerReply);
+ ///////////////////////////////////////////////cursor processing end///////////////////////////////////
+
+
+ free (geo);
block_t *block = block_heap_Alloc (img, xcb_get_image_data (img),
xcb_get_image_data_length (img));
if (block == NULL)
diff --git a/po/fr.po b/po/fr.po
index f6e67a0..df4f7c6 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -30,7 +30,8 @@ msgid ""
"see the file named COPYING for details.\n"
"Written by the VideoLAN team; see the AUTHORS file.\n"
msgstr ""
-"Ce programme est fourni SANS AUCUNE GARANTIE, tel qu'il est permis par la loi.\n"
+"Ce programme est fourni SANS AUCUNE GARANTIE, tel qu'il est permis par la "
+"loi.\n"
"Vous pouvez le redistribuer selon les termes de la Licence Publique Générale "
"GNU ;\n"
"voir le fichier COPYING pour plus de détails.\n"
@@ -797,14 +798,14 @@ msgstr ""
"raccourcis clavier principaux, lisez la page sur les <a href=\"http://wiki."
"videolan.org/Hotkeys\">raccourcis</a>.</p><h3>Aide</h3><p>Avant de poser une "
"question, référez vous d'abord à la <a href=\"http://wiki.videolan.org/"
-"Frequently_Asked_Questions\">FAQ</a>.</p><p>Vous pouvez ensuite demander "
-"(et apporter) de l'aide sur les <a href=\"http://forum.videolan.org"
-"\">Forums</a>, les <a href=\"http://www.videolan.org/vlc/lists.html\">listes "
-"de diffusion</a> ou notre cannal irc ( <a href=\"http://www.videolan.org/"
-"webirc/\"><em>#videolan</em></a> sur irc.freenode.net ).</p><h3>Contribuer "
-"au projet</h3><p>Vous pouvez aider le projet VideoLAN en donnant de votre "
-"temps pour aider la communauté, pour concevoir des interfaces, pour traduire "
-"la documentation, pour tester et pour coder. Vous pouvez aussi donner de "
+"Frequently_Asked_Questions\">FAQ</a>.</p><p>Vous pouvez ensuite demander (et "
+"apporter) de l'aide sur les <a href=\"http://forum.videolan.org\">Forums</"
+"a>, les <a href=\"http://www.videolan.org/vlc/lists.html\">listes de "
+"diffusion</a> ou notre cannal irc ( <a href=\"http://www.videolan.org/webirc/"
+"\"><em>#videolan</em></a> sur irc.freenode.net ).</p><h3>Contribuer au "
+"projet</h3><p>Vous pouvez aider le projet VideoLAN en donnant de votre temps "
+"pour aider la communauté, pour concevoir des interfaces, pour traduire la "
+"documentation, pour tester et pour coder. Vous pouvez aussi donner de "
"l'argent ou du matériel pour nous aider. Et bien sûr, vous pouvez "
"<b>promouvoir</b> le lecteur multimédia VLC.</p></body></html>"
@@ -1650,7 +1651,8 @@ msgid ""
"The step size of the volume is adjustable using this option, in a range from "
"0 to 1024."
msgstr ""
-"Cette option permet de modifier le pas de réglage du volume audio, de 0 à 1024"
+"Cette option permet de modifier le pas de réglage du volume audio, de 0 à "
+"1024"
#: src/libvlc-module.c:280
msgid "Audio output frequency (Hz)"
@@ -18427,10 +18429,6 @@ msgstr " g Aller à l'élément courant"
msgid " / Look for an item"
msgstr " / Rechercher"
-#: modules/gui/ncurses.c:910
-msgid " ; Look for the next item"
-msgstr " ; Rechercher le prochain"
-
#: modules/gui/ncurses.c:911
msgid " A Add an entry"
msgstr " A Ajouter"
@@ -18517,11 +18515,6 @@ msgstr " Source: <pas d'élément>"
msgid " [ h for help ]"
msgstr " [ h pour l'aide ]"
-#: modules/gui/ncurses.c:1136
-#, c-format
-msgid "Open: %s"
-msgstr "Ouvrir: %s"
-
#: modules/gui/qt4/components/controller.cpp:339
msgid "Shift+L"
msgstr "Shift+L"
@@ -28268,6 +28261,12 @@ msgstr "Rafraîchir les flux"
msgid "Enqueue"
msgstr "Mettre à la file"
+#~ msgid " ; Look for the next item"
+#~ msgstr " ; Rechercher le prochain"
+
+#~ msgid "Open: %s"
+#~ msgstr "Ouvrir: %s"
+
#~ msgid ""
#~ "The specified sound font file (%s) is incorrect.\n"
#~ "Please install a valid sound font and reconfigure it from the VLC "
--
1.7.1
More information about the vlc-devel
mailing list