summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoronestone <onestone>2006-12-21 14:12:32 +0000
committeronestone <onestone>2006-12-21 14:12:32 +0000
commit0ada037d4a0f6c6ee9ee1bfcbe85faf0fa511116 (patch)
tree403ef94cd0ad5a3e24cdc670dde616ea17614e1d
parent4787a246db329e3acec6c089a17d7cf31f68a9b6 (diff)
downloadaquamarine-0ada037d4a0f6c6ee9ee1bfcbe85faf0fa511116.tar.gz
aquamarine-0ada037d4a0f6c6ee9ee1bfcbe85faf0fa511116.tar.bz2
aquamarine: compiz backport of toolkit actions
-rw-r--r--src/decorator.cpp84
-rw-r--r--src/utils.cpp70
-rw-r--r--src/utils.h18
-rw-r--r--src/window.cpp62
-rw-r--r--src/window.h7
5 files changed, 200 insertions, 41 deletions
diff --git a/src/decorator.cpp b/src/decorator.cpp
index 8da5808..535684e 100644
--- a/src/decorator.cpp
+++ b/src/decorator.cpp
@@ -27,12 +27,14 @@
#include <qglobal.h>
+#include <dcopclient.h>
#include <kcmdlineargs.h>
#include <kconfig.h>
#include <kdebug.h>
#include <kglobal.h>
#include <kwinmodule.h>
#include <klocale.h>
+#include <kwin.h>
#include <qpoint.h>
@@ -106,7 +108,9 @@ m_kwinmodule (new KWinModule (this, KWinModule::INFO_ALL)), m_switcher (0)
{
// delete KGlobal::_locale;
// KGlobal::_locale = new KLocale( "kwin" , NULL );
- KGlobal::locale()->insertCatalogue("kwin");
+// KGlobal::locale()->insertCatalogue("aquamarine");
+ KGlobal::locale()->insertCatalogue("kdelibs");
+ KGlobal::locale()->setActiveCatalogue("aquamarine");
ready = false;
m_restart = false;
@@ -186,6 +190,12 @@ m_kwinmodule (new KWinModule (this, KWinModule::INFO_ALL)), m_switcher (0)
}
connect( this, SIGNAL(appearanceChanged()), SLOT(reconfigure()) );
+
+ (void) QApplication::desktop (); // trigger creation of desktop widget
+
+ // select for client messages
+ XSelectInput (qt_xdisplay(), qt_xrootwin (),
+ StructureNotifyMask | PropertyChangeMask);
}
Aquamarine::Decorator::~Decorator ()
@@ -362,6 +372,63 @@ Aquamarine::Decorator::x11EventFilter (XEvent * xevent)
client->updateCursor (QPoint (xme->x, xme->y));
break;
}
+ case ClientMessage:
+ if (xevent->xclient.message_type == Atoms::toolkitActionAtom)
+ {
+ long action;
+
+ action = xevent->xclient.data.l[0];
+ if ((Atom)action == Atoms::toolkitActionWindowMenuAtom)
+ {
+ if (m_windows.contains (xevent->xclient.window))
+ {
+ QPoint pos;
+
+ Aquamarine::Window * client = m_windows[xevent->xclient.window];
+
+ if (xevent->xclient.data.l[2])
+ {
+ pos = QPoint (xevent->xclient.data.l[3],
+ xevent->xclient.data.l[4]);
+ }
+ else
+ {
+ pos = client->geometry ().topLeft ();
+ }
+
+ client->showWindowMenu (pos);
+ }
+ }
+ else if ((Atom)action == Atoms::toolkitActionMainMenuAtom)
+ {
+ dcopClient ()->send ("kicker",
+ "kicker",
+ "showKMenu()",
+ QByteArray ());
+ }
+ else if ((Atom)action == Atoms::toolkitActionRunDialogAtom)
+ {
+ dcopClient ()->send ("kdesktop",
+ "KDesktopIface",
+ "popupExecuteCommand()",
+ QByteArray ());
+ }
+ else if ((Atom)action == Atoms::toolkitActionForceQuitDialogAtom)
+ {
+ if (m_windows.contains (xevent->xclient.window))
+ {
+ Time timestamp = xevent->xclient.data.l[1];
+
+ Aquamarine::Window * client = m_windows[xevent->xclient.window];
+
+ if (xevent->xclient.data.l[2])
+ client->showKillProcessDialog (timestamp);
+ else
+ client->hideKillProcessDialog ();
+ }
+ }
+ }
+ break;
default:
break;
}
@@ -484,6 +551,21 @@ Aquamarine::Decorator::slotWindowAdded (WId id)
}
}
+ KWin::WindowInfo wInfo = KWin::windowInfo (id, NET::WMWindowType, 0);
+
+ switch (wInfo.windowType (~0)) {
+ case NET::Normal:
+ case NET::Dialog:
+ case NET::Toolbar:
+ case NET::Menu:
+ case NET::Utility:
+ case NET::Splash:
+ /* decorate these window types */
+ break;
+ default:
+ return;
+ }
+
if (frame)
{
if (!m_windows.contains (id))
diff --git a/src/utils.cpp b/src/utils.cpp
index 869bb33..9761055 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -48,42 +48,48 @@ namespace Aquamarine
namespace Atoms
{
- Atom select_window;
+ Atom select_window;
- Atom manager;
- Atom targets;
- Atom multiple;
- Atom timestamp;
- Atom version;
- Atom atom_pair;
+ Atom manager;
+ Atom targets;
+ Atom multiple;
+ Atom timestamp;
+ Atom version;
+ Atom atom_pair;
- Atom opacity;
- Atom saturation;
- Atom brightness;
+ Atom opacity;
+ Atom saturation;
+ Atom brightness;
- Atom utf8_string;
+ Atom utf8_string;
- Atom dm_name;
- Atom dm_sn;
+ Atom dm_name;
+ Atom dm_sn;
- Atom net_frame_window;
- Atom net_window_decor;
- Atom net_wm_moveresize;
+ Atom net_frame_window;
+ Atom net_window_decor;
+ Atom net_wm_moveresize;
- Atom wm_delete_window;
- Atom wm_take_focus;
- Atom net_wm_context_help;
- Atom net_wm_ping;
- Atom net_wm_take_activity;
- Atom wm_protocols;
+ Atom wm_delete_window;
+ Atom wm_take_focus;
+ Atom net_wm_context_help;
+ Atom net_wm_ping;
+ Atom net_wm_take_activity;
+ Atom wm_protocols;
- Atom net_desktop_viewport;
- Atom net_desktop_geometry;
+ Atom net_desktop_viewport;
+ Atom net_desktop_geometry;
- Atom wm_name;
- Atom wm_sn;
+ Atom wm_name;
+ Atom wm_sn;
- Atom change_frame_window;
+ Atom change_frame_window;
+
+ Atom toolkitActionAtom;
+ Atom toolkitActionWindowMenuAtom;
+ Atom toolkitActionMainMenuAtom;
+ Atom toolkitActionRunDialogAtom;
+ Atom toolkitActionForceQuitDialogAtom;
}
}
@@ -515,4 +521,14 @@ Aquamarine::Atoms::init ()
change_frame_window =
XInternAtom (xdisplay, "_BERYL_CHANGE_FRAME_WINDOW", false);
+ toolkitActionAtom = XInternAtom (xdisplay, "_COMPIZ_TOOLKIT_ACTION", false);
+ toolkitActionWindowMenuAtom =
+ XInternAtom (xdisplay, "_COMPIZ_TOOLKIT_ACTION_WINDOW_MENU", false);
+ toolkitActionMainMenuAtom =
+ XInternAtom (xdisplay, "_COMPIZ_TOOLKIT_ACTION_MAIN_MENU", false);
+ toolkitActionRunDialogAtom =
+ XInternAtom (xdisplay, "_COMPIZ_TOOLKIT_ACTION_RUN_DIALOG", false);
+ toolkitActionForceQuitDialogAtom =
+ XInternAtom (xdisplay, "_COMPIZ_TOOLKIT_ACTION_FORCE_QUIT_DIALOG", false);
+
}
diff --git a/src/utils.h b/src/utils.h
index 88fb682..1c64ad1 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -38,19 +38,7 @@ namespace Aquamarine
{
namespace Atoms
{
- extern Atom restack_window;
extern Atom select_window;
- extern Atom mwm_hints;
-
- extern Atom toolkit_action;
- extern Atom toolkit_action_main_menu;
- extern Atom toolkit_action_run_dialog;
- extern Atom toolkit_action_window_menu;
- extern Atom toolkit_action_force_quit_dialog;
-
- extern Atom panel_action;
- extern Atom panel_action_main_menu;
- extern Atom panel_action_run_dialog;
extern Atom manager;
extern Atom targets;
@@ -89,6 +77,12 @@ namespace Aquamarine
extern Atom change_frame_window;
+ extern Atom toolkitActionAtom;
+ extern Atom toolkitActionWindowMenuAtom;
+ extern Atom toolkitActionMainMenuAtom;
+ extern Atom toolkitActionRunDialogAtom;
+ extern Atom toolkitActionForceQuitDialogAtom;
+
void init ();
}
diff --git a/src/window.cpp b/src/window.cpp
index cf852fc..d3b9658 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -49,7 +49,10 @@
#include <kdecoration.h>
#include <kwin.h>
#include <klocale.h>
+#include <kprocess.h>
+#include <kstandarddirs.h>
+#include <netwm.h>
#include <qapplication.h>
#include <qlayout.h>
@@ -112,7 +115,8 @@ m_popup (0),
m_advanced_popup (0),
m_viewport_menu (0),
m_appearance_menu (0),
-m_brightness_menu (0), m_saturation_menu (0), m_opacity_menu (0)
+m_brightness_menu (0), m_saturation_menu (0), m_opacity_menu (0),
+mProcessKiller (0)
{
KWin::WindowInfo wInf = KWin::windowInfo (m_wid, NET::WMState, 0);
m_state = wInf.state ();
@@ -1827,3 +1831,59 @@ Aquamarine::Window::eventFilter (QObject * watched, QEvent * event)
return rv;
}
+void Aquamarine::Window::handleProcessKillerExited (void)
+{
+ if (mProcessKiller)
+ {
+ delete mProcessKiller;
+ mProcessKiller = NULL;
+ }
+}
+
+void Aquamarine::Window::showKillProcessDialog (Time timestamp)
+{
+ KWin::WindowInfo kWinInfo =
+ KWin::windowInfo (m_wid, 0, NET::WM2WindowClass | NET::WM2ClientMachine);
+ NETWinInfo wInfo = NETWinInfo (qt_xdisplay(), m_wid,
+ qt_xrootwin (), NET::WMPid);
+ QCString clientMachine, resourceClass;
+ pid_t pid;
+ char buf[257];
+
+ if (mProcessKiller)
+ return;
+
+ clientMachine = kWinInfo.clientMachine ();
+ resourceClass = kWinInfo.windowClassClass ();
+ pid = wInfo.pid ();
+
+ if (gethostname (buf, sizeof (buf) - 1) == 0)
+ {
+ if (strcmp (buf, clientMachine) == 0)
+ clientMachine = "localhost";
+ }
+
+ mProcessKiller = new KProcess (this);
+
+ *mProcessKiller << KStandardDirs::findExe ("kwin_killer_helper") <<
+ "--pid" << QCString ().setNum (pid) <<
+ "--hostname" << clientMachine <<
+ "--windowname" << m_name.utf8 () <<
+ "--applicationname" << resourceClass <<
+ "--wid" << QCString ().setNum (m_wid) <<
+ "--timestamp" << QCString ().setNum (timestamp);
+
+ connect (mProcessKiller, SIGNAL (processExited (KProcess *)),
+ SLOT (handleProcessKillerExited ()));
+
+ if (!mProcessKiller->start (KProcess::NotifyOnExit))
+ {
+ delete mProcessKiller;
+ mProcessKiller = NULL;
+ }
+}
+
+void Aquamarine::Window::hideKillProcessDialog (void)
+{
+ handleProcessKillerExited ();
+}
diff --git a/src/window.h b/src/window.h
index bcdd4dc..e3f757e 100644
--- a/src/window.h
+++ b/src/window.h
@@ -40,6 +40,7 @@
class KDecoration;
class QPopupMenu;
+class KProcess;
namespace Aquamarine
{
@@ -141,6 +142,9 @@ namespace Aquamarine
void setMapping (bool map);
+ void showKillProcessDialog (Time timestamp);
+ void hideKillProcessDialog (void);
+
protected:
virtual bool eventFilter (QObject * watched, QEvent * event);
@@ -180,6 +184,7 @@ namespace Aquamarine
void slotChangeViewport (int id);
void slotAppearanceChange (int id);
void slotDesktopGeometryChanged ();
+ void handleProcessKillerExited (void);
private:
WId m_wid;
@@ -229,6 +234,8 @@ namespace Aquamarine
QRect m_soffset;
int m_sradius;
short m_scolor[4];
+
+ KProcess *mProcessKiller;
};
}