Changed screen saver control to use fake events

This closes Bug 1031
(cherry picked from commit 8fe6f08227)
v3.5.13-sru
Slávek Banko 13 years ago
parent d7288a48b3
commit f5dd8fe760

@ -105,6 +105,9 @@
/* Define to 1 if you have the `vsnprintf' function. */
#undef HAVE_VSNPRINTF
/* XTest extension available */
#undef HAVE_XTEST
/* If we have libxine installed */
#undef HAVE_XINE

@ -123,6 +123,35 @@ if test x$have_expat = xyes -a x$want_expat = xyes; then
AC_SUBST(LIB_EXPAT)
fi
dnl -------------------------
dnl check for XTest extension
dnl -------------------------
AC_ARG_WITH([xtest], [AS_HELP_STRING([--without-xtest], [build without XTest support])],,
[with_xtest=yes])
CFLAGS_XTEST=""
LIB_XTEST=""
if test "$with_xtest" != "no" ; then
AC_MSG_CHECKING([for XTest extension])
if "$PKG_CONFIG" --exists xtst ; then
with_xtest=yes
CFLAGS_XTEST=`"$PKG_CONFIG" --cflags xtst`
LIB_XTEST=`"$PKG_CONFIG" --libs xtst`
AC_DEFINE([HAVE_XTEST],,[XTest extension available])
AC_MSG_RESULT([yes])
else
with_xtest=no
AC_MSG_RESULT([no])
fi
fi
AC_SUBST([CFLAGS_XTEST])
AC_SUBST([LIB_XTEST])
KDE_CHECK_HEADER(xine.h,
have_xine=yes,
have_xine=no)

@ -58,6 +58,34 @@ if test x$have_expat = xyes -a x$want_expat = xyes; then
AC_SUBST(LIB_EXPAT)
fi
dnl -------------------------
dnl check for XTest extension
dnl -------------------------
AC_ARG_WITH([xtest], [AS_HELP_STRING([--without-xtest], [build without XTest support])],,
[with_xtest=yes])
CFLAGS_XTEST=""
LIB_XTEST=""
if test "$with_xtest" != "no" ; then
AC_MSG_CHECKING([for XTest extension])
if "$PKG_CONFIG" --exists xtst ; then
with_xtest=yes
CFLAGS_XTEST=`"$PKG_CONFIG" --cflags xtst`
LIB_XTEST=`"$PKG_CONFIG" --libs xtst`
AC_DEFINE([HAVE_XTEST],,[XTest extension available])
AC_MSG_RESULT([yes])
else
with_xtest=no
AC_MSG_RESULT([no])
fi
fi
AC_SUBST([CFLAGS_XTEST])
AC_SUBST([LIB_XTEST])
KDE_CHECK_HEADER(xine.h,
have_xine=yes,
have_xine=no)

@ -5,8 +5,8 @@ METASOURCES= AUTO
lib_LTLIBRARIES= libkmplayercommon.la
libkmplayercommon_la_SOURCES = viewarea.cpp kmplayerview.cpp playlistview.cpp kmplayercontrolpanel.cpp kmplayerconfig.cpp pref.cpp kmplayerprocess.cpp kmplayer_callback.skel kmplayer_backend.stub kmplayerpartbase.cpp kmplayerplaylist.cpp kmplayer_asx.cpp kmplayer_smil.cpp kmplayer_rp.cpp kmplayer_rss.cpp kmplayer_atom.cpp kmplayer_xspf.cpp triestring.cpp kmplayerpartbase.skel
libkmplayercommon_la_LDFLAGS = -avoid-version $(all_libraries)
libkmplayercommon_la_LIBADD = -lkmediaplayer $(LIB_KPARTS) $(LIB_KUTILS) $(LIB_EXPAT) -lm $(LIBCAIRO_LIBS) $(LIBQTDBUS)
libkmplayercommon_la_LDFLAGS = -avoid-version $(all_libraries) $(CFLAGS_XTEST)
libkmplayercommon_la_LIBADD = -lkmediaplayer $(LIB_KPARTS) $(LIB_KUTILS) $(LIB_EXPAT) -lm $(LIBCAIRO_LIBS) $(LIBQTDBUS) $(LIB_XTEST)
if include_koffice_support
kofficeplugin_lib= libkmplayerkofficepart.la
@ -25,7 +25,7 @@ libkmplayerkofficepart_la_LIBADD= libkmplayercommon.la $(LIB_KOFFICE)
kdeinit_LTLIBRARIES=kmplayer.la
kmplayer_la_SOURCES= main.cpp kmplayerapp.cpp kmplayertvsource.cpp kmplayerbroadcast.cpp kmplayervdr.cpp
kmplayer_la_LIBADD= libkmplayercommon.la
kmplayer_la_LIBADD= libkmplayercommon.la $(LIB_XTEST)
kmplayer_la_LDFLAGS= -module $(KDE_PLUGIN) $(LIB_QT)
EXTRA_PROGRAMS = kxineplayer kxvplayer kgstplayer

@ -137,6 +137,7 @@ private slots:
void menuMoveUpNode ();
void menuMoveDownNode ();
void preparePlaylistMenu (KMPlayer::PlayListItem *, TQPopupMenu *);
void slotFakeKeyEvent();
private:
void menuItemClicked (TQPopupMenu * menu, int id);
@ -192,6 +193,11 @@ private:
bool m_played_exit;
bool m_minimal_mode;
bool m_auto_resize;
TQTimer m_screensaverTimer;
bool m_haveKWin;
bool haveXTest;
int fakeKeycode;
};
class KMPLAYER_NO_EXPORT FileDocument : public KMPlayer::Document {

@ -73,6 +73,12 @@
#include "kmplayervdr.h"
#include "kmplayerconfig.h"
#include <X11/Xlib.h>
#ifdef HAVE_XTEST
#include <X11/keysym.h>
#include <X11/extensions/XTest.h>
#endif
static const int DVDNav_start = 1;
static const int DVDNav_previous = 2;
static const int DVDNav_next = 3;
@ -533,6 +539,24 @@ KDE_NO_CDTOR_EXPORT KMPlayerApp::KMPlayerApp(TQWidget* , const char* name)
initActions();
initView();
haveXTest = false;
#ifdef HAVE_XTEST
int dummy_event, dummy_error, dummy_major, dummy_minor;
if (XTestQueryExtension(x11Display(), &dummy_event, &dummy_error, &dummy_major, &dummy_minor)) {
fakeKeycode = XKeysymToKeycode(x11Display(), XK_Shift_L);
if (fakeKeycode != 0)
haveXTest = true;
}
#endif
/** KWin are you there? **/
m_haveKWin = KApplication::dcopClient()->isApplicationRegistered("kwin");
if (m_haveKWin)
kdDebug() << "Window manager: KWin found" << endl;
else
kdDebug() << "Window manager: not KWin - using save fullscreen mode" << endl;
connect(&m_screensaverTimer, TQT_SIGNAL(timeout()), TQT_TQOBJECT(this), TQT_SLOT(slotFakeKeyEvent()));
m_screensaverTimer.start( 55000 );
//setAutoSaveSettings();
playlist = new Playlist (this, lstsrc);
playlist_id = m_view->playList ()->addTree (playlist, "listssource", "player_playlist", KMPlayer::PlayListView::AllowDrag | KMPlayer::PlayListView::AllowDrops | KMPlayer::PlayListView::TreeEdit | KMPlayer::PlayListView::Moveable | KMPlayer::PlayListView::Deleteable);
@ -685,6 +709,27 @@ KDE_NO_EXPORT void KMPlayerApp::initView () {
setAcceptDrops (true);
}
void KMPlayerApp::slotFakeKeyEvent()
{
if ( m_player && m_player->isPlaying() && !m_player->isPaused())
if (m_haveKWin) {
// use a better method if we're in a kde environment
kdDebug() << "KMPlayer: Fake mouse movement\n";
XWarpPointer(x11Display(), None, None, 0, 0, 0, 0, 0, 0);
XFlush(x11Display());
} else {
if(haveXTest) {
#ifdef HAVE_XTEST
kdDebug() << "KMPlayer: Fake key press\n";
XTestFakeKeyEvent(x11Display(), fakeKeycode, true, 0);
XTestFakeKeyEvent(x11Display(), fakeKeycode, false, 0);
XFlush(x11Display());
#endif
}
}
}
KDE_NO_EXPORT void KMPlayerApp::loadingProgress (int perc) {
if (perc < 100)
statusBar ()->changeItem (TQString ("%1%").arg (perc), id_status_timer);

@ -874,6 +874,11 @@ KDE_NO_EXPORT bool PartBase::isPlaying () {
return playing ();
}
KDE_NO_EXPORT bool PartBase::isPaused () {
NodePtr doc = m_source ? m_source->document () : 0L;
return doc && doc->state == Node::state_deferred;
}
KAboutData* PartBase::createAboutData () {
KMessageBox::error(0L, "createAboutData", "KMPlayer");
return 0;

@ -192,6 +192,7 @@ public:
k_dcop:
void toggleFullScreen ();
bool isPlaying ();
bool isPaused ();
signals:
void sourceChanged (KMPlayer::Source * old, KMPlayer::Source * nw);
void sourceDimensionChanged ();

@ -599,27 +599,12 @@ bool View::isFullScreen () const {
void View::fullScreen () {
if (!m_view_area->isFullScreen()) {
m_sreensaver_disabled = false;
TQByteArray data, replydata;
TQCString replyType;
if (kapp->dcopClient ()->call ("kdesktop", "KScreensaverIface",
"isEnabled()", data, replyType, replydata)) {
bool enabled;
TQDataStream replystream (replydata, IO_ReadOnly);
replystream >> enabled;
if (enabled)
m_sreensaver_disabled = kapp->dcopClient()->send
("kdesktop", "KScreensaverIface", "enable(bool)", TQString("false"));
}
//if (m_keepsizeratio && m_viewer->aspect () < 0.01)
// m_viewer->setAspect (1.0 * m_viewer->width() / m_viewer->height());
m_view_area->fullScreen();
m_control_panel->popupMenu ()->setItemVisible (ControlPanel::menu_zoom, false);
m_widgetstack->visibleWidget ()->setFocus ();
} else {
if (m_sreensaver_disabled)
m_sreensaver_disabled = !kapp->dcopClient()->send
("kdesktop", "KScreensaverIface", "enable(bool)", TQString("true"));
m_view_area->fullScreen();
m_control_panel->popupMenu ()->setItemVisible (ControlPanel::menu_zoom, true);
}

@ -198,7 +198,6 @@ private:
bool m_playing;
bool m_mixer_init;
bool m_inVolumeUpdate;
bool m_sreensaver_disabled;
bool m_tmplog_needs_eol;
bool m_revert_fullscreen;
bool m_no_info;

@ -25,6 +25,7 @@ email :
#include <tqguardedptr.h>
#include <tqfileinfo.h>
#include <tqtimer.h>
#include "kmplayer.h"

Loading…
Cancel
Save