[MPlayer-dev-eng] [PATCH] Make disabling DPMS optional

Holger Weiss holger at CIS.FU-Berlin.DE
Sun Nov 5 01:49:37 CET 2006


* Paul TT <paultt at hackerjournal.it> [2006-11-03 20:09]:
> Holger Weiss <holger at CIS.FU-Berlin.DE> wrote:
> > * RC <rcooley at spamcop.net> [2006-11-03 03:22]:
> > > In any case, I'd certainly pick better option names...  Perhaps
> > > -(no)dpms ?
> >
> > I thought about "-(no)dpms" myself, but found it a bit ambiguous: Does
> > "-nodpms" mean "disable DPMS" or "don't disable DPMS"?  If you tell me
> > which way round to do it, I'll send an updated pacth :-)
>
> i read it this way:
> no dpms to me means something like 'don't take care of dpms', so don't
> disable.

Okay, I've attached a version of the patch which provides "-(no)dpms"
instead of "-(no)disable-dpms".  Personally, I'd still slightly prefer
the latter, but I don't really mind.

> anyway i found totally useless to have the /true/ part, to let
> mplayer disable it.
> i think -nodpms, meaning 'don't take care of dpms is enough

The mplayer(1) manpage says:

| Every 'flag' option has a 'noflag' counterpart, e.g. the opposite of
| the -fs option is -nofs.

I would have thought this implies that every flag documented as "nofoo"
has a "foo" counterpart.  In any case, it makes sense in order to allow
for overriding a "nodpms=1" (or "dpms=0") setting in the (system-wide or
user-specific) configuration file on the command line.

Thanks, Holger

-- 
PGP fingerprint:  F1F0 9071 8084 A426 DD59  9839 59D3 F3A1 B8B5 D3DE
-------------- next part --------------
Index: Gui/cfg.c
===================================================================
--- Gui/cfg.c	(revision 20672)
+++ Gui/cfg.c	(working copy)
@@ -82,6 +82,7 @@
 extern char * get_path( const char * filename );
 extern int    flip;
 extern int    frame_dropping;
+extern int    disable_dpms;
 extern int    stop_xscreensaver;
 extern int    m_config_parse_config_file(m_config_t* config, char *conffile);
 
@@ -171,6 +172,7 @@
  { "playbar",&gtkEnablePlayBar,CONF_TYPE_FLAG,0,0,1,NULL }, 
  { "load_fullscreen",&gtkLoadFullscreen,CONF_TYPE_FLAG,0,0,1,NULL },
  { "show_videowin", &gtkShowVideoWindow,CONF_TYPE_FLAG,0,0,1,NULL },
+ { "disabledpms",&disable_dpms,CONF_TYPE_FLAG,0,0,1,NULL },
  { "stopxscreensaver",&stop_xscreensaver,CONF_TYPE_FLAG,0,0,1,NULL },
 
  { "autosync",&gtkAutoSyncOn,CONF_TYPE_FLAG,0,0,1,NULL },
Index: Gui/wm/ws.c
===================================================================
--- Gui/wm/ws.c	(revision 20672)
+++ Gui/wm/ws.c	(working copy)
@@ -53,6 +53,8 @@
 extern int xinerama_screen;
 #endif
 
+extern int disable_dpms;
+
 typedef struct
 {
  unsigned long flags;
@@ -1182,7 +1184,7 @@
 {
  int nothing;
 #ifdef HAVE_XDPMS
- if ( dpms_disabled )
+ if ( disable_dpms && dpms_disabled )
   {
    if ( DPMSQueryExtension( mDisplay,&nothing,&nothing ) )
     {
@@ -1212,7 +1214,7 @@
 {
  int interval,prefer_blank,allow_exp,nothing;
 #ifdef HAVE_XDPMS
- if ( DPMSQueryExtension( mDisplay,&nothing,&nothing ) )
+ if ( disable_dpms && DPMSQueryExtension( mDisplay,&nothing,&nothing ) )
   {
    BOOL onoff;
    CARD16 state;
Index: Gui/mplayer/gtk/opts.c
===================================================================
--- Gui/mplayer/gtk/opts.c	(revision 20672)
+++ Gui/mplayer/gtk/opts.c	(working copy)
@@ -75,6 +75,7 @@
 static GtkWidget * CBCache;
 static GtkWidget * CBLoadFullscreen;
 static GtkWidget * CBSaveWinPos;
+static GtkWidget * CBDisableDPMS;
 static GtkWidget * CBStopXScreenSaver;
 static GtkWidget * CBPlayBar;
 
@@ -171,6 +172,7 @@
 static void prEntry( GtkContainer * container,gpointer user_data );
 #endif
 
+extern int    disable_dpms;
 extern int    stop_xscreensaver;
 
 void ShowPreferences( void )
@@ -374,6 +376,7 @@
    gtk_widget_set_sensitive( CBLoadFullscreen,FALSE );
    gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBLoadFullscreen ),0 );
   }
+ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBDisableDPMS ),disable_dpms );
  gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( CBStopXScreenSaver ),stop_xscreensaver );
  gtk_adjustment_set_value( HSPPQualityadj,auto_quality );
 
@@ -623,6 +626,7 @@
 	gtkLoadFullscreen=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBLoadFullscreen ) );
 	gui_save_pos=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBSaveWinPos ) );
 	gtkShowVideoWindow=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBShowVideoWindow ) );
+	disable_dpms=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBDisableDPMS ) );
 	stop_xscreensaver=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBStopXScreenSaver ) );
 	gtkEnablePlayBar=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBPlayBar ) );
 	gtkSet( gtkSetAutoq,HSPPQualityadj->value,NULL );
@@ -1271,6 +1275,7 @@
   CBShowVideoWindow=AddCheckButton( MSGTR_PREFERENCES_ShowVideoWindow,vbox602 );
   CBLoadFullscreen=AddCheckButton( MSGTR_PREFERENCES_LoadFullscreen,vbox602 );
   CBSaveWinPos=AddCheckButton( MSGTR_PREFERENCES_SaveWinPos,vbox602 );
+  CBDisableDPMS=AddCheckButton( MSGTR_PREFERENCES_DisableDPMS,vbox602 );
   CBStopXScreenSaver=AddCheckButton( MSGTR_PREFERENCES_XSCREENSAVER,vbox602 );
   CBPlayBar=AddCheckButton( MSGTR_PREFERENCES_PlayBar,vbox602 );
 
Index: libvo/x11_common.c
===================================================================
--- libvo/x11_common.c	(revision 20672)
+++ libvo/x11_common.c	(working copy)
@@ -68,6 +68,7 @@
 static int orig_layer = 0;
 static int old_gravity = NorthWestGravity;
 
+int disable_dpms = 1;
 int stop_xscreensaver = 0;
 
 static int dpms_disabled = 0;
@@ -1659,7 +1660,7 @@
 #ifdef HAVE_XDPMS
     int nothing;
 
-    if (dpms_disabled)
+    if (disable_dpms && dpms_disabled)
     {
         if (DPMSQueryExtension(mDisplay, &nothing, &nothing))
         {
@@ -1721,7 +1722,7 @@
 #ifdef HAVE_XDPMS
     int nothing;
 
-    if (DPMSQueryExtension(mDisplay, &nothing, &nothing))
+    if (disable_dpms && DPMSQueryExtension(mDisplay, &nothing, &nothing))
     {
         BOOL onoff;
         CARD16 state;
Index: DOCS/man/en/mplayer.1
===================================================================
--- DOCS/man/en/mplayer.1	(revision 20672)
+++ DOCS/man/en/mplayer.1	(working copy)
@@ -2815,6 +2815,10 @@
 It can affect OSD negatively, but often removes OSD flickering.
 .
 .TP
+.B \-nodpms
+Do not disable DPMS at startup (and do not re-enable it on exit).
+.
+.TP
 .B \-nograbpointer
 Do not grab the mouse pointer after a video mode change (\-vm).
 Useful for multihead setups.
Index: DOCS/man/de/mplayer.1
===================================================================
--- DOCS/man/de/mplayer.1	(revision 20672)
+++ DOCS/man/de/mplayer.1	(working copy)
@@ -2934,6 +2934,11 @@
 Es kann das OSD negativ beeinflussen, entfernt aber oft Flimmern des OSD.
 .
 .TP
+.B \-nodpms
+DPMS beim Start von MPlayer nicht deaktivieren (und beim Beenden nicht
+wieder aktivieren).
+.
+.TP
 .B \-nograbpointer
 ?bernimm den Mauszeiger nach einem Wechsel des Videomodus (mit \-vm)
 nicht.
Index: cfg-mplayer.h
===================================================================
--- cfg-mplayer.h	(revision 20672)
+++ cfg-mplayer.h	(working copy)
@@ -62,6 +62,7 @@
 #ifdef HAVE_X11
 extern char *mDisplayName;
 extern int fs_layer;
+extern int disable_dpms;
 extern int stop_xscreensaver;
 extern char **vo_fstype_list;
 extern int vo_nomouse_input;
@@ -239,6 +240,8 @@
 #ifdef HAVE_X11
 	// x11,xv,xmga,xvidix
 	{"icelayer", "-icelayer is obsolete. Use -fstype layer:<number> instead.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL},
+	{"dpms", &disable_dpms, CONF_TYPE_FLAG, 0, 0, 1, NULL},
+	{"nodpms", &disable_dpms, CONF_TYPE_FLAG, 0, 1, 0, NULL},
 	{"stop-xscreensaver", &stop_xscreensaver, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 	{"nostop-xscreensaver", &stop_xscreensaver, CONF_TYPE_FLAG, 0, 1, 0, NULL},
 	{"stop_xscreensaver", "Use -stop-xscreensaver instead, options with _ have been obsoleted.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL},
Index: help/help_mp-de.h
===================================================================
--- help/help_mp-de.h	(revision 20672)
+++ help/help_mp-de.h	(working copy)
@@ -932,6 +932,7 @@
 #define MSGTR_PREFERENCES_CacheSize "Cachegr????e: "
 #define MSGTR_PREFERENCES_LoadFullscreen "Im Vollbildmodus starten"
 #define MSGTR_PREFERENCES_SaveWinPos "Speichere Fensterposition"
+#define MSGTR_PREFERENCES_DisableDPMS "Deaktiviere DPMS"
 #define MSGTR_PREFERENCES_XSCREENSAVER "Deaktiviere XScreenSaver"
 #define MSGTR_PREFERENCES_PlayBar "Aktiviere die Playbar"
 #define MSGTR_PREFERENCES_AutoSync "AutoSync ein/aus"
Index: help/help_mp-en.h
===================================================================
--- help/help_mp-en.h	(revision 20672)
+++ help/help_mp-en.h	(working copy)
@@ -919,6 +919,7 @@
 #define MSGTR_PREFERENCES_CacheSize "Cache size: "
 #define MSGTR_PREFERENCES_LoadFullscreen "Start in fullscreen"
 #define MSGTR_PREFERENCES_SaveWinPos "Save window position"
+#define MSGTR_PREFERENCES_DisableDPMS "Disable DPMS"
 #define MSGTR_PREFERENCES_XSCREENSAVER "Stop XScreenSaver"
 #define MSGTR_PREFERENCES_PlayBar "Enable playbar"
 #define MSGTR_PREFERENCES_AutoSync "AutoSync on/off"


More information about the MPlayer-dev-eng mailing list