[MPlayer-dev-eng] [PATCH] Option '-display' for GUI

Ingo Brückl ib at wupperonline.de
Wed Jun 1 20:55:37 CEST 2011


On the users' mailing list there was a report that there are problems with
option '-display' and the GUI. While fixing this bug (display.6.patch) I came
across a few other things and had to make some changes, some of which in
non-gui files. I've made a kind of patch sequence which I've attached
together with the planned commit messages for possible objections.

If there are none, I will commit.

Ingo
-------------- next part --------------
Remove needless explicit initialization of Display variables.

Index: libvo/x11_common.c
===================================================================
--- libvo/x11_common.c	(revision 33533)
+++ libvo/x11_common.c	(working copy)
@@ -93,8 +93,8 @@

 static int dpms_disabled = 0;

-char *mDisplayName = NULL;
-Display *mDisplay = NULL;
+char *mDisplayName;
+Display *mDisplay;
 Window mRootWin;
 int mScreen;
 int mLocalDisplay;
-------------- next part --------------
Remove commented and blocked out code.

XDisplayName() does look in the environment for DISPLAY,
if mDisplayName isn't given.

diff -Nur libvo/x11_common.c libvo/x11_common.c
--- libvo/x11_common.c	2011-06-01 19:43:17.000000000 +0200
+++ libvo/x11_common.c	2011-06-01 19:49:26.000000000 +0200
@@ -408,8 +408,6 @@
     int depth, bpp;
     unsigned int mask;

-// char    * DisplayName = ":0.0";
-// Display * mDisplay;
     XImage *mXImage = NULL;

 // Window    mRootWin;
@@ -427,13 +425,7 @@

     XSetErrorHandler(x11_errorhandler);

-#if 0
-    if (!mDisplayName)
-        if (!(mDisplayName = getenv("DISPLAY")))
-            mDisplayName = strdup(":0.0");
-#else
     dispName = XDisplayName(mDisplayName);
-#endif

     mp_msg(MSGT_VO, MSGL_V, "X11 opening display: %s\n", dispName);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: display.3.patch
Type: text/x-c++
Size: 937 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20110601/568a005c/attachment.bin>
-------------- next part --------------
Remove useless code.

mDisplay is always set, otherwise the GUI wouldn't have been called.
Thus, there is neither a need to call XOpenDisplay() nor to check for error.

diff -Nur gui/wm/ws.c gui/wm/ws.c
--- gui/wm/ws.c	2011-06-01 19:58:01.000000000 +0200
+++ gui/wm/ws.c	2011-06-01 20:13:08.000000000 +0200
@@ -202,18 +202,8 @@
  int    eventbase;
  int    errorbase;

-if(mDisplay){
+ // NOTE TO MYSELF: Use global mDisplay, get rid of wsDisplay.
  wsDisplay=mDisplay;
-} else {
- char * DisplayName = ":0.0";
- if ( getenv( "DISPLAY" ) ) DisplayName=getenv( "DISPLAY" );
- wsDisplay=XOpenDisplay( DisplayName );
- if ( !wsDisplay )
-  {
-   mp_msg( MSGT_GPLAYER,MSGL_FATAL,MSGTR_WS_CouldNotOpenDisplay );
-   guiExit( EXIT_ERROR );
-  }
-}

  XSetErrorHandler( wsErrorHandler );

diff -Nur help/help_mp-bg.h help/help_mp-bg.h
--- help/help_mp-bg.h	2011-06-01 19:35:10.000000000 +0200
+++ help/help_mp-bg.h	2011-06-01 20:13:25.000000000 +0200
@@ -812,7 +812,6 @@

 // ws.c

-#define MSGTR_WS_CouldNotOpenDisplay "[ws] ?? ???? ?? ???? ??????? DISPLAY.\n"
 #define MSGTR_WS_RemoteDisplay "[ws] ????????? ???????, ?????????? ??  XMITSHM.\n"
 #define MSGTR_WS_NoXshm "[ws] ?? ????????? ?????? ??????? ?? ???????? ???????????? ?? X ?? ????????? ?????.\n"
 #define MSGTR_WS_NoXshape "[ws] ?? ????????? ?????? ??????? ?? ???????? ???????????? XShape.\n"
