summaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/Makefile.am6
-rw-r--r--src/kmplayer.h6
-rw-r--r--src/kmplayerapp.cpp45
-rw-r--r--src/kmplayerpartbase.cpp5
-rw-r--r--src/kmplayerpartbase.h1
-rw-r--r--src/kmplayerview.cpp15
-rw-r--r--src/kmplayerview.h1
-rw-r--r--src/main.cpp1
8 files changed, 61 insertions, 19 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 5ebff92..3dd1ef0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -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)
tdeinit_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
diff --git a/src/kmplayer.h b/src/kmplayer.h
index ba2bf87..9c9b6d2 100644
--- a/src/kmplayer.h
+++ b/src/kmplayer.h
@@ -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 {
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);
diff --git a/src/kmplayerpartbase.cpp b/src/kmplayerpartbase.cpp
index 6a6f84c..32ead14 100644
--- a/src/kmplayerpartbase.cpp
+++ b/src/kmplayerpartbase.cpp
@@ -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;
diff --git a/src/kmplayerpartbase.h b/src/kmplayerpartbase.h
index 2ff4dbd..f21ba4f 100644
--- a/src/kmplayerpartbase.h
+++ b/src/kmplayerpartbase.h
@@ -192,6 +192,7 @@ public:
k_dcop:
void toggleFullScreen ();
bool isPlaying ();
+ bool isPaused ();
signals:
void sourceChanged (KMPlayer::Source * old, KMPlayer::Source * nw);
void sourceDimensionChanged ();
diff --git a/src/kmplayerview.cpp b/src/kmplayerview.cpp
index 0696826..61b5dfa 100644
--- a/src/kmplayerview.cpp
+++ b/src/kmplayerview.cpp
@@ -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);
}
diff --git a/src/kmplayerview.h b/src/kmplayerview.h
index 06ca60e..253b7c0 100644
--- a/src/kmplayerview.h
+++ b/src/kmplayerview.h
@@ -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;
diff --git a/src/main.cpp b/src/main.cpp
index 3cf6a1d..03874e3 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -25,6 +25,7 @@ email :
#include <tqguardedptr.h>
#include <tqfileinfo.h>
+#include <tqtimer.h>
#include "kmplayer.h"