[Konsole-devel] Fwd: KDE/kdebase/apps/konsole/src

Kurt Hindenburg kurt.hindenburg at gmail.com
Wed Oct 7 03:09:58 UTC 2009


FYI,  I don't know enough about this to know if there are  issues with these
changes.

---------- Forwarded message ----------
From: Fredrik Höglund <fredrik at kde.org>
Date: Tue, Oct 6, 2009 at 6:46 PM
Subject: KDE/kdebase/apps/konsole/src
To: kde-commits at kde.org


SVN commit 1032123 by fredrik:

Get rid of the ARGB visual hack, and use Qt::WA_TranslucentBackground
instead.


 M  +0 -8      Application.cpp
 M  +0 -5      Application.h
 M  +15 -0     MainWindow.cpp
 M  +5 -79     main.cpp


--- trunk/KDE/kdebase/apps/konsole/src/Application.cpp #1032122:1032123
@@ -48,14 +48,6 @@

 using namespace Konsole;

-#ifdef Q_WS_X11
-Application::Application(Display* display , Qt::HANDLE visual, Qt::HANDLE
colormap)
-    : KUniqueApplication(display,visual,colormap)
-{
-    init();
-}
-#endif
-
 Application::Application() : KUniqueApplication()
 {
    init();
--- trunk/KDE/kdebase/apps/konsole/src/Application.h #1032122:1032123
@@ -52,11 +52,6 @@

 public:
    /** Constructs a new Konsole application. */
-#ifdef Q_WS_X11
-    Application(Display* display , Qt::HANDLE visual, Qt::HANDLE colormap);
-#endif
-
-    /** Constructs a new Konsole application. */
    Application();

    virtual ~Application();
--- trunk/KDE/kdebase/apps/konsole/src/MainWindow.cpp #1032122:1032123
@@ -30,6 +30,7 @@
 #include <KActionCollection>
 #include <KActionMenu>
 #include <KApplication>
+#include <KCmdLineArgs>
 #include <KShortcutsDialog>
 #include <KLocale>
 #include <KMenu>
@@ -41,6 +42,7 @@
 #include <KToolInvocation>
 #include <KStandardAction>
 #include <KStandardGuiItem>
+#include <KWindowSystem>
 #include <KXMLGUIFactory>
 #include <KNotifyConfigWidget>

@@ -57,12 +59,25 @@

 using namespace Konsole;

+static bool useTransparency()
+{
+    KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
+    bool compositingAvailable = KWindowSystem::compositingActive() ||
+                                args->isSet("force-transparency");
+    return compositingAvailable && args->isSet("transparency");
+}
+
 MainWindow::MainWindow()
 : KXmlGuiWindow() ,
   _bookmarkHandler(0),
   _pluggedController(0),
   _menuBarVisibilitySet(false)
 {
+    if (useTransparency()) {
+        setAttribute(Qt::WA_TranslucentBackground);
+        setAttribute(Qt::WA_NoSystemBackground, false);
+    }
+
    // create actions for menus
    setupActions();

--- trunk/KDE/kdebase/apps/konsole/src/main.cpp #1032122:1032123
@@ -25,31 +25,19 @@
 // Unix
 #include <unistd.h>

-// X11
-#ifdef Q_WS_X11
-#include <X11/Xlib.h>
-#include <X11/extensions/Xrender.h>
-#endif
-
 // KDE
 #include <KAboutData>
 #include <KCmdLineArgs>
 #include <KLocale>
-#include <KWindowSystem>

 #define KONSOLE_VERSION "2.4"

 using namespace Konsole;

-#ifdef Q_WS_X11
-void getDisplayInformation(Display*& display , Visual*& visual , Colormap&
colormap);
-#endif
-
 // fills the KAboutData structure with information about contributors to
 // Konsole
 void fillAboutData(KAboutData& aboutData);
 void fillCommandLineOptions(KCmdLineOptions& options);
-bool useTransparency();     // returns true if transparency should be
enabled
 bool forceNewProcess();     // returns true if new instance should use a
new
                            // process (instead of re-using an existing one)
 void restoreSession(Application& app);
@@ -83,26 +71,10 @@
    {
        exit(0);
    }
-#ifdef Q_WS_X11
-    if ( useTransparency() )
-    {
-        Display* display = 0;
-        Visual* visual = 0;
-        Colormap colormap = 0;
-
-        getDisplayInformation(display,visual,colormap);
-
-        Application app(display,(Qt::HANDLE)visual,(Qt::HANDLE)colormap);
-        restoreSession(app);
-        return app.exec();
-    }
-    else
-#endif
-    {
-        Application app;
-        restoreSession(app);
-        return app.exec();
-    }
+
+    Application app;
+    restoreSession(app);
+    return app.exec();
 }
 bool forceNewProcess()
 {
@@ -113,13 +85,7 @@
    KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
    return isatty(1) && !args->isSet("new-tab");
 }
-bool useTransparency()
-{
-    KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
-    bool compositingAvailable = KWindowSystem::compositingActive() ||
-                                args->isSet("force-transparency");
-    return compositingAvailable && args->isSet("transparency");
-}
+
 void fillCommandLineOptions(KCmdLineOptions& options)
 {
    options.add("profile <file>", ki18n("Name of profile to use for new
Konsole instance"));
@@ -209,46 +175,6 @@
  aboutData.setProgramIconName("utilities-terminal");
 }

-// code taken from the Qt 4 graphics dojo examples
-// at http://labs.trolltech.com
-#ifdef Q_WS_X11
-void getDisplayInformation(Display*& display , Visual*& visual , Colormap&
colormap)
-{
-    display = XOpenDisplay(0); // open default display
-    if (!display) {
-        kWarning("Cannot connect to the X server");
-        exit(1);
-    }
-
-    int screen = DefaultScreen(display);
-    int eventBase, errorBase;
-
-    if (XRenderQueryExtension(display, &eventBase, &errorBase)) {
-        int nvi;
-        XVisualInfo templ;
-        templ.screen  = screen;
-        templ.depth = 32;
-        templ.c_class = TrueColor;
-        XVisualInfo *xvi = XGetVisualInfo(display, VisualScreenMask |
-                                          VisualDepthMask |
-                                          VisualClassMask, &templ, &nvi);
-
-        for (int i = 0; i < nvi; ++i) {
-            XRenderPictFormat* format = XRenderFindVisualFormat(display,
-
 xvi[i].visual);
-            if (format->type == PictTypeDirect && format->direct.alphaMask)
{
-                visual = xvi[i].visual;
-                colormap = XCreateColormap(display, RootWindow(display,
screen),
-                                           visual, AllocNone);
-
-                // found ARGB visual
-                break;
-            }
-        }
-    }
-}
-#endif
-
 void restoreSession(Application& app)
 {
    if (app.isSessionRestored())
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/konsole-devel/attachments/20091006/0675539b/attachment.html>


More information about the konsole-devel mailing list