diff -Nur help/help_mp-cs.h help/help_mp-cs.h
--- help/help_mp-cs.h	2011-06-01 19:35:10.000000000 +0200
+++ help/help_mp-cs.h	2011-06-01 20:13:30.000000000 +0200
@@ -784,7 +784,6 @@
 #define MSGTR_NotAFile "Toto nevypadá jako soubor: %s !\n"

 // ws.c
-#define MSGTR_WS_CouldNotOpenDisplay "[ws] Nelze otev?ít display.\n"
 #define MSGTR_WS_RemoteDisplay "[ws] Vzdálený display, vypínám XMITSHM.\n"
 #define MSGTR_WS_NoXshm "[ws] Promi?te, ale vá? systém nepodporuje roz?í?ení X shared memory.\n"
 #define MSGTR_WS_NoXshape "[ws] Promi?te, ale vá? systém nepodporuje roz?í?ení XShape.\n"
diff -Nur help/help_mp-de.h help/help_mp-de.h
--- help/help_mp-de.h	2011-06-01 19:35:10.000000000 +0200
+++ help/help_mp-de.h	2011-06-01 20:13:33.000000000 +0200
@@ -1016,7 +1016,6 @@
 #define MSGTR_NotAFile "Dies scheint keine Datei zu sein: %s !\n"

 // ws.c
-#define MSGTR_WS_CouldNotOpenDisplay "[ws] Konnte das Display nicht öffnen.\n"
 #define MSGTR_WS_RemoteDisplay "[ws] Ferngesteuertes Display, deaktiviere XMITSHM.\n"
 #define MSGTR_WS_NoXshm "[ws] Sorry, dein System unterstützt die Shared-Memory-Erweiterung von X nicht.\n"
 #define MSGTR_WS_NoXshape "[ws] Sorry, dein System unterstützt die XShape-Erweiterung nicht.\n"
diff -Nur help/help_mp-en.h help/help_mp-en.h
--- help/help_mp-en.h	2011-06-01 19:35:10.000000000 +0200
+++ help/help_mp-en.h	2011-06-01 20:13:39.000000000 +0200
@@ -807,7 +807,6 @@
 #define MSGTR_NotAFile "This does not seem to be a file: %s !\n"

 // ws.c
-#define MSGTR_WS_CouldNotOpenDisplay "[ws] Could not open the display.\n"
 #define MSGTR_WS_RemoteDisplay "[ws] Remote display, disabling XMITSHM.\n"
 #define MSGTR_WS_NoXshm "[ws] Sorry, your system does not support the X shared memory extension.\n"
 #define MSGTR_WS_NoXshape "[ws] Sorry, your system does not support the XShape extension.\n"
diff -Nur help/help_mp-es.h help/help_mp-es.h
--- help/help_mp-es.h	2011-06-01 19:35:10.000000000 +0200
+++ help/help_mp-es.h	2011-06-01 20:13:42.000000000 +0200
@@ -800,7 +800,6 @@
 #define MSGTR_NotAFile "Esto no parece ser un archivo: %s !\n"

 // ws.c
-#define MSGTR_WS_CouldNotOpenDisplay "[ws] No puede abrir el display.\n"
 #define MSGTR_WS_RemoteDisplay "[ws] Display remoto, desactivando XMITSHM.\n"
 #define MSGTR_WS_NoXshm "[ws] Lo lamento, su sistema no soporta la extensión de memoria compartida X.\n"
 #define MSGTR_WS_NoXshape "[ws] Lo lamento, su sistema no soporta la extensión XShape.\n"
diff -Nur help/help_mp-fr.h help/help_mp-fr.h
--- help/help_mp-fr.h	2011-06-01 19:35:10.000000000 +0200
+++ help/help_mp-fr.h	2011-06-01 20:13:45.000000000 +0200
@@ -967,7 +967,6 @@

 // ws.c

-#define MSGTR_WS_CouldNotOpenDisplay "[ws] Impossible d'ouvrir l'affichage.\n"
 #define MSGTR_WS_RemoteDisplay "[ws] Affichage à distance, désactive XMITSHM.\n"
 #define MSGTR_WS_NoXshm "[ws] Désolé, votre système ne supporte pas l'extension de mémoire partagée X.\n"
 #define MSGTR_WS_NoXshape "[ws] Désolé, votre système ne supporte pas l'extension XShape.\n"
diff -Nur help/help_mp-hu.h help/help_mp-hu.h
--- help/help_mp-hu.h	2011-06-01 19:35:10.000000000 +0200
+++ help/help_mp-hu.h	2011-06-01 20:13:47.000000000 +0200
@@ -797,7 +797,6 @@
 #define MSGTR_NotAFile "Úgy t?nik, hogy ez nem fájl: %s !\n"

 // ws.c
-#define MSGTR_WS_CouldNotOpenDisplay "[ws] A képerny? nem nyitható meg.\n"
 #define MSGTR_WS_RemoteDisplay "[ws] Távoli képerny?, XMITSHM kikapcsolva.\n"
 #define MSGTR_WS_NoXshm "[ws] Bocs, a rendszered nem támogatja az X osztott memória kiterjesztést.\n"
 #define MSGTR_WS_NoXshape "[ws] Bocs, a rendszered nem támogatja az XShape kiterjesztést.\n"
diff -Nur help/help_mp-it.h help/help_mp-it.h
--- help/help_mp-it.h	2011-06-01 19:35:10.000000000 +0200
+++ help/help_mp-it.h	2011-06-01 20:13:50.000000000 +0200
@@ -794,7 +794,6 @@
 #define MSGTR_NotAFile "Questo non pare essere un file: %s !\n"

 // ws.c
-#define MSGTR_WS_CouldNotOpenDisplay "[ws] Non posso aprire il display.\n"
 #define MSGTR_WS_RemoteDisplay "[ws] Display remoto, disabilito XMITSHM.\n"
 #define MSGTR_WS_NoXshm "[ws] Spiacente, il tuo sistema non supporta l'estensione 'X shared memory'.\n"
 #define MSGTR_WS_NoXshape "[ws] Spiacente, il tuo sistema non supporta l'estensione XShape.\n"
diff -Nur help/help_mp-pl.h help/help_mp-pl.h
--- help/help_mp-pl.h	2011-06-01 19:35:10.000000000 +0200
+++ help/help_mp-pl.h	2011-06-01 20:14:05.000000000 +0200
@@ -938,7 +938,6 @@

 // ws.c

-#define MSGTR_WS_CouldNotOpenDisplay "[ws] Nie uda?o sie otworzy? ekranu.\n"
 #define MSGTR_WS_RemoteDisplay "[ws] Ekran zdalny, wy??czam XMITSHM.\n"
 #define MSGTR_WS_NoXshm "[ws] Niestety Twój system nie obs?uguje rozszerze? dzielonej pami?ci X.\n"
 #define MSGTR_WS_NoXshape "[ws] Niestety Twój system nie obs?uguje rozszerzenia XShape.\n"
diff -Nur help/help_mp-ru.h help/help_mp-ru.h
--- help/help_mp-ru.h	2011-06-01 19:35:10.000000000 +0200
+++ help/help_mp-ru.h	2011-06-01 20:14:13.000000000 +0200
@@ -786,7 +786,6 @@
 #define MSGTR_NotAFile "??? ?? ?????? ?? ????: '%s' !\n"

 // ws.c
-#define MSGTR_WS_CouldNotOpenDisplay "[ws] ?? ???? ??????? ???????.\n"
 #define MSGTR_WS_RemoteDisplay "[ws] ????????? ???????, ???????? XMITSHM.\n"
 #define MSGTR_WS_NoXshm "[ws] ????????, ???? ??????? ?? ???????????? ?????????? ??????????? ?????? X'??.\n"
 #define MSGTR_WS_NoXshape "[ws] ????????, ???? ??????? ?? ???????????? ?????????? XShape.\n"
diff -Nur help/help_mp-tr.h help/help_mp-tr.h
--- help/help_mp-tr.h	2011-06-01 19:35:10.000000000 +0200
+++ help/help_mp-tr.h	2011-06-01 20:14:20.000000000 +0200
@@ -981,7 +981,6 @@

 // ws.c

-#define MSGTR_WS_CouldNotOpenDisplay "[ws] Gösterge aç?lamad?.\n"
 #define MSGTR_WS_RemoteDisplay "[ws] uzaktan kumanda göstergesi, XMITSHM devred??? b?rak?l?yor.\n"
 #define MSGTR_WS_NoXshm "[ws] Üzgünüm, sisteminiz X payla??ml? bellek geni?letmesini desteklemiyor.\n"
 #define MSGTR_WS_NoXshape "[ws] Üzgünüm, sisteminiz Xshape geni?letmesini desteklemiyor.\n"
diff -Nur help/help_mp-uk.h help/help_mp-uk.h
--- help/help_mp-uk.h	2011-06-01 19:35:10.000000000 +0200
+++ help/help_mp-uk.h	2011-06-01 20:14:24.000000000 +0200
@@ -779,7 +779,6 @@
 #define MSGTR_NotAFile "????????, ?? ?? ????: %s !\n"

 // ws.c
-#define MSGTR_WS_CouldNotOpenDisplay "[ws] ?? ???? ???????? ???????.\n"
 #define MSGTR_WS_RemoteDisplay "[ws] ?????????? ???????, ??????? XMITSHM.\n"
 #define MSGTR_WS_NoXshm "[ws] ???????, ???? ??????? ?? ????????? ?????????? ????????? ???'??? X.\n"
 #define MSGTR_WS_NoXshape "[ws] ???????, ????????, ???? ??????? ?? ????????? ?????????? XShape.\n"
diff -Nur help/help_mp-zh_CN.h help/help_mp-zh_CN.h
--- help/help_mp-zh_CN.h	2011-06-01 19:35:10.000000000 +0200
+++ help/help_mp-zh_CN.h	2011-06-01 20:14:34.000000000 +0200
@@ -807,7 +807,6 @@
 #define MSGTR_NotAFile "????????%s?\n"

 // ws.c
-#define MSGTR_WS_CouldNotOpenDisplay "[ws] ?????????\n"
 #define MSGTR_WS_RemoteDisplay "[ws] ????????? XMITSHM?\n"
 #define MSGTR_WS_NoXshm "[ws] ?????????? X ?????????\n"
 #define MSGTR_WS_NoXshape "[ws] ?????????? XShape ?????\n"
diff -Nur help/help_mp-zh_TW.h help/help_mp-zh_TW.h
--- help/help_mp-zh_TW.h	2011-06-01 19:35:10.000000000 +0200
+++ help/help_mp-zh_TW.h	2011-06-01 20:14:39.000000000 +0200
@@ -953,7 +953,6 @@

 // ws.c

-#define MSGTR_WS_CouldNotOpenDisplay "[ws] ??????\n"
 #define MSGTR_WS_RemoteDisplay "[ws] ????, ?? XMITSHM?\n"
 #define MSGTR_WS_NoXshm "[ws] ??, ??????? X ???????\n"
 #define MSGTR_WS_NoXshape "[ws] ??, ??????? XShape ???\n"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: display.5.patch
Type: text/x-pascal
Size: 2752 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20110601/568a005c/attachment.p>
-------------- next part --------------
Take notice of MPlayer option '-display'.

If option '-display' is given, initialize GTK in a way
that the GUI will run on that display.

diff -Nur gui/mplayer/widgets.c gui/mplayer/widgets.c
--- gui/mplayer/widgets.c	2011-06-01 20:29:40.000000000 +0200
+++ gui/mplayer/widgets.c	2011-06-01 20:36:35.000000000 +0200
@@ -35,6 +35,7 @@
 #include "config.h"
 #include "help_mp.h"
 #include "mp_msg.h"
+#include "libvo/x11_common.h"

 #include "widgets.h"
 #include "gui/app.h"
@@ -75,10 +76,17 @@
 void gtkInit( char * progname )
 {
  int argc = 1;
- char *arg[1], **argv = arg;
+ char *arg[3], **argv = arg;

  arg[0] = progname;

+ if (mDisplayName)
+ {
+   argc = 3;
+   arg[1] = "--display";
+   arg[2] = mDisplayName;
+ }
+
  mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[widget] init GTK ...\n" );
 #ifdef CONFIG_GTK2
  gtk_disable_setlocale();


More information about the MPlayer-dev-eng mailing list