diff options
Diffstat (limited to 'src/kmplayerapp.cpp')
-rw-r--r-- | src/kmplayerapp.cpp | 45 |
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); |