summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@compiz-fusion.org>2008-08-20 19:52:06 +0200
committerDennis kasprzyk <onestone@compiz-fusion.org>2008-08-20 19:52:06 +0200
commit7dee054a80fec3640fa5b4621325ce768008a152 (patch)
treeb5ffab42859355bf2e964236693531eddd868dee
parent01b0aa33dfe61e00adfa390e2fc36087e3c9ab2e (diff)
downloadcompiz-with-glib-mainloop-7dee054a80fec3640fa5b4621325ce768008a152.tar.gz
compiz-with-glib-mainloop-7dee054a80fec3640fa5b4621325ce768008a152.tar.bz2
Moved session related functions/structs into own header and namespace.
-rw-r--r--include/compcore.h5
-rw-r--r--include/compiz-core.h24
-rw-r--r--include/compsession.h28
-rw-r--r--src/core.cpp4
-rw-r--r--src/main.cpp4
-rw-r--r--src/session.cpp48
6 files changed, 59 insertions, 54 deletions
diff --git a/include/compcore.h b/include/compcore.h
index e2e0f48..eb508f2 100644
--- a/include/compcore.h
+++ b/include/compcore.h
@@ -6,6 +6,7 @@
#include "wrapable.h"
#include <compoption.h>
+#include <compsession.h>
class PrivateCore;
@@ -79,7 +80,7 @@ class CoreInterface : public WrapableInterface<CompCore> {
WRAPABLE_DEF(void, objectAdd, CompObject *, CompObject *)
WRAPABLE_DEF(void, objectRemove, CompObject *, CompObject *)
- WRAPABLE_DEF(void, sessionEvent, CompSessionEvent, CompOption::Vector &)
+ WRAPABLE_DEF(void, sessionEvent, CompSession::Event, CompOption::Vector &)
};
class CompCore : public WrapableHandler<CoreInterface>, public CompObject {
@@ -178,7 +179,7 @@ class CompCore : public WrapableHandler<CoreInterface>, public CompObject {
WRAPABLE_HND(void, objectAdd, CompObject *, CompObject *)
WRAPABLE_HND(void, objectRemove, CompObject *, CompObject *)
- WRAPABLE_HND(void, sessionEvent, CompSessionEvent, CompOption::Vector &)
+ WRAPABLE_HND(void, sessionEvent, CompSession::Event, CompOption::Vector &)
friend class Timer;
private:
diff --git a/include/compiz-core.h b/include/compiz-core.h
index 4050a70..822a398 100644
--- a/include/compiz-core.h
+++ b/include/compiz-core.h
@@ -43,8 +43,6 @@
#include <X11/Xregion.h>
#include <X11/XKBlib.h>
-#define SN_API_NOT_YET_FROZEN
-#include <libsn/sn.h>
#include <GL/gl.h>
#include <GL/glx.h>
@@ -165,29 +163,7 @@ extern CompMetadata *coreMetadata;
/* session.c */
-typedef enum {
- CompSessionEventSaveYourself = 0,
- CompSessionEventSaveComplete,
- CompSessionEventDie,
- CompSessionEventShutdownCancelled
-} CompSessionEvent;
-typedef enum {
- CompSessionClientId = 0,
- CompSessionPrevClientId
-} CompSessionClientIdType;
-
-
-
-void
-initSession (char *smPrevClientId);
-
-void
-closeSession (void);
-
-
-char *
-getSessionClientId (CompSessionClientIdType type);
/* option.c */
diff --git a/include/compsession.h b/include/compsession.h
new file mode 100644
index 0000000..a08a916
--- /dev/null
+++ b/include/compsession.h
@@ -0,0 +1,28 @@
+#ifndef _COMPSESSION_H
+#define _COMPSESSION_H
+
+#define SN_API_NOT_YET_FROZEN
+#include <libsn/sn.h>
+
+namespace CompSession {
+
+ enum Event {
+ EventSaveYourself = 0,
+ EventSaveComplete,
+ EventDie,
+ EventShutdownCancelled
+ };
+
+ enum ClientIdType {
+ ClientId = 0,
+ PrevClientId
+ };
+
+ void initSession (char *smPrevClientId);
+
+ void closeSession (void);
+
+ char *getSessionClientId (ClientIdType type);
+};
+
+#endif \ No newline at end of file
diff --git a/src/core.cpp b/src/core.cpp
index 890787d..90789ef 100644
--- a/src/core.cpp
+++ b/src/core.cpp
@@ -471,7 +471,7 @@ CompCore::objectRemove (CompObject *parent, CompObject *object)
WRAPABLE_HND_FUNC(objectRemove, parent, object)
void
-CompCore::sessionEvent (CompSessionEvent event,
+CompCore::sessionEvent (CompSession::Event event,
CompOption::Vector &arguments)
WRAPABLE_HND_FUNC(sessionEvent, event, arguments)
@@ -521,7 +521,7 @@ CoreInterface::objectRemove (CompObject *parent, CompObject *object)
WRAPABLE_DEF_FUNC(objectRemove, parent, object)
void
-CoreInterface::sessionEvent (CompSessionEvent event,
+CoreInterface::sessionEvent (CompSession::Event event,
CompOption::Vector &arguments)
WRAPABLE_DEF_FUNC(sessionEvent, event, arguments)
diff --git a/src/main.cpp b/src/main.cpp
index 7f6e5c5..88e8804 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -373,7 +373,7 @@ main (int argc, char **argv)
return 1;
if (!disableSm)
- initSession (clientId);
+ CompSession::initSession (clientId);
if (!core->addDisplay (displayName))
return 1;
@@ -381,7 +381,7 @@ main (int argc, char **argv)
core->eventLoop ();
if (!disableSm)
- closeSession ();
+ CompSession::closeSession ();
delete core;
delete coreMetadata;
diff --git a/src/session.cpp b/src/session.cpp
index 99c1d23..6efb27a 100644
--- a/src/session.cpp
+++ b/src/session.cpp
@@ -36,14 +36,15 @@
#include <X11/SM/SMlib.h>
#include <X11/ICE/ICElib.h>
+#include <compsession.h>
#include <compiz-core.h>
#define SM_DEBUG(x)
static SmcConn smcConnection;
static CompWatchFdHandle iceWatchFdHandle;
-static Bool connected = 0;
-static Bool iceConnected = 0;
+static bool connected = false;
+static bool iceConnected = false;
static char *smClientId, *smPrevClientId;
static void iceInit (void);
@@ -58,7 +59,7 @@ setStringListProperty (SmcConn connection,
int i;
prop.name = (char *) name;
- prop.type = SmLISTofARRAY8;
+ prop.type = const_cast<char *> (SmLISTofARRAY8);
prop.vals = (SmPropValue *) malloc (nValues * sizeof (SmPropValue));
if (!prop.vals)
@@ -123,8 +124,8 @@ setRestartStyle (SmcConn connection,
SmProp prop, *pProp;
SmPropValue propVal;
- prop.name = SmRestartStyleHint;
- prop.type = SmCARD8;
+ prop.name = const_cast<char *> (SmRestartStyleHint);
+ prop.type = const_cast<char *> (SmCARD8);
prop.num_vals = 1;
prop.vals = &propVal;
propVal.value = &hint;
@@ -142,8 +143,8 @@ setProgram (SmcConn connection,
SmProp prop, *pProp;
SmPropValue propVal;
- prop.name = SmProgram;
- prop.type = SmARRAY8;
+ prop.name = const_cast<char *> (SmProgram);
+ prop.type = const_cast<char *> (SmARRAY8);
prop.num_vals = 1;
prop.vals = &propVal;
propVal.value = (SmPointer) program;
@@ -174,7 +175,7 @@ saveYourselfCallback (SmcConn connection,
args[2].value ().set (interact_Style);
args[3].value ().set ((bool) fast);
- core->sessionEvent (CompSessionEventSaveYourself, args);
+ core->sessionEvent (CompSession::EventSaveYourself, args);
setCloneRestartCommands (connection);
setRestartStyle (connection, SmRestartImmediately);
@@ -186,9 +187,9 @@ static void
dieCallback (SmcConn connection,
SmPointer clientData)
{
- core->sessionEvent (CompSessionEventDie, noOptions);
+ core->sessionEvent (CompSession::EventDie, noOptions);
- closeSession ();
+ CompSession::closeSession ();
exit (0);
}
@@ -196,18 +197,18 @@ static void
saveCompleteCallback (SmcConn connection,
SmPointer clientData)
{
- core->sessionEvent (CompSessionEventSaveComplete, noOptions);
+ core->sessionEvent (CompSession::EventSaveComplete, noOptions);
}
static void
shutdownCancelledCallback (SmcConn connection,
SmPointer clientData)
{
- core->sessionEvent (CompSessionEventShutdownCancelled, noOptions);
+ core->sessionEvent (CompSession::EventShutdownCancelled, noOptions);
}
void
-initSession (char *prevClientId)
+CompSession::initSession (char *prevClientId)
{
static SmcCallbacks callbacks;
@@ -256,7 +257,7 @@ initSession (char *prevClientId)
}
void
-closeSession (void)
+CompSession::closeSession (void)
{
if (connected)
{
@@ -278,21 +279,20 @@ closeSession (void)
}
char *
-getSessionClientId (CompSessionClientIdType type)
+CompSession::getSessionClientId (CompSession::ClientIdType type)
{
if (!connected)
return NULL;
switch (type) {
- case CompSessionClientId:
- if (smClientId)
- return strdup (smClientId);
- break;
-
- case CompSessionPrevClientId:
- if (smPrevClientId)
- return strdup (smPrevClientId);
- break;
+ case CompSession::ClientId:
+ if (smClientId)
+ return strdup (smClientId);
+ break;
+ case CompSession::PrevClientId:
+ if (smPrevClientId)
+ return strdup (smPrevClientId);
+ break;
}
return NULL;