summaryrefslogtreecommitdiffstats
path: root/src/kmplayerapp.cpp
diff options
context:
space:
mode:
authorSlávek Banko <[email protected]>2012-07-11 03:36:42 +0200
committerSlávek Banko <[email protected]>2012-07-11 03:47:55 +0200
commit8fe6f08227059c8cddc686888fb3e402b83c9eff (patch)
tree8966907d5b5cc3ecdd6bb86bc845e605f07926b8 /src/kmplayerapp.cpp
parentefeb4d69d6d954caeb700e0a33ca0a8ae7d4e166 (diff)
downloadkmplayer-8fe6f08227059c8cddc686888fb3e402b83c9eff.tar.gz
kmplayer-8fe6f08227059c8cddc686888fb3e402b83c9eff.zip
Changed screen saver control to use fake events
This closes Bug 1031
Diffstat (limited to 'src/kmplayerapp.cpp')
-rw-r--r--src/kmplayerapp.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/kmplayerapp.cpp b/src/kmplayerapp.cpp
index bdeac91..fe8995a 100644
--- a/src/kmplayerapp.cpp
+++ b/src/kmplayerapp.cpp
@@ -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
+ /** TWin are you there? **/
+ m_haveKWin = KApplication::dcopClient()->isApplicationRegistered("twin");
+ if (m_haveKWin)
+ kdDebug() << "Window manager: TWin found" << endl;
+ else
+ kdDebug() << "Window manager: not TWin - 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 tde 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);