mirror of
https://github.com/KDE/konsole.git
synced 2026-05-08 14:46:44 -04:00
Get rid of the ARGB visual hack, and use Qt::WA_TranslucentBackground instead.
svn path=/trunk/KDE/kdebase/apps/konsole/; revision=1032123
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -52,11 +52,6 @@ Q_OBJECT
|
||||
|
||||
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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
84
src/main.cpp
84
src/main.cpp
@@ -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 @@ extern "C" int KDE_EXPORT kdemain(int argc,char** argv)
|
||||
{
|
||||
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 @@ bool forceNewProcess()
|
||||
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 @@ void fillAboutData(KAboutData& aboutData)
|
||||
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())
|
||||
|
||||
Reference in New Issue
Block a user