summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter@cs.unisa.edu.au>2007-03-15 22:25:08 +1030
committerPeter Hutterer <peter@cs.unisa.edu.au>2007-03-15 22:25:08 +1030
commit06fd74ee1a4fbccff0c815c71feaf5fe91fb6c9c (patch)
tree6918e430057affe59a34019eb62560f3ad1db00d
parent130c76ead4ae1251944ebbea85284c6808317f51 (diff)
+ add keyboard images for each connected keyboard to the dock. Currently
inactive.
-rw-r--r--Changelog2
-rw-r--r--images/keyboard.pngbin0 -> 1853 bytes
-rw-r--r--src/Config.cpp1
-rw-r--r--src/Config.h1
-rw-r--r--src/Dock.cpp40
-rw-r--r--src/Dock.h3
-rw-r--r--src/DockKeyboard.cpp35
-rw-r--r--src/DockKeyboard.h21
-rw-r--r--src/KeyboardDevice.cpp18
-rw-r--r--src/KeyboardDevice.h33
-rw-r--r--src/Makefile4
-rw-r--r--src/Manager.cpp24
-rw-r--r--src/Manager.h2
13 files changed, 183 insertions, 1 deletions
diff --git a/Changelog b/Changelog
index 34ad26a..89e85ef 100644
--- a/Changelog
+++ b/Changelog
@@ -13,6 +13,8 @@ o Try a bit of optimizing on window resizes to make it slightly faster.
o Update README file, with some more warnings.
+ add cursor hotplug handling, wrap cursor numbers at 10 so we don't run out
of images.
++ add keyboard images for each connected keyboard to the dock. Currently
+inactive.
14.03.2007
o use new access control for floor control, remove traces of MPGXlib.
diff --git a/images/keyboard.png b/images/keyboard.png
new file mode 100644
index 0000000..de7547b
--- /dev/null
+++ b/images/keyboard.png
Binary files differ
diff --git a/src/Config.cpp b/src/Config.cpp
index 862c328..abc1b70 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -48,6 +48,7 @@ Config::Config(XConn* x11)
this->x11 = x11;
clientOffset = 3;
imgBackground = IMAGEPATH "background.png";
+ kbdImage = IMAGEPATH "keyboard.png";
windowBarHeight = 30;
buttonWidth = 20;
diff --git a/src/Config.h b/src/Config.h
index ee56374..1e78b08 100644
--- a/src/Config.h
+++ b/src/Config.h
@@ -25,6 +25,7 @@ class Config
public:
char* imgBackground;
+ char* kbdImage;
int clientOffset;
int windowBarHeight;
int resizeBarHeight;
diff --git a/src/Dock.cpp b/src/Dock.cpp
index 4c606df..8ad8b56 100644
--- a/src/Dock.cpp
+++ b/src/Dock.cpp
@@ -80,6 +80,15 @@ bool Dock::hasWindow(Window win)
it2++;
}
+ /* check keyboards */
+ vector<DockKeyboard*>::const_iterator it3 = keyboards.begin();
+ while(it3 != keyboards.end())
+ {
+ if ((*it3)->hasWindow(win))
+ return true;
+ it3++;
+ }
+
return false;
}
@@ -113,6 +122,17 @@ void Dock::handleExpose(XExposeEvent* ev)
it2++;
}
+
+ vector<DockKeyboard*>::const_iterator it3 = keyboards.begin();
+ while(it3 != keyboards.end())
+ {
+ if ((*it3)->hasWindow(ev->window))
+ {
+ (*it3)->handleExpose(ev);
+ break;
+ }
+ it3++;
+ }
return;
}
@@ -175,6 +195,26 @@ void Dock::appendProcess(WMWindow* win)
TRACE("append dock with %d, dpx %d\n", width, dp_x);
}
+void Dock::appendKeyboard(KeyboardDevice* k)
+{
+ x -= DOCK_BUTTON_WIDTH/2;
+ width += DOCK_BUTTON_WIDTH;
+ XMoveResizeWindow(x11->dpy, dock, x, y, width, height);
+ int dk_x = width - DOCK_BUTTON_WIDTH - DOCK_WIDTH_EXTENDED/2;
+ int dk_y = DOCK_HEIGHT_EXTENDED;
+ DockKeyboard* dk = new DockKeyboard(x11, k);
+ dk->initGUI(dock, dk_x, dk_y, DOCK_BUTTON_WIDTH, DOCK_BUTTON_HEIGHT);
+ dk->setup();
+ keyboards.push_back(dk);
+
+ XFreePixmap(x11->dpy, backbuff);
+ backbuff = XCreatePixmap(x11->dpy, dock, width, height, x11->depth);
+ repaint();
+
+ TRACE("append keyboard with %d, dkx %d\n", width, dk_x);
+}
+
+
/*
* Removes a process from the dock. Usually after maximizing it again.
*/
diff --git a/src/Dock.h b/src/Dock.h
index 677b156..491d2d5 100644
--- a/src/Dock.h
+++ b/src/Dock.h
@@ -9,6 +9,7 @@
#include "Config.h"
#include "DockApp.h"
#include "DockProcess.h"
+#include "DockKeyboard.h"
using namespace std;
@@ -35,6 +36,7 @@ class Dock
GC gc_dock;
vector<DockApp*> apps; /* apps to start app */
vector<DockProcess*> processes; /* minimized processes */
+ vector<DockKeyboard*> keyboards; /* connected keyboards */
int x;
int y;
@@ -50,6 +52,7 @@ class Dock
void handleExpose(XExposeEvent* ev);
void handleButtonEvent(XButtonEvent *ev);
void appendProcess(WMWindow* win);
+ void appendKeyboard(KeyboardDevice* kbd);
void removeProcess(DockProcess* dp);
private:
diff --git a/src/DockKeyboard.cpp b/src/DockKeyboard.cpp
new file mode 100644
index 0000000..2a7852d
--- /dev/null
+++ b/src/DockKeyboard.cpp
@@ -0,0 +1,35 @@
+
+#include "DockKeyboard.h"
+#include "logger.h"
+#include "Config.h"
+#include <cairo.h>
+#include <cairo-xlib.h>
+
+DockKeyboard::DockKeyboard(XConn* x11, KeyboardDevice* kbd)
+{
+ this->kbd = kbd;
+ this->x11 = x11;
+}
+
+void DockKeyboard::setup()
+{
+ cairo_surface_t* png =
+ cairo_image_surface_create_from_png(Config::getInstance()->kbdImage);
+ cairo_surface_t* button =
+ cairo_xlib_surface_create(x11->dpy, backbuff, x11->vis, width, height);
+ cairo_t* cr = cairo_create(button);
+ cairo_set_source_surface(cr, png, 0, 0);
+ cairo_paint(cr);
+ if (cairo_status(cr))
+ {
+ ERR("cairo: %s\n", cairo_status_to_string(cairo_status(cr)));
+ }
+ cairo_surface_destroy(button);
+ cairo_surface_destroy(png);
+ cairo_destroy(cr);
+ XFlush(x11->dpy);
+}
+
+void DockKeyboard::handleButtonEvent(XButtonEvent* ev)
+{
+}
diff --git a/src/DockKeyboard.h b/src/DockKeyboard.h
new file mode 100644
index 0000000..dbd4014
--- /dev/null
+++ b/src/DockKeyboard.h
@@ -0,0 +1,21 @@
+#ifndef __DOCKKEYBOARD_H__
+#define __DOCKKEYBOARD_H__
+
+#include <X11/Xlib.h>
+#include "XConn.h"
+#include "DockItem.h"
+#include "KeyboardDevice.h"
+
+class DockKeyboard : public DockItem
+{
+ private:
+ KeyboardDevice* kbd;
+
+ public:
+ DockKeyboard(XConn* x11, KeyboardDevice* kbd);
+ void handleButtonEvent(XButtonEvent* ev);
+ void setup();
+};
+
+
+#endif
diff --git a/src/KeyboardDevice.cpp b/src/KeyboardDevice.cpp
new file mode 100644
index 0000000..22248f8
--- /dev/null
+++ b/src/KeyboardDevice.cpp
@@ -0,0 +1,18 @@
+
+#include "KeyboardDevice.h"
+
+int KeyboardDevice::counter = 0;
+
+KeyboardDevice::KeyboardDevice(XDeviceInfo* dev, XConn* x11, Manager* manager)
+{
+ XDevice* d = XOpenDevice(x11->dpy, dev->id);
+
+ if (!d)
+ throw new DeviceError(DeviceError::OPEN_FAILED);
+ this->x11 = x11;
+ this->kbdID = KeyboardDevice::counter++;
+ this->name = string(dev->name);
+ this->id = dev->id;
+ this->dev = d;
+ TRACE("Keyboard %d (%s) initialised\n", kbdID, dev->name);
+}
diff --git a/src/KeyboardDevice.h b/src/KeyboardDevice.h
new file mode 100644
index 0000000..be51a43
--- /dev/null
+++ b/src/KeyboardDevice.h
@@ -0,0 +1,33 @@
+#ifndef __KEYBOARDDEVICE_H__
+#define __KEYBOARDDEVICE_H__
+
+#include<X11/Xlib.h>
+#include<X11/extensions/XInput.h>
+#include<string>
+#include "DeviceError.h"
+#include "logger.h"
+#include "XConn.h"
+
+using namespace std;
+
+class Manager;
+
+class KeyboardDevice
+{
+ public:
+ static int counter;
+
+ private:
+ int kbdID;
+ XConn* x11;
+ int id;
+ string name;
+ XDevice* dev;
+
+ public:
+ KeyboardDevice(XDeviceInfo* device, XConn* x11, Manager* manager);
+ int getID() { return id; }
+ string getName() { return name; }
+};
+
+#endif
diff --git a/src/Makefile b/src/Makefile
index 22469c8..d7ba760 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -10,6 +10,7 @@ OBJ= XConn.o\
Util.o \
Manager.o \
PointerDevice.o \
+ KeyboardDevice.o \
FloorControl.o \
Overlay.o \
WMWindow.o \
@@ -19,7 +20,8 @@ OBJ= XConn.o\
Dock.o \
DockItem.o \
DockApp.o \
- DockProcess.o
+ DockProcess.o \
+ DockKeyboard.o
FLAGS=-Wall -g3 -pipe
CFLAGS=$(FLAGS) $(INCLUDES)
LIB=$(LIBDIR) $(LIBS)
diff --git a/src/Manager.cpp b/src/Manager.cpp
index 59e55bc..4096e9a 100644
--- a/src/Manager.cpp
+++ b/src/Manager.cpp
@@ -133,6 +133,18 @@ void Manager::initXi()
{
ERR("%s\n", e->message.c_str());
}
+ }
+ if ((currDevice->use & IsXExtensionKeyboard))
+ {
+ try
+ {
+ KeyboardDevice *k = new KeyboardDevice(currDevice, x11, this);
+ keyboards.push_back(k);
+ dock->appendKeyboard(k);
+ } catch (DeviceError* e)
+ {
+ ERR("%s\n", e->message.c_str());
+ }
}
}
@@ -752,6 +764,18 @@ void Manager::handlePresenceNotify(XDevicePresenceNotifyEvent* ev)
}
}
+ if (current->use & IsXExtensionKeyboard)
+ {
+ try
+ {
+ KeyboardDevice *k = new KeyboardDevice(current, x11, this);
+ keyboards.push_back(k);
+ } catch (DeviceError* e)
+ {
+ ERR("%s\n", e->message.c_str());
+ }
+ }
+
}
}
diff --git a/src/Manager.h b/src/Manager.h
index 5f4f3d3..31cdd6e 100644
--- a/src/Manager.h
+++ b/src/Manager.h
@@ -18,6 +18,7 @@
#include "Config.h"
#include "WMWindow.h"
#include "PointerDevice.h"
+#include "KeyboardDevice.h"
#include "DeviceError.h"
#include "XError.h"
#include "Util.h"
@@ -41,6 +42,7 @@ class Manager
GC root_gc;
vector<WMWindow*> windows;
vector<PointerDevice*> pointers;
+ vector<KeyboardDevice*> keyboards;
bool stop;
Pixmap pxBackground;