summaryrefslogtreecommitdiffstats
path: root/ksplashml/themeengine/simple
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit4aed2c8219774f5d797760606b8489a92ddc5163 (patch)
tree3f8c130f7d269626bf6a9447407ef6c35954426a /ksplashml/themeengine/simple
downloadtdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz
tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'ksplashml/themeengine/simple')
-rw-r--r--ksplashml/themeengine/simple/Makefile.am7
-rw-r--r--ksplashml/themeengine/simple/configure.in.in27
-rw-r--r--ksplashml/themeengine/simple/main.cpp182
3 files changed, 216 insertions, 0 deletions
diff --git a/ksplashml/themeengine/simple/Makefile.am b/ksplashml/themeengine/simple/Makefile.am
new file mode 100644
index 000000000..8f1e8ac93
--- /dev/null
+++ b/ksplashml/themeengine/simple/Makefile.am
@@ -0,0 +1,7 @@
+
+INCLUDES = $(all_includes)
+
+bin_PROGRAMS = ksplashsimple
+ksplashsimple_SOURCES = main.cpp
+ksplashsimple_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+ksplashsimple_LDADD = $(LIB_XINERAMA) $(LIB_X11)
diff --git a/ksplashml/themeengine/simple/configure.in.in b/ksplashml/themeengine/simple/configure.in.in
new file mode 100644
index 000000000..e049bf94d
--- /dev/null
+++ b/ksplashml/themeengine/simple/configure.in.in
@@ -0,0 +1,27 @@
+LIB_XINERAMA=
+
+AC_ARG_WITH([xinerama],
+ AC_HELP_STRING([--without-xinerama], [Disable xinerama extension support (default: check)]) )
+
+if test "x$with_xinerama" != "xno"; then
+ xinerama_save_ldflags="$LDFLAGS"
+ LDFLAGS="$X_LDFLAGS"
+
+ KDE_CHECK_HEADER(X11/extensions/Xinerama.h,
+ [
+ AC_CHECK_LIB(Xinerama,XineramaQueryExtension,
+ [
+ AC_DEFINE(HAVE_XINERAMA, 1, [Define if you have the Xinerama extension])
+ LIB_XINERAMA="-lXinerama -lXext"
+ ],
+ [],
+ [ $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS ])
+ ], [],
+ [
+ #include <X11/Xlib.h>
+ ] )
+
+ AC_SUBST(LIB_XINERAMA)
+ LDFLAGS="$xinerama_save_ldflags"
+fi
+
diff --git a/ksplashml/themeengine/simple/main.cpp b/ksplashml/themeengine/simple/main.cpp
new file mode 100644
index 000000000..940ecc874
--- /dev/null
+++ b/ksplashml/themeengine/simple/main.cpp
@@ -0,0 +1,182 @@
+/***************************************************************************
+ * Copyright 2004 Lubos Lunak <l.lunak@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License (version 2) as *
+ * published by the Free Software Foundation. (The original KSplash/ML *
+ * codebase (upto version 0.95.3) is BSD-licensed.) *
+ * *
+ ***************************************************************************/
+
+#include <config.h>
+
+#include <X11/Xlib.h>
+#ifdef HAVE_XINERAMA
+extern "C" { // for older XFree86 versions
+#include <X11/extensions/Xinerama.h>
+}
+#endif
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+
+#ifdef TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
+
+//#define DEBUG
+
+int main( int argc, char* argv[])
+ {
+ if( fork() != 0 )
+ return 0;
+ Display* dpy = XOpenDisplay( NULL );
+ if( dpy == NULL )
+ return 1;
+ bool test = false;
+ if( argc == 2 && strcmp( argv[ 1 ], "--test" ) == 0 )
+ test = true;
+ int sx, sy, sw, sh;
+#ifdef HAVE_XINERAMA
+ // Xinerama code from Qt
+ XineramaScreenInfo *xinerama_screeninfo = 0;
+ int unused;
+ bool use_xinerama = XineramaQueryExtension( dpy, &unused, &unused )
+ && XineramaIsActive( dpy );
+ if (use_xinerama)
+ {
+ int screenCount;
+ xinerama_screeninfo = XineramaQueryScreens( dpy, &screenCount );
+ sx = xinerama_screeninfo[ 0 ].x_org;
+ sy = xinerama_screeninfo[ 0 ].y_org;
+ sw = xinerama_screeninfo[ 0 ].width;
+ sh = xinerama_screeninfo[ 0 ].height;
+ }
+ else
+#endif
+ {
+ sx = sy = 0;
+ sw = WidthOfScreen( ScreenOfDisplay( dpy, DefaultScreen( dpy )));
+ sh = HeightOfScreen( ScreenOfDisplay( dpy, DefaultScreen( dpy )));
+ }
+ XSetWindowAttributes attrs;
+ attrs.override_redirect = True;
+ const int states = 6;
+ const int frame = 3;
+ const int segment = sw / 2 / states;
+ const int w = segment * states + 2 * frame;
+ const int h = sh / 20 + frame;
+ Window win = XCreateWindow( dpy, DefaultRootWindow( dpy ), sx + ( sw - w ) / 2, sy + ( sh - h ) /2, w, h,
+ 0, CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect, &attrs );
+ Pixmap pix = XCreatePixmap( dpy, DefaultRootWindow( dpy ), w, h, DefaultDepth( dpy, 0 ));
+ XGCValues values;
+ values.foreground = WhitePixel( dpy, 0 );
+ GC gc = XCreateGC( dpy, pix, GCForeground, &values );
+ XFillRectangle( dpy, pix, gc, 0, 0, w, h );
+ values.foreground = BlackPixel( dpy, 0 );
+ XChangeGC( dpy, gc, GCForeground, &values );
+// XFillRectangle( dpy, pix, gc, 0, 0, w, frame );
+// XFillRectangle( dpy, pix, gc, 0, h - frame, w, frame );
+// XFillRectangle( dpy, pix, gc, 0, 0, frame, h );
+// XFillRectangle( dpy, pix, gc, w - frame, 0, frame, h );
+ XSetWindowBackgroundPixmap( dpy, win, pix );
+ XSelectInput( dpy, win, ButtonPressMask );
+ XSelectInput( dpy, DefaultRootWindow( dpy ), SubstructureNotifyMask );
+ XMapWindow( dpy, win );
+ int pos = 0;
+ int state = 1; // cannot check dcop connection - make this state initial
+ const int delay = 200; // ms
+ time_t final_time = time( NULL ) + 60;
+ time_t test_time = time( NULL ) + 1;
+ Atom kde_splash_progress = XInternAtom( dpy, "_KDE_SPLASH_PROGRESS", False );
+ for(;;)
+ {
+ while( XPending( dpy ))
+ {
+ XEvent ev;
+ XNextEvent( dpy, &ev );
+ if( ev.type == ButtonPress && ev.xbutton.window == win && ev.xbutton.button == Button1 )
+ {
+ final_time = time( NULL );
+ break;
+ }
+ if( ev.type == ConfigureNotify && ev.xconfigure.event == DefaultRootWindow( dpy ))
+ XRaiseWindow( dpy, win );
+ if( ev.type == ClientMessage && ev.xclient.window == DefaultRootWindow( dpy )
+ && ev.xclient.message_type == kde_splash_progress )
+ {
+ // based on ksplash
+ const char* s = ev.xclient.data.b;
+#ifdef DEBUG
+ fprintf( stderr,"MESSAGE: %s\n", s );
+#endif
+ if( strcmp( s, "dcop" ) == 0 && state < 1 )
+ state = 1; // not actually used, state starts from 1, because dcop cannot be checked
+ else if( strcmp( s, "kded" ) == 0 && state < 2 )
+ state = 2;
+ else if( strcmp( s, "kcminit" ) == 0 )
+ ; // unused
+ else if( strcmp( s, "ksmserver" ) == 0 && state < 3 )
+ state = 3;
+ else if( strcmp( s, "wm started" ) == 0 && state < 4 )
+ state = 4;
+ else if( strcmp( s, "kdesktop" ) == 0 && state < 5 )
+ state = 5;
+ else if(( strcmp( s, "kicker" ) == 0 || strcmp( s, "session ready" ) == 0 ) && state < 6 )
+ state = 6;
+ }
+ }
+ if( test && time( NULL ) >= test_time )
+ {
+ ++state;
+ test_time = time( NULL ) + 1;
+ }
+ if( pos != state )
+ {
+ while( pos < state && pos < states )
+ {
+#ifdef DEBUG
+ fprintf( stderr, "POS: %d\n", pos );
+#endif
+ final_time = time( NULL ) + 60;
+ XFillRectangle( dpy, pix, gc, frame + pos * segment, frame, segment, h - 2 * frame );
+ XSetWindowBackgroundPixmap( dpy, win, pix );
+ XClearWindow( dpy, win );
+ ++pos;
+ if( pos >= states )
+ {
+#ifdef DEBUG
+ fprintf( stderr, "CLOSING DOWN\n" );
+#endif
+ final_time = time( NULL ) + 2;
+ }
+ }
+ }
+ fd_set set;
+ FD_ZERO( &set );
+ FD_SET( XConnectionNumber( dpy ), &set );
+ struct timeval tv;
+ tv.tv_sec = 0;
+ tv.tv_usec = delay * 1000;
+ select( XConnectionNumber( dpy ) + 1, &set, NULL, NULL, &tv );
+ if( time( NULL ) >= final_time )
+ {
+#ifdef DEBUG
+ fprintf( stderr, "EXITING\n" );
+#endif
+ break; // --->
+ }
+ }
+ XFreePixmap( dpy, pix );
+ XDestroyWindow( dpy, win );
+ XFreeGC( dpy, gc );
+ XCloseDisplay( dpy );
+ }