summaryrefslogtreecommitdiffstats
path: root/kdecore
diff options
context:
space:
mode:
Diffstat (limited to 'kdecore')
-rw-r--r--kdecore/kapplication.cpp76
-rw-r--r--kdecore/kapplication.h45
2 files changed, 55 insertions, 66 deletions
diff --git a/kdecore/kapplication.cpp b/kdecore/kapplication.cpp
index 5606b54fa..3bdf0b4cc 100644
--- a/kdecore/kapplication.cpp
+++ b/kdecore/kapplication.cpp
@@ -667,6 +667,22 @@ KApplication::KApplication( bool allowStyles, bool GUIenabled ) :
}
#ifdef Q_WS_X11
+KApplication::KApplication( Display *dpy, bool allowStyles ) :
+ TQApplication( dpy, *KCmdLineArgs::qt_argc(), *KCmdLineArgs::qt_argv(),
+ getX11RGBAVisual(dpy), getX11RGBAColormap(dpy) ),
+ KInstance( KCmdLineArgs::about), display(0L), d (new KApplicationPrivate)
+{
+ aIconPixmap.pm.icon = 0L;
+ aIconPixmap.pm.miniIcon = 0L;
+ read_app_startup_id();
+ useStyles = allowStyles;
+ setName( instanceName() );
+ installSigpipeHandler();
+ parseCommandLine( );
+ init( true );
+ d->m_KAppDCOPInterface = new KAppDCOPInterface(this);
+}
+
KApplication::KApplication( Display *dpy, Qt::HANDLE visual, Qt::HANDLE colormap,
bool allowStyles ) :
TQApplication( dpy, *KCmdLineArgs::qt_argc(), *KCmdLineArgs::qt_argv(),
@@ -1803,11 +1819,16 @@ bool KApplication::detectCompositionManagerAvailable(bool force_available) {
Display* KApplication::openX11RGBADisplay() {
KCmdLineArgs *qtargs = KCmdLineArgs::parsedArgs("qt");
- char *displayname = 0;
+ char *display = 0;
if ( qtargs->isSet("display"))
- displayname = qtargs->getOption( "display" ).data();
-
- Display *dpy = XOpenDisplay( displayname );
+ display = qtargs->getOption( "display" ).data();
+
+ Display *dpy = XOpenDisplay( display );
+ if ( !dpy ) {
+ kdError() << "cannot connect to X server " << display << endl;
+ exit( 1 );
+ }
+
return dpy;
}
@@ -1866,53 +1887,6 @@ void KApplication::getX11RGBAInformation(Display *dpy) {
argb_visual = false;
return;
}
-
-KApplication KApplication::KARGBApplicationObject( bool allowStyles ) {
- KCmdLineArgs *qtargs = KCmdLineArgs::parsedArgs("qt");
- bool argb_visual_available = false;
- char *display = 0;
- if ( qtargs->isSet("display"))
- display = qtargs->getOption( "display" ).data();
-
- Display *dpy = XOpenDisplay( display );
- if ( !dpy ) {
- kdError() << "cannot connect to X server " << display << endl;
- exit( 1 );
- }
-
- int screen = DefaultScreen( dpy );
- Colormap colormap = 0;
- Visual *visual = 0;
- int event_base, error_base;
-
- if ( XRenderQueryExtension( dpy, &event_base, &error_base ) ) {
- int nvi;
- XVisualInfo templ;
- templ.screen = screen;
- templ.depth = 32;
- templ.c_class = TrueColor;
- XVisualInfo *xvi = XGetVisualInfo( dpy, VisualScreenMask | VisualDepthMask
- | VisualClassMask, &templ, &nvi );
-
- for ( int i = 0; i < nvi; i++ ) {
- XRenderPictFormat *format = XRenderFindVisualFormat( dpy, xvi[i].visual );
- if ( format->type == PictTypeDirect && format->direct.alphaMask ) {
- visual = xvi[i].visual;
- colormap = XCreateColormap( dpy, RootWindow( dpy, screen ), visual, AllocNone );
- kdDebug() << "found visual with alpha support" << endl;
- argb_visual_available = true;
- break;
- }
- }
- }
-
- if( argb_visual_available ) {
- return KApplication( dpy, Qt::HANDLE( visual ), Qt::HANDLE( colormap ), allowStyles );
- }
- else {
- return KApplication(allowStyles, true);
- }
-}
#else
void KApplication::getX11RGBAInformation(Display *dpy) {
}
diff --git a/kdecore/kapplication.h b/kdecore/kapplication.h
index 9558d528e..ee0d48f02 100644
--- a/kdecore/kapplication.h
+++ b/kdecore/kapplication.h
@@ -113,9 +113,11 @@ public:
* This constructor takes aboutData and command line
* arguments from KCmdLineArgs.
*
- * If ARGB (transparent) widgets are to be used in your application,
- * please use KARGBApplication(new object name) or
- * KARGBApplication(new object name, allow_styles) instead of KApplication(...).
+ * If ARGB (transparent) widgets are to be used in your application,
+ * please use
+ * KApplication app(KApplication::openX11RGBADisplay());
+ * or
+ * KApplication app(KApplication::openX11RGBADisplay(), useStyles);
*
* @param allowStyles Set to false to disable the loading on plugin based
* styles. This is only useful to applications that do not display a GUI
@@ -131,6 +133,25 @@ public:
#ifdef Q_WS_X11
/**
* Constructor. Parses command-line arguments. Use this constructor when you
+ * you want ARGB support to be automatically detected and enabled.
+ *
+ * @param display Will be passed to Qt as the X display. The display must be
+ * valid and already opened.
+ *
+ * @param allowStyles Set to false to disable the loading on plugin based
+ * styles. This is only useful to applications that do not display a GUI
+ * normally. If you do create an application with @p allowStyles set to false
+ * that normally runs in the background but under special circumstances
+ * displays widgets call enableStyles() before displaying any widgets.
+ *
+ * @since KDE 3.5
+ *
+ * @see RGBADisplay()
+ */
+ KApplication(Display *display, bool allowStyles);
+
+ /**
+ * Constructor. Parses command-line arguments. Use this constructor when you
* you need to use a non-default visual or colormap.
*
* @param display Will be passed to Qt as the X display. The display must be
@@ -899,19 +920,13 @@ public:
/**
* @internal
- * Opens an X11 display and returns the handle to it
- * @return the X11 display handle
+ * Opens the display
+ * This can be used to initialize a KApplication with RGBA support like this:
+ * KApplication app(KApplication::openX11RGBADisplay());
+ * or
+ * KApplication app(KApplication::openX11RGBADisplay(), useStyles);
*/
- Display *openX11RGBADisplay();
-
- /**
- * @internal
- * Creates a default KApplication with transparency support
- * (if available)
- */
- static KApplication KARGBApplicationObject( bool allowStyles=true );
-
- #define KARGBApplication(objectname, ...) const KApplication &__kapplication_internal_app = KApplication::KARGBApplicationObject(__VA_ARGS__); KApplication &objectname = const_cast<KApplication&>(__kapplication_internal_app);
+ static Display* openX11RGBADisplay();
/**
* Returns the X11 display visual