summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk/gnome/50-compiz-desktop-key.xml.in10
-rw-r--r--gtk/window-decorator/gtk-window-decorator.c127
-rw-r--r--include/core/atoms.h4
-rw-r--r--include/core/privates.h6
-rw-r--r--include/core/rect.h1
-rw-r--r--include/core/region.h4
-rw-r--r--include/core/screen.h34
-rw-r--r--include/core/window.h4
-rw-r--r--include/scale/scale.h2
-rw-r--r--kde/window-decorator-kde4/decorator.cpp9
-rw-r--r--kde/window-decorator-kde4/utils.cpp6
-rw-r--r--kde/window-decorator-kde4/utils.h2
-rw-r--r--metadata/CMakeLists.txt2
-rw-r--r--metadata/commands.xml.in225
-rw-r--r--metadata/core.xml.in147
-rw-r--r--metadata/gnomecompat.xml.in52
-rw-r--r--metadata/place.xml.in82
-rw-r--r--plugins/CMakeLists.txt12
-rw-r--r--plugins/commands.cpp156
-rw-r--r--plugins/commands.h105
-rw-r--r--plugins/decor.cpp20
-rw-r--r--plugins/decor.h2
-rw-r--r--plugins/gnomecompat.cpp170
-rw-r--r--plugins/gnomecompat.h67
-rw-r--r--plugins/ini.cpp44
-rw-r--r--plugins/ini.h1
-rw-r--r--plugins/inotify.cpp2
-rw-r--r--plugins/opengl/texture.cpp2
-rw-r--r--plugins/place.cpp214
-rw-r--r--plugins/place.h32
-rw-r--r--plugins/regex.cpp622
-rw-r--r--plugins/regexplugin.h74
-rw-r--r--plugins/scale/privates.h2
-rw-r--r--plugins/scale/scale.cpp444
-rw-r--r--po/POTFILES.in2
-rw-r--r--src/action.cpp42
-rw-r--r--src/actions.cpp91
-rw-r--r--src/atoms.cpp11
-rw-r--r--src/event.cpp16
-rw-r--r--src/main.cpp44
-rw-r--r--src/match.cpp62
-rw-r--r--src/option.cpp49
-rw-r--r--src/plugin.cpp79
-rw-r--r--src/privates.cpp39
-rw-r--r--src/privatescreen.h102
-rw-r--r--src/privatewindow.h18
-rw-r--r--src/rect.cpp15
-rw-r--r--src/region.cpp12
-rw-r--r--src/screen.cpp309
-rw-r--r--src/window.cpp672
-rw-r--r--src/windowgeometry.cpp21
51 files changed, 2449 insertions, 1821 deletions
diff --git a/gtk/gnome/50-compiz-desktop-key.xml.in b/gtk/gnome/50-compiz-desktop-key.xml.in
index 1559d03..083d5e1 100644
--- a/gtk/gnome/50-compiz-desktop-key.xml.in
+++ b/gtk/gnome/50-compiz-desktop-key.xml.in
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<KeyListEntries _name="Desktop" wm_name="compiz" package="compiz">
- <KeyListEntry name="/apps/compiz/general/allscreens/options/run_key"/>
+ <KeyListEntry name="/apps/compiz/plugins/gnomecompat/options/run_key"/>
- <KeyListEntry name="/apps/compiz/general/allscreens/options/main_menu_key"/>
+ <KeyListEntry name="/apps/compiz/plugins/gnomecompat/options/main_menu_key"/>
- <KeyListEntry name="/apps/compiz/general/allscreens/options/run_command_screenshot_key"/>
+ <KeyListEntry name="/apps/compiz/plugins/gnomecompat/allscreens/options/run_command_screenshot_key"/>
- <KeyListEntry name="/apps/compiz/general/allscreens/options/run_command_window_screenshot_key"/>
+ <KeyListEntry name="/apps/compiz/plugins/gnomecompat/allscreens/options/run_command_window_screenshot_key"/>
<KeyListEntry name="/apps/compiz/general/allscreens/options/show_desktop_key"/>
- <KeyListEntry name="/apps/compiz/general/allscreens/options/run_command_terminal_key"/>
+ <KeyListEntry name="/apps/compiz/plugins/gnomecompat/allscreens/options/run_command_terminal_key"/>
</KeyListEntries>
diff --git a/gtk/window-decorator/gtk-window-decorator.c b/gtk/window-decorator/gtk-window-decorator.c
index 91f676c..b34c06e 100644
--- a/gtk/window-decorator/gtk-window-decorator.c
+++ b/gtk/window-decorator/gtk-window-decorator.c
@@ -311,6 +311,7 @@ static Atom wm_move_resize_atom;
static Atom restack_window_atom;
static Atom select_window_atom;
static Atom mwm_hints_atom;
+static Atom switcher_fg_atom;
static Atom toolkit_action_atom;
static Atom toolkit_action_main_menu_atom;
@@ -318,10 +319,6 @@ static Atom toolkit_action_run_dialog_atom;
static Atom toolkit_action_window_menu_atom;
static Atom toolkit_action_force_quit_dialog_atom;
-static Atom panel_action_atom;
-static Atom panel_action_main_menu_atom;
-static Atom panel_action_run_dialog_atom;
-
static Time dm_sn_timestamp;
#define C(name) { 0, XC_ ## name }
@@ -628,36 +625,6 @@ decor_update_window_property (decor_t *d)
}
static void
-decor_update_switcher_property (decor_t *d)
-{
- long data[256];
- Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
- gint nQuad;
- decor_quad_t quads[N_QUADS_MAX];
-
- nQuad = decor_set_lSrStSbX_window_quads (quads, &switcher_context,
- &d->border_layout,
- d->border_layout.top.x2 -
- d->border_layout.top.x1 -
- switcher_context.extents.left -
- switcher_context.extents.right -
- 32);
-
- decor_quads_to_property (data, GDK_PIXMAP_XID (d->pixmap),
- &_switcher_extents, &_switcher_extents,
- 0, 0, quads, nQuad);
-
- gdk_error_trap_push ();
- XChangeProperty (xdisplay, d->prop_xid,
- win_decor_atom,
- XA_INTEGER,
- 32, PropModeReplace, (guchar *) data,
- BASE_PROP_SIZE + QUAD_PROP_SIZE * nQuad);
- gdk_display_sync (gdk_display_get_default ());
- gdk_error_trap_pop ();
-}
-
-static void
gdk_cairo_set_source_color_alpha (cairo_t *cr,
GdkColor *color,
double alpha)
@@ -2182,6 +2149,47 @@ meta_draw_window_decoration (decor_t *d)
#define SWITCHER_ALPHA 0xa0a0
static void
+decor_update_switcher_property (decor_t *d)
+{
+ long data[256];
+ Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+ gint nQuad;
+ decor_quad_t quads[N_QUADS_MAX];
+ GtkStyle *style;
+ long fgColor[4];
+
+ nQuad = decor_set_lSrStSbX_window_quads (quads, &switcher_context,
+ &d->border_layout,
+ d->border_layout.top.x2 -
+ d->border_layout.top.x1 -
+ switcher_context.extents.left -
+ switcher_context.extents.right -
+ 32);
+
+ decor_quads_to_property (data, GDK_PIXMAP_XID (d->pixmap),
+ &_switcher_extents, &_switcher_extents,
+ 0, 0, quads, nQuad);
+
+ style = gtk_widget_get_style (style_window);
+
+ fgColor[0] = style->fg[GTK_STATE_NORMAL].red;
+ fgColor[1] = style->fg[GTK_STATE_NORMAL].green;
+ fgColor[2] = style->fg[GTK_STATE_NORMAL].blue;
+ fgColor[3] = SWITCHER_ALPHA;
+
+ gdk_error_trap_push ();
+ XChangeProperty (xdisplay, d->prop_xid,
+ win_decor_atom,
+ XA_INTEGER,
+ 32, PropModeReplace, (guchar *) data,
+ BASE_PROP_SIZE + QUAD_PROP_SIZE * nQuad);
+ XChangeProperty (xdisplay, d->prop_xid, switcher_fg_atom,
+ XA_INTEGER, 32, PropModeReplace, (guchar *) fgColor, 4);
+ gdk_display_sync (gdk_display_get_default ());
+ gdk_error_trap_pop ();
+}
+
+static void
draw_switcher_background (decor_t *d)
{
Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
@@ -2379,6 +2387,7 @@ draw_switcher_background (decor_t *d)
gdk_error_trap_push ();
XSetWindowBackground (xdisplay, d->prop_xid, pixel);
XClearWindow (xdisplay, d->prop_xid);
+
gdk_display_sync (gdk_display_get_default ());
gdk_error_trap_pop ();
@@ -4931,27 +4940,6 @@ bottom_right_event (WnckWindow *win,
}
static void
-panel_action (Display *xdisplay,
- Window root,
- Atom panel_action,
- Time event_time)
-{
- XEvent ev;
-
- ev.type = ClientMessage;
- ev.xclient.window = root;
- ev.xclient.message_type = panel_action_atom;
- ev.xclient.format = 32;
- ev.xclient.data.l[0] = panel_action;
- ev.xclient.data.l[1] = event_time;
- ev.xclient.data.l[2] = 0;
- ev.xclient.data.l[3] = 0;
- ev.xclient.data.l[4] = 0;
-
- XSendEvent (xdisplay, root, FALSE, StructureNotifyMask, &ev);
-}
-
-static void
force_quit_dialog_realize (GtkWidget *dialog,
void *data)
{
@@ -5240,19 +5228,7 @@ event_filter_func (GdkXEvent *gdkxevent,
long action;
action = xevent->xclient.data.l[0];
- if (action == toolkit_action_main_menu_atom)
- {
- panel_action (xdisplay, xevent->xclient.window,
- panel_action_main_menu_atom,
- xevent->xclient.data.l[1]);
- }
- else if (action == toolkit_action_run_dialog_atom)
- {
- panel_action (xdisplay, xevent->xclient.window,
- panel_action_run_dialog_atom,
- xevent->xclient.data.l[1]);
- }
- else if (action == toolkit_action_window_menu_atom)
+ if (action == toolkit_action_window_menu_atom)
{
WnckWindow *win;
@@ -6985,26 +6961,18 @@ main (int argc, char *argv[])
select_window_atom = XInternAtom (xdisplay, DECOR_SWITCH_WINDOW_ATOM_NAME,
FALSE);
mwm_hints_atom = XInternAtom (xdisplay, "_MOTIF_WM_HINTS", FALSE);
+ switcher_fg_atom = XInternAtom (xdisplay,
+ DECOR_SWITCH_FOREGROUND_COLOR_ATOM_NAME,
+ FALSE);
toolkit_action_atom =
XInternAtom (xdisplay, "_COMPIZ_TOOLKIT_ACTION", FALSE);
- toolkit_action_main_menu_atom =
- XInternAtom (xdisplay, "_COMPIZ_TOOLKIT_ACTION_MAIN_MENU", FALSE);
- toolkit_action_run_dialog_atom =
- XInternAtom (xdisplay, "_COMPIZ_TOOLKIT_ACTION_RUN_DIALOG", FALSE);
toolkit_action_window_menu_atom =
XInternAtom (xdisplay, "_COMPIZ_TOOLKIT_ACTION_WINDOW_MENU", FALSE);
toolkit_action_force_quit_dialog_atom =
XInternAtom (xdisplay, "_COMPIZ_TOOLKIT_ACTION_FORCE_QUIT_DIALOG",
FALSE);
- panel_action_atom =
- XInternAtom (xdisplay, "_GNOME_PANEL_ACTION", FALSE);
- panel_action_main_menu_atom =
- XInternAtom (xdisplay, "_GNOME_PANEL_ACTION_MAIN_MENU", FALSE);
- panel_action_run_dialog_atom =
- XInternAtom (xdisplay, "_GNOME_PANEL_ACTION_RUN_DIALOG", FALSE);
-
status = decor_acquire_dm_session (xdisplay,
gdk_screen_get_number (gdkscreen),
"gwd", replace, &dm_sn_timestamp);
@@ -7053,6 +7021,7 @@ main (int argc, char *argv[])
}
screen = wnck_screen_get_default ();
+ wnck_set_client_type (WNCK_CLIENT_TYPE_PAGER);
gdk_window_add_filter (NULL,
selection_event_filter_func,
diff --git a/include/core/atoms.h b/include/core/atoms.h
index ba36113..6cd0b50 100644
--- a/include/core/atoms.h
+++ b/include/core/atoms.h
@@ -123,6 +123,8 @@ namespace Atoms {
extern Atom wmSyncRequestCounter;
+ extern Atom wmFullscreenMonitors;
+
extern Atom closeWindow;
extern Atom wmMoveResize;
extern Atom moveResizeWindow;
@@ -133,8 +135,6 @@ namespace Atoms {
extern Atom xBackground[2];
extern Atom toolkitAction;
- extern Atom toolkitActionMainMenu;
- extern Atom toolkitActionRunDialog;
extern Atom toolkitActionWindowMenu;
extern Atom toolkitActionForceQuitDialog;
diff --git a/include/core/privates.h b/include/core/privates.h
index e369d0e..bd64798 100644
--- a/include/core/privates.h
+++ b/include/core/privates.h
@@ -43,14 +43,14 @@ class CompPrivateStorage {
typedef std::vector<bool> Indices;
public:
- CompPrivateStorage (Indices *iList);
+ CompPrivateStorage (Indices& iList);
public:
std::vector<CompPrivate> privates;
protected:
- static int allocatePrivateIndex (Indices *iList);
- static void freePrivateIndex (Indices *iList, int idx);
+ static int allocatePrivateIndex (Indices& iList);
+ static void freePrivateIndex (Indices& iList, int idx);
};
#endif
diff --git a/include/core/rect.h b/include/core/rect.h
index 39e3d78..ab8de7f 100644
--- a/include/core/rect.h
+++ b/include/core/rect.h
@@ -48,6 +48,7 @@ class CompRect {
void setGeometry (int, int, int, int);
+ bool contains (const CompPoint &) const;
bool operator== (const CompRect &) const;
bool operator!= (const CompRect &) const;
diff --git a/include/core/region.h b/include/core/region.h
index d8baf8a..fe6df71 100644
--- a/include/core/region.h
+++ b/include/core/region.h
@@ -57,7 +57,7 @@ class CompRegion {
bool contains (const CompPoint &) const;
bool contains (const CompRect &) const;
-
+
CompRegion intersected (const CompRegion &) const;
CompRegion intersected (const CompRect &) const;
bool intersects (const CompRegion &) const;
@@ -104,4 +104,4 @@ class CompRegion {
extern const CompRegion infiniteRegion;
extern const CompRegion emptyRegion;
-#endif \ No newline at end of file
+#endif
diff --git a/include/core/screen.h b/include/core/screen.h
index c30da1f..00ab409 100644
--- a/include/core/screen.h
+++ b/include/core/screen.h
@@ -45,6 +45,7 @@ extern char *backgroundImage;
extern bool replaceCurrentWm;
extern bool indirectRendering;
extern bool noDetection;
+extern bool debugOutput;
extern CompScreen *screen;
extern CompMetadata *coreMetadata;
@@ -66,7 +67,7 @@ typedef int CompFileWatchHandle;
typedef int CompWatchFdHandle;
struct CompFileWatch {
- char *path;
+ CompString path;
int mask;
FileWatchCallBack callBack;
CompFileWatchHandle handle;
@@ -107,7 +108,7 @@ class ScreenInterface : public WrapableInterface<CompScreen, ScreenInterface> {
virtual bool imageToFile (CompString &path, CompString &format,
CompSize &size, int stride, void *data);
- virtual CompMatch::Expression *matchInitExp (const CompString value);
+ virtual CompMatch::Expression *matchInitExp (const CompString& value);
virtual void matchExpHandlerChanged ();
virtual void matchPropertyChanged (CompWindow *window);
@@ -282,8 +283,7 @@ class CompScreen :
void viewportForGeometry (CompWindow::Geometry gm,
- int *viewportX,
- int *viewportY);
+ CompPoint &viewport);
int outputDeviceForGeometry (CompWindow::Geometry gm);
@@ -343,7 +343,7 @@ class CompScreen :
CompString &, CompSize &, int, void *);
WRAPABLE_HND (10, ScreenInterface, CompMatch::Expression *,
- matchInitExp, const CompString);
+ matchInitExp, const CompString&);
WRAPABLE_HND (11, ScreenInterface, void, matchExpHandlerChanged)
WRAPABLE_HND (12, ScreenInterface, void, matchPropertyChanged,
CompWindow *)
@@ -365,30 +365,6 @@ class CompScreen :
public :
- static bool runCommandDispatch (CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
- static bool runCommandScreenshot(CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
- static bool runCommandWindowScreenshot(CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
- static bool runCommandTerminal (CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
- static bool mainMenu (CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
- static bool runDialog (CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
static bool showDesktop (CompAction *action,
CompAction::State state,
CompOption::Vector &options);
diff --git a/include/core/window.h b/include/core/window.h
index 3a62f58..a896d56 100644
--- a/include/core/window.h
+++ b/include/core/window.h
@@ -192,7 +192,7 @@ struct CompStruts {
class WindowInterface : public WrapableInterface<CompWindow, WindowInterface> {
public:
- virtual void getOutputExtents (CompWindowExtents *output);
+ virtual void getOutputExtents (CompWindowExtents& output);
virtual void getAllowedActions (unsigned int &setActions,
unsigned int &clearActions);
@@ -456,7 +456,7 @@ class CompWindow :
static void freePrivateIndex (int index);
WRAPABLE_HND (0, WindowInterface, void, getOutputExtents,
- CompWindowExtents *);
+ CompWindowExtents&);
WRAPABLE_HND (1, WindowInterface, void, getAllowedActions,
unsigned int &, unsigned int &);
diff --git a/include/scale/scale.h b/include/scale/scale.h
index 12ed213..c81b07d 100644
--- a/include/scale/scale.h
+++ b/include/scale/scale.h
@@ -32,7 +32,7 @@
#include <composite/composite.h>
#include <opengl/opengl.h>
-#define COMPIZ_SCALE_ABI 0
+#define COMPIZ_SCALE_ABI 1
class ScaleScreen;
class PrivateScaleScreen;
diff --git a/kde/window-decorator-kde4/decorator.cpp b/kde/window-decorator-kde4/decorator.cpp
index 70f5d8a..f2a5bb1 100644
--- a/kde/window-decorator-kde4/decorator.cpp
+++ b/kde/window-decorator-kde4/decorator.cpp
@@ -648,15 +648,6 @@ KWD::Decorator::x11EventFilter (XEvent *xevent)
client->showWindowMenu (pos);
}
}
- else if (action == Atoms::toolkitActionMainMenuAtom)
- {
- }
- else if (action == Atoms::toolkitActionRunDialogAtom)
- {
- QDBusInterface krunner ("org.kde.krunner", "/App",
- "org.kde.krunner.App");
- krunner.call ("display");
- }
else if (action == Atoms::toolkitActionForceQuitDialogAtom)
{
if (mClients.contains (xevent->xclient.window))
diff --git a/kde/window-decorator-kde4/utils.cpp b/kde/window-decorator-kde4/utils.cpp
index 396c08d..a9ef8e4 100644
--- a/kde/window-decorator-kde4/utils.cpp
+++ b/kde/window-decorator-kde4/utils.cpp
@@ -50,8 +50,6 @@ namespace KWD
Atom wmProtocols;
Atom toolkitActionAtom;
Atom toolkitActionWindowMenuAtom;
- Atom toolkitActionMainMenuAtom;
- Atom toolkitActionRunDialogAtom;
Atom toolkitActionForceQuitDialogAtom;
Atom compizWindowBlurDecor;
}
@@ -205,10 +203,6 @@ KWD::Atoms::init (void)
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/kde/window-decorator-kde4/utils.h b/kde/window-decorator-kde4/utils.h
index e43bb6f..eb0e2af 100644
--- a/kde/window-decorator-kde4/utils.h
+++ b/kde/window-decorator-kde4/utils.h
@@ -46,8 +46,6 @@ namespace KWD
extern Atom wmProtocols;
extern Atom toolkitActionAtom;
extern Atom toolkitActionWindowMenuAtom;
- extern Atom toolkitActionMainMenuAtom;
- extern Atom toolkitActionRunDialogAtom;
extern Atom toolkitActionForceQuitDialogAtom;
extern Atom compizWindowBlurDecor;
diff --git a/metadata/CMakeLists.txt b/metadata/CMakeLists.txt
index af64e38..d4c435e 100644
--- a/metadata/CMakeLists.txt
+++ b/metadata/CMakeLists.txt
@@ -3,6 +3,7 @@ set (_plugin_files
annotate
blur
clone
+ commands
cube
dbus
decor
@@ -10,6 +11,7 @@ set (_plugin_files
fs
gconf
glib
+ gnomecompat
imgpng
imgsvg
ini
diff --git a/metadata/commands.xml.in b/metadata/commands.xml.in
new file mode 100644
index 0000000..ca5f74c
--- /dev/null
+++ b/metadata/commands.xml.in
@@ -0,0 +1,225 @@
+<compiz>
+ <plugin name="commands">
+ <_short>Commands</_short>
+ <_long>Assigns bindings to arbitrary commands</_long>
+ <category>General</category>
+ <display>
+ <group>
+ <_short>Commands</_short>
+ <option name="command0" type="string">
+ <_short>Command line 0</_short>
+ <_long>Command line to be executed in shell when run_command0 is invoked</_long>
+ <default></default>
+ </option>
+ <option name="command1" type="string">
+ <_short>Command line 1</_short>
+ <_long>Command line to be executed in shell when run_command1 is invoked</_long>
+ <default></default>
+ </option>
+ <option name="command2" type="string">
+ <_short>Command line 2</_short>
+ <_long>Command line to be executed in shell when run_command2 is invoked</_long>
+ <default></default>
+ </option>
+ <option name="command3" type="string">
+ <_short>Command line 3</_short>
+ <_long>Command line to be executed in shell when run_command3 is invoked</_long>
+ <default></default>
+ </option>
+ <option name="command4" type="string">
+ <_short>Command line 4</_short>
+ <_long>Command line to be executed in shell when run_command4 is invoked</_long>
+ <default></default>
+ </option>
+ <option name="command5" type="string">
+ <_short>Command line 5</_short>
+ <_long>Command line to be executed in shell when run_command5 is invoked</_long>
+ <default></default>
+ </option>
+ <option name="command6" type="string">
+ <_short>Command line 6</_short>
+ <_long>Command line to be executed in shell when run_command6 is invoked</_long>
+ <default></default>
+ </option>
+ <option name="command7" type="string">
+ <_short>Command line 7</_short>
+ <_long>Command line to be executed in shell when run_command7 is invoked</_long>
+ <default></default>
+ </option>
+ <option name="command8" type="string">
+ <_short>Command line 8</_short>
+ <_long>Command line to be executed in shell when run_command8 is invoked</_long>
+ <default></default>
+ </option>
+ <option name="command9" type="string">
+ <_short>Command line 9</_short>
+ <_long>Command line to be executed in shell when run_command9 is invoked</_long>
+ <default></default>
+ </option>
+ <option name="command10" type="string">
+ <_short>Command line 10</_short>
+ <_long>Command line to be executed in shell when run_command10 is invoked</_long>
+ <default></default>
+ </option>
+ <option name="command11" type="string">
+ <_short>Command line 11</_short>
+ <_long>Command line to be executed in shell when run_command11 is invoked</_long>
+ <default></default>
+ </option>
+ </group>
+ <group>
+ <_short>Key Bindings</_short>
+ <option name="run_command0_key" type="key">
+ <_short>Run command 0</_short>
+ <_long>A keybinding that when invoked, will run the shell command identified by command0</_long>
+ </option>
+ <option name="run_command1_key" type="key">
+ <_short>Run command 1</_short>
+ <_long>A keybinding that when invoked, will run the shell command identified by command1</_long>
+ </option>
+ <option name="run_command2_key" type="key">
+ <_short>Run command 2</_short>
+ <_long>A keybinding that when invoked, will run the shell command identified by command2</_long>
+ </option>
+ <option name="run_command3_key" type="key">
+ <_short>Run command 3</_short>
+ <_long>A keybinding that when invoked, will run the shell command identified by command3</_long>
+ </option>
+ <option name="run_command4_key" type="key">
+ <_short>Run command 4</_short>
+ <_long>A keybinding that when invoked, will run the shell command identified by command4</_long>
+ </option>
+ <option name="run_command5_key" type="key">
+ <_short>Run command 5</_short>
+ <_long>A keybinding that when invoked, will run the shell command identified by command5</_long>
+ </option>
+ <option name="run_command6_key" type="key">
+ <_short>Run command 6</_short>
+ <_long>A keybinding that when invoked, will run the shell command identified by command6</_long>
+ </option>
+ <option name="run_command7_key" type="key">
+ <_short>Run command 7</_short>
+ <_long>A keybinding that when invoked, will run the shell command identified by command7</_long>
+ </option>
+ <option name="run_command8_key" type="key">
+ <_short>Run command 8</_short>
+ <_long>A keybinding that when invoked, will run the shell command identified by command8</_long>
+ </option>
+ <option name="run_command9_key" type="key">
+ <_short>Run command 9</_short>
+ <_long>A keybinding that when invoked, will run the shell command identified by command9</_long>
+ </option>
+ <option name="run_command10_key" type="key">
+ <_short>Run command 10</_short>
+ <_long>A keybinding that when invoked, will run the shell command identified by command10</_long>
+ </option>
+ <option name="run_command11_key" type="key">
+ <_short>Run command 11</_short>
+ <_long>A keybinding that when invoked, will run the shell command identified by command11</_long>
+ </option>
+ </group>
+ <group>
+ <_short>Button Bindings</_short>
+ <option name="run_command0_button" type="button">
+ <_short>Run command 0</_short>
+ <_long>A button binding that when invoked, will run the shell command identified by command0</_long>
+ </option>
+ <option name="run_command1_button" type="button">
+ <_short>Run command 1</_short>
+ <_long>A button binding that when invoked, will run the shell command identified by command1</_long>
+ </option>
+ <option name="run_command2_button" type="button">
+ <_short>Run command 2</_short>
+ <_long>A button binding that when invoked, will run the shell command identified by command2</_long>
+ </option>
+ <option name="run_command3_button" type="button">
+ <_short>Run command 3</_short>
+ <_long>A button binding that when invoked, will run the shell command identified by command3</_long>
+ </option>
+ <option name="run_command4_button" type="button">
+ <_short>Run command 4</_short>
+ <_long>A button binding that when invoked, will run the shell command identified by command4</_long>
+ </option>
+ <option name="run_command5_button" type="button">
+ <_short>Run command 5</_short>
+ <_long>A button binding that when invoked, will run the shell command identified by command5</_long>
+ </option>
+ <option name="run_command6_button" type="button">
+ <_short>Run command 6</_short>
+ <_long>A button binding that when invoked, will run the shell command identified by command6</_long>
+ </option>
+ <option name="run_command7_button" type="button">
+ <_short>Run command 7</_short>
+ <_long>A button binding that when invoked, will run the shell command identified by command7</_long>
+ </option>
+ <option name="run_command8_button" type="button">
+ <_short>Run command 8</_short>
+ <_long>A button binding that when invoked, will run the shell command identified by command8</_long>
+ </option>
+ <option name="run_command9_button" type="button">
+ <_short>Run command 9</_short>
+ <_long>A button binding that when invoked, will run the shell command identified by command9</_long>
+ </option>
+ <option name="run_command10_button" type="button">
+ <_short>Run command 10</_short>
+ <_long>A button binding that when invoked, will run the shell command identified by command10</_long>
+ </option>
+ <option name="run_command11_button" type="button">
+ <_short>Run command 11</_short>
+ <_long>A button binding that when invoked, will run the shell command identified by command11</_long>
+ </option>
+ </group>
+ <group>
+ <_short>Edge Bindings</_short>
+ <option name="run_command0_edge" type="edge">
+ <_short>Run command 0</_short>
+ <_long>An edge binding that when invoked, will run the shell command identified by command0</_long>
+ </option>
+ <option name="run_command1_edge" type="edge">
+ <_short>Run command 1</_short>
+ <_long>An edge binding that when invoked, will run the shell command identified by command1</_long>
+ </option>
+ <option name="run_command2_edge" type="edge">
+ <_short>Run command 2</_short>
+ <_long>An edge binding that when invoked, will run the shell command identified by command2</_long>
+ </option>
+ <option name="run_command3_edge" type="edge">
+ <_short>Run command 3</_short>
+ <_long>An edge binding that when invoked, will run the shell command identified by command3</_long>
+ </option>
+ <option name="run_command4_edge" type="edge">
+ <_short>Run command 4</_short>
+ <_long>An edge binding that when invoked, will run the shell command identified by command4</_long>
+ </option>
+ <option name="run_command5_edge" type="edge">
+ <_short>Run command 5</_short>
+ <_long>An edge binding that when invoked, will run the shell command identified by command5</_long>
+ </option>
+ <option name="run_command6_edge" type="edge">
+ <_short>Run command 6</_short>
+ <_long>An edge binding that when invoked, will run the shell command identified by command6</_long>
+ </option>
+ <option name="run_command7_edge" type="edge">
+ <_short>Run command 7</_short>
+ <_long>An edge binding that when invoked, will run the shell command identified by command7</_long>
+ </option>
+ <option name="run_command8_edge" type="edge">
+ <_short>Run command 8</_short>
+ <_long>An edge binding that when invoked, will run the shell command identified by command8</_long>
+ </option>
+ <option name="run_command9_edge" type="edge">
+ <_short>Run command 9</_short>
+ <_long>An edge binding that when invoked, will run the shell command identified by command9</_long>
+ </option>
+ <option name="run_command10_edge" type="edge">
+ <_short>Run command 10</_short>
+ <_long>An edge binding that when invoked, will run the shell command identified by command10</_long>
+ </option>
+ <option name="run_command11_edge" type="edge">
+ <_short>Run command 11</_short>
+ <_long>An edge binding that when invoked, will run the shell command identified by command11</_long>
+ </option>
+ </group>
+ </display>
+ </plugin>
+</compiz>
diff --git a/metadata/core.xml.in b/metadata/core.xml.in
index 5e1bdaa..83b5f6b 100644
--- a/metadata/core.xml.in
+++ b/metadata/core.xml.in
@@ -44,124 +44,6 @@
<_short>Close Window</_short>
<_long>Close active window</_long>
</option>
- <option name="main_menu_key" type="key">
- <_short>Show Main Menu</_short>
- <_long>Show the main menu</_long>
- <default>&lt;Alt&gt;F1</default>
- </option>
- <option name="run_key" type="key">
- <_short>Run Dialog</_short>
- <_long>Show Run Application dialog</_long>
- <default>&lt;Alt&gt;F2</default>
- </option>
- <option name="command0" type="string">
- <_short>Command line 0</_short>
- <_long>Command line to be executed in shell when run_command0 is invoked</_long>
- <default></default>
- </option>
- <option name="command1" type="string">
- <_short>Command line 1</_short>
- <_long>Command line to be executed in shell when run_command1 is invoked</_long>
- <default></default>
- </option>
- <option name="command2" type="string">
- <_short>Command line 2</_short>
- <_long>Command line to be executed in shell when run_command2 is invoked</_long>
- <default></default>
- </option>
- <option name="command3" type="string">
- <_short>Command line 3</_short>
- <_long>Command line to be executed in shell when run_command3 is invoked</_long>
- <default></default>
- </option>
- <option name="command4" type="string">
- <_short>Command line 4</_short>
- <_long>Command line to be executed in shell when run_command4 is invoked</_long>
- <default></default>
- </option>
- <option name="command5" type="string">
- <_short>Command line 5</_short>
- <_long>Command line to be executed in shell when run_command5 is invoked</_long>
- <default></default>
- </option>
- <option name="command6" type="string">
- <_short>Command line 6</_short>
- <_long>Command line to be executed in shell when run_command6 is invoked</_long>
- <default></default>
- </option>
- <option name="command7" type="string">
- <_short>Command line 7</_short>
- <_long>Command line to be executed in shell when run_command7 is invoked</_long>
- <default></default>
- </option>
- <option name="command8" type="string">
- <_short>Command line 8</_short>
- <_long>Command line to be executed in shell when run_command8 is invoked</_long>
- <default></default>
- </option>
- <option name="command9" type="string">
- <_short>Command line 9</_short>
- <_long>Command line to be executed in shell when run_command9 is invoked</_long>
- <default></default>
- </option>
- <option name="command10" type="string">
- <_short>Command line 10</_short>
- <_long>Command line to be executed in shell when run_command10 is invoked</_long>
- <default></default>
- </option>
- <option name="command11" type="string">
- <_short>Command line 11</_short>
- <_long>Command line to be executed in shell when run_command11 is invoked</_long>
- <default></default>
- </option>
- <option name="run_command0_key" type="key">
- <_short>Run command 0</_short>
- <_long>A keybinding that when invoked, will run the shell command identified by command0</_long>
- </option>
- <option name="run_command1_key" type="key">
- <_short>Run command 1</_short>
- <_long>A keybinding that when invoked, will run the shell command identified by command1</_long>
- </option>
- <option name="run_command2_key" type="key">
- <_short>Run command 2</_short>
- <_long>A keybinding that when invoked, will run the shell command identified by command2</_long>
- </option>
- <option name="run_command3_key" type="key">
- <_short>Run command 3</_short>
- <_long>A keybinding that when invoked, will run the shell command identified by command3</_long>
- </option>
- <option name="run_command4_key" type="key">
- <_short>Run command 4</_short>
- <_long>A keybinding that when invoked, will run the shell command identified by command4</_long>
- </option>
- <option name="run_command5_key" type="key">
- <_short>Run command 5</_short>
- <_long>A keybinding that when invoked, will run the shell command identified by command5</_long>
- </option>
- <option name="run_command6_key" type="key">
- <_short>Run command 6</_short>
- <_long>A keybinding that when invoked, will run the shell command identified by command6</_long>
- </option>
- <option name="run_command7_key" type="key">
- <_short>Run command 7</_short>
- <_long>A keybinding that when invoked, will run the shell command identified by command7</_long>
- </option>
- <option name="run_command8_key" type="key">
- <_short>Run command 8</_short>
- <_long>A keybinding that when invoked, will run the shell command identified by command8</_long>
- </option>
- <option name="run_command9_key" type="key">
- <_short>Run command 9</_short>
- <_long>A keybinding that when invoked, will run the shell command identified by command9</_long>
- </option>
- <option name="run_command10_key" type="key">
- <_short>Run command 10</_short>
- <_long>A keybinding that when invoked, will run the shell command identified by command10</_long>
- </option>
- <option name="run_command11_key" type="key">
- <_short>Run command 11</_short>
- <_long>A keybinding that when invoked, will run the shell command identified by command11</_long>
- </option>
<option name="raise_window_key" type="key">
<_short>Raise Window</_short>
<_long>Raise window above other windows</_long>
@@ -207,26 +89,6 @@
<_short>Maximize Window Vertically</_short>
<_long>Maximize active window vertically</_long>
</option>
- <option name="command_screenshot" type="string">
- <_short>Screenshot command line</_short>
- <_long>Screenshot command line</_long>
- <default>gnome-screenshot</default>
- </option>
- <option name="run_command_screenshot_key" type="key">
- <_short>Take a screenshot</_short>
- <_long>Take a screenshot</_long>
- <default>Print</default>
- </option>
- <option name="command_window_screenshot" type="string">
- <_short>Window screenshot command line</_short>
- <_long>Window screenshot command line</_long>
- <default>gnome-screenshot --window</default>
- </option>
- <option name="run_command_window_screenshot_key" type="key">
- <_short>Take a screenshot of a window</_short>
- <_long>Take a screenshot of a window</_long>
- <default>&lt;Alt&gt;Print</default>
- </option>
<option name="window_menu_button" type="button">
<_short>Window Menu</_short>
<_long>Window menu button binding</_long>
@@ -288,15 +150,6 @@
<_long>Ignore size increment and aspect hints when window is maximized</_long>
<default>true</default>
</option>
- <option name="command_terminal" type="string">
- <_short>Terminal command line</_short>
- <_long>Terminal command line</_long>
- <default></default>
- </option>
- <option name="run_command_terminal_key" type="key">
- <_short>Open a terminal</_short>
- <_long>Open a terminal</_long>
- </option>
<option name="ping_delay" type="int">
<_short>Ping Delay</_short>
<_long>Interval between ping messages</_long>
diff --git a/metadata/gnomecompat.xml.in b/metadata/gnomecompat.xml.in
new file mode 100644
index 0000000..b40ae4a
--- /dev/null
+++ b/metadata/gnomecompat.xml.in
@@ -0,0 +1,52 @@
+<compiz>
+ <plugin name="gnomecompat">
+ <_short>Gnome Compatibility</_short>
+ <_long>Options that keep Compiz compatible to the Gnome desktop environment</_long>
+ <category>General</category>
+ <display>
+ <option name="main_menu_key" type="key">
+ <_short>Show Main Menu</_short>
+ <_long>Show the main menu</_long>
+ <default>&lt;Alt&gt;F1</default>
+ </option>
+ <option name="run_key" type="key">
+ <_short>Run Dialog</_short>
+ <_long>Show Run Application dialog</_long>
+ <default>&lt;Alt&gt;F2</default>
+ </option>
+ <group>
+ <_short>Commands</_short>
+ <option name="command_screenshot" type="string">
+ <_short>Screenshot command line</_short>
+ <_long>Screenshot command line</_long>
+ <default>gnome-screenshot</default>
+ </option>
+ <option name="run_command_screenshot_key" type="key">
+ <_short>Take a screenshot</_short>
+ <_long>Take a screenshot</_long>
+ <default>Print</default>
+ </option>
+ <option name="command_window_screenshot" type="string">
+ <_short>Window screenshot command line</_short>
+ <_long>Window screenshot command line</_long>
+ <default>gnome-screenshot --window</default>
+ </option>
+ <option name="run_command_window_screenshot_key" type="key">
+ <_short>Take a screenshot of a window</_short>
+ <_long>Take a screenshot of a window</_long>
+ <default>&lt;Alt&gt;Print</default>
+ </option>
+ <_short>Run terminal command</_short>
+ <option name="command_terminal" type="string">
+ <_short>Terminal command line</_short>
+ <_long>Terminal command line</_long>
+ <default></default>
+ </option>
+ <option name="run_command_terminal_key" type="key">
+ <_short>Open a terminal</_short>
+ <_long>Open a terminal</_long>
+ </option>
+ </group>
+ </display>
+ </plugin>
+</compiz>
diff --git a/metadata/place.xml.in b/metadata/place.xml.in
index bad213d..addd9c6 100644
--- a/metadata/place.xml.in
+++ b/metadata/place.xml.in
@@ -63,40 +63,54 @@
<_long>Windows that should forcedly be placed, even if they indicate the window manager should avoid placing them.</_long>
<default></default>
</option>
- <option name="position_matches" type="list">
- <_short>Positioned windows</_short>
- <_long>Windows that should be positioned by default</_long>
- <type>match</type>
- </option>
- <option name="position_x_values" type="list">
- <_short>X Positions</_short>
- <_long>X position values</_long>
- <type>int</type>
- </option>
- <option name="position_y_values" type="list">
- <_short>Y Positions</_short>
- <_long>Y position values</_long>
- <type>int</type>
- </option>
- <option name="viewport_matches" type="list">
- <_short>Viewport positioned windows</_short>
- <_long>Windows that should be positioned in specific viewports by default</_long>
- <type>match</type>
- </option>
- <option name="viewport_x_values" type="list">
- <_short>X Viewport Positions</_short>
- <_long>Horizontal viewport positions</_long>
- <type>int</type>
- <min>1</min>
- <max>32</max>
- </option>
- <option name="viewport_y_values" type="list">
- <_short>Y Viewport Positions</_short>
- <_long>Vertical viewport positions</_long>
- <type>int</type>
- <min>1</min>
- <max>32</max>
- </option>
+ <group>
+ <_short>Fixed Window Placement</_short>
+ <subgroup>
+ <_short>Windows with fixed positions></_short>
+ <option name="position_matches" type="list">
+ <_short>Positioned windows</_short>
+ <_long>Windows that should be positioned by default</_long>
+ <type>match</type>
+ </option>
+ <option name="position_x_values" type="list">
+ <_short>X Positions</_short>
+ <_long>X position values</_long>
+ <type>int</type>
+ </option>
+ <option name="position_y_values" type="list">
+ <_short>Y Positions</_short>
+ <_long>Y position values</_long>
+ <type>int</type>
+ </option>
+ <option name="position_constrain_workarea" type="list">
+ <_short>Keep In Workarea</_short>
+ <_long>Keep placed window in work area, even if that means that the position might differ from the specified position</_long>
+ <type>bool</type>
+ </option>
+ </subgroup>
+ <subgroup>
+ <_short>Windows with fixed viewport</_short>
+ <option name="viewport_matches" type="list">
+ <_short>Viewport positioned windows</_short>
+ <_long>Windows that should be positioned in specific viewports by default</_long>
+ <type>match</type>
+ </option>
+ <option name="viewport_x_values" type="list">
+ <_short>X Viewport Positions</_short>
+ <_long>Horizontal viewport positions</_long>
+ <type>int</type>
+ <min>1</min>
+ <max>32</max>
+ </option>
+ <option name="viewport_y_values" type="list">
+ <_short>Y Viewport Positions</_short>
+ <_long>Vertical viewport positions</_long>
+ <type>int</type>
+ <min>1</min>
+ <max>32</max>
+ </option>
+ </subgroup>
+ </group>
</options>
</plugin>
</compiz>
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
index 2a3a543..49a953c 100644
--- a/plugins/CMakeLists.txt
+++ b/plugins/CMakeLists.txt
@@ -32,8 +32,18 @@ target_link_libraries (switcher composite opengl)
add_library (place MODULE place.cpp)
target_link_libraries (place)
+add_library (regex MODULE regex.cpp)
+target_link_libraries (regex)
+
+add_library (gnomecompat MODULE gnomecompat.cpp)
+target_link_libraries (gnomecompat)
+
+add_library (commands MODULE commands.cpp)
+target_link_libraries (commands)
+
install (
- TARGETS decor move resize copytex zoom water ini switcher place
+ TARGETS decor move resize copytex zoom water ini switcher
+ place regex gnomecompat commands
DESTINATION ${compiz_plugindir}
)
diff --git a/plugins/commands.cpp b/plugins/commands.cpp
new file mode 100644
index 0000000..932017e
--- /dev/null
+++ b/plugins/commands.cpp
@@ -0,0 +1,156 @@
+/*
+ * Copyright © 2009 Danny Baumann
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Danny Baumann not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Danny Baumann makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * DANNY BAUMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Danny Baumann <dannybaumann@web.de>
+ */
+
+#include "commands.h"
+
+COMPIZ_PLUGIN_20081216 (commands, CommandsPluginVTable);
+
+bool
+CommandsScreen::runCommand (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector& options,
+ int commandOption)
+{
+ CommandsScreen *cs;
+ Window xid;
+
+ xid = CompOption::getIntOptionNamed (options, "root", 0);
+ if (xid != screen->root ())
+ return false;
+
+ cs = CommandsScreen::get (screen);
+
+ screen->runCommand (cs->opt[commandOption].value (). s());
+
+ return true;
+}
+
+#define DISPATCH(opt) boost::bind (CommandsScreen::runCommand, _1, _2, _3, opt)
+
+static const CompMetadata::OptionInfo commandsOptionInfo[] = {
+ { "command0", "string", 0, 0, 0 },
+ { "command1", "string", 0, 0, 0 },
+ { "command2", "string", 0, 0, 0 },
+ { "command3", "string", 0, 0, 0 },
+ { "command4", "string", 0, 0, 0 },
+ { "command5", "string", 0, 0, 0 },
+ { "command6", "string", 0, 0, 0 },
+ { "command7", "string", 0, 0, 0 },
+ { "command8", "string", 0, 0, 0 },
+ { "command9", "string", 0, 0, 0 },
+ { "command10", "string", 0, 0, 0 },
+ { "command11", "string", 0, 0, 0 },
+ { "run_command0_key", "key", 0, DISPATCH (COMMANDS_OPTION_COMMAND0), 0 },
+ { "run_command1_key", "key", 0, DISPATCH (COMMANDS_OPTION_COMMAND1), 0 },
+ { "run_command2_key", "key", 0, DISPATCH (COMMANDS_OPTION_COMMAND2), 0 },
+ { "run_command3_key", "key", 0, DISPATCH (COMMANDS_OPTION_COMMAND3), 0 },
+ { "run_command4_key", "key", 0, DISPATCH (COMMANDS_OPTION_COMMAND4), 0 },
+ { "run_command5_key", "key", 0, DISPATCH (COMMANDS_OPTION_COMMAND5), 0 },
+ { "run_command6_key", "key", 0, DISPATCH (COMMANDS_OPTION_COMMAND6), 0 },
+ { "run_command7_key", "key", 0, DISPATCH (COMMANDS_OPTION_COMMAND7), 0 },
+ { "run_command8_key", "key", 0, DISPATCH (COMMANDS_OPTION_COMMAND8), 0 },
+ { "run_command9_key", "key", 0, DISPATCH (COMMANDS_OPTION_COMMAND9), 0 },
+ { "run_command10_key", "key", 0, DISPATCH (COMMANDS_OPTION_COMMAND10), 0 },
+ { "run_command11_key", "key", 0, DISPATCH (COMMANDS_OPTION_COMMAND11), 0 },
+ { "run_command0_button", "button", 0,
+ DISPATCH (COMMANDS_OPTION_COMMAND0), 0 },
+ { "run_command1_button", "button", 0,
+ DISPATCH (COMMANDS_OPTION_COMMAND1), 0 },
+ { "run_command2_button", "button", 0,
+ DISPATCH (COMMANDS_OPTION_COMMAND2), 0 },
+ { "run_command3_button", "button", 0,
+ DISPATCH (COMMANDS_OPTION_COMMAND3), 0 },
+ { "run_command4_button", "button", 0,
+ DISPATCH (COMMANDS_OPTION_COMMAND4), 0 },
+ { "run_command5_button", "button", 0,
+ DISPATCH (COMMANDS_OPTION_COMMAND5), 0 },
+ { "run_command6_button", "button", 0,
+ DISPATCH (COMMANDS_OPTION_COMMAND6), 0 },
+ { "run_command7_button", "button", 0,
+ DISPATCH (COMMANDS_OPTION_COMMAND7), 0 },
+ { "run_command8_button", "button", 0,
+ DISPATCH (COMMANDS_OPTION_COMMAND8), 0 },
+ { "run_command9_button", "button", 0,
+ DISPATCH (COMMANDS_OPTION_COMMAND9), 0 },
+ { "run_command10_button", "button", 0,
+ DISPATCH (COMMANDS_OPTION_COMMAND10), 0 },
+ { "run_command11_button", "button", 0,
+ DISPATCH (COMMANDS_OPTION_COMMAND11), 0 },
+ { "run_command0_edge", "edge", 0, DISPATCH (COMMANDS_OPTION_COMMAND0), 0 },
+ { "run_command1_edge", "edge", 0, DISPATCH (COMMANDS_OPTION_COMMAND1), 0 },
+ { "run_command2_edge", "edge", 0, DISPATCH (COMMANDS_OPTION_COMMAND2), 0 },
+ { "run_command3_edge", "edge", 0, DISPATCH (COMMANDS_OPTION_COMMAND3), 0 },
+ { "run_command4_edge", "edge", 0, DISPATCH (COMMANDS_OPTION_COMMAND4), 0 },
+ { "run_command5_edge", "edge", 0, DISPATCH (COMMANDS_OPTION_COMMAND5), 0 },
+ { "run_command6_edge", "edge", 0, DISPATCH (COMMANDS_OPTION_COMMAND6), 0 },
+ { "run_command7_edge", "edge", 0, DISPATCH (COMMANDS_OPTION_COMMAND7), 0 },
+ { "run_command8_edge", "edge", 0, DISPATCH (COMMANDS_OPTION_COMMAND8), 0 },
+ { "run_command9_edge", "edge", 0, DISPATCH (COMMANDS_OPTION_COMMAND9), 0 },
+ { "run_command10_edge", "edge", 0,
+ DISPATCH (COMMANDS_OPTION_COMMAND10), 0 },
+ { "run_command11_edge", "edge", 0,
+ DISPATCH (COMMANDS_OPTION_COMMAND11), 0 }
+};
+
+CommandsScreen::CommandsScreen (CompScreen *s) :
+ PrivateHandler<CommandsScreen, CompScreen> (s)
+{
+ if (!commandsVTable->getMetadata ()->initOptions (commandsOptionInfo,
+ COMMANDS_OPTION_NUM,
+ opt))
+ setFailed ();
+}
+
+CompOption::Vector&
+CommandsScreen::getOptions ()
+{
+ return opt;
+}
+
+bool
+CommandsScreen::setOption (const char *name,
+ CompOption::Value& value)
+{
+ CompOption *o;
+
+ o = CompOption::findOption (opt, name, NULL);
+ if (!o)
+ return false;
+
+ return CompOption::setOption (*o, value);
+}
+
+bool
+CommandsPluginVTable::init ()
+{
+ if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
+ return false;
+
+ getMetadata ()->addFromOptionInfo (commandsOptionInfo, COMMANDS_OPTION_NUM);
+ getMetadata ()->addFromFile (name ());
+
+ return true;
+}
+
diff --git a/plugins/commands.h b/plugins/commands.h
new file mode 100644
index 0000000..217695d
--- /dev/null
+++ b/plugins/commands.h
@@ -0,0 +1,105 @@
+/*
+ * Copyright © 2009 Danny Baumann
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Danny Baumann not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Danny Baumann makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * DANNY BAUMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Danny Baumann <dannybaumann@web.de>
+ */
+
+#include <core/core.h>
+#include <core/privatehandler.h>
+
+#define COMMANDS_OPTION_COMMAND0 0
+#define COMMANDS_OPTION_COMMAND1 1
+#define COMMANDS_OPTION_COMMAND2 2
+#define COMMANDS_OPTION_COMMAND3 3
+#define COMMANDS_OPTION_COMMAND4 4
+#define COMMANDS_OPTION_COMMAND5 5
+#define COMMANDS_OPTION_COMMAND6 6
+#define COMMANDS_OPTION_COMMAND7 7
+#define COMMANDS_OPTION_COMMAND8 8
+#define COMMANDS_OPTION_COMMAND9 9
+#define COMMANDS_OPTION_COMMAND10 10
+#define COMMANDS_OPTION_COMMAND11 11
+#define COMMANDS_OPTION_RUN_COMMAND0_KEY 12
+#define COMMANDS_OPTION_RUN_COMMAND1_KEY 13
+#define COMMANDS_OPTION_RUN_COMMAND2_KEY 14
+#define COMMANDS_OPTION_RUN_COMMAND3_KEY 15
+#define COMMANDS_OPTION_RUN_COMMAND4_KEY 16
+#define COMMANDS_OPTION_RUN_COMMAND5_KEY 17
+#define COMMANDS_OPTION_RUN_COMMAND6_KEY 18
+#define COMMANDS_OPTION_RUN_COMMAND7_KEY 19
+#define COMMANDS_OPTION_RUN_COMMAND8_KEY 20
+#define COMMANDS_OPTION_RUN_COMMAND9_KEY 21
+#define COMMANDS_OPTION_RUN_COMMAND10_KEY 22
+#define COMMANDS_OPTION_RUN_COMMAND11_KEY 23
+#define COMMANDS_OPTION_RUN_COMMAND0_BUTTON 24
+#define COMMANDS_OPTION_RUN_COMMAND1_BUTTON 25
+#define COMMANDS_OPTION_RUN_COMMAND2_BUTTON 26
+#define COMMANDS_OPTION_RUN_COMMAND3_BUTTON 27
+#define COMMANDS_OPTION_RUN_COMMAND4_BUTTON 28
+#define COMMANDS_OPTION_RUN_COMMAND5_BUTTON 29
+#define COMMANDS_OPTION_RUN_COMMAND6_BUTTON 30
+#define COMMANDS_OPTION_RUN_COMMAND7_BUTTON 31
+#define COMMANDS_OPTION_RUN_COMMAND8_BUTTON 32
+#define COMMANDS_OPTION_RUN_COMMAND9_BUTTON 33
+#define COMMANDS_OPTION_RUN_COMMAND10_BUTTON 34
+#define COMMANDS_OPTION_RUN_COMMAND11_BUTTON 35
+#define COMMANDS_OPTION_RUN_COMMAND0_EDGE 36
+#define COMMANDS_OPTION_RUN_COMMAND1_EDGE 37
+#define COMMANDS_OPTION_RUN_COMMAND2_EDGE 38
+#define COMMANDS_OPTION_RUN_COMMAND3_EDGE 39
+#define COMMANDS_OPTION_RUN_COMMAND4_EDGE 40
+#define COMMANDS_OPTION_RUN_COMMAND5_EDGE 41
+#define COMMANDS_OPTION_RUN_COMMAND6_EDGE 42
+#define COMMANDS_OPTION_RUN_COMMAND7_EDGE 43
+#define COMMANDS_OPTION_RUN_COMMAND8_EDGE 44
+#define COMMANDS_OPTION_RUN_COMMAND9_EDGE 45
+#define COMMANDS_OPTION_RUN_COMMAND10_EDGE 46
+#define COMMANDS_OPTION_RUN_COMMAND11_EDGE 47
+#define COMMANDS_OPTION_NUM 48
+
+class CommandsScreen :
+ public PrivateHandler<CommandsScreen, CompScreen>
+{
+ public:
+ CommandsScreen (CompScreen *s);
+
+ CompOption::Vector& getOptions ();
+ bool setOption (const char *name, CompOption::Value& value);
+
+ static bool runCommand (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector& options,
+ int commandOption);
+
+ private:
+ CompOption::Vector opt;
+};
+
+class CommandsPluginVTable :
+ public CompPlugin::VTableForScreen<CommandsScreen>
+{
+ public:
+ bool init ();
+
+ PLUGIN_OPTION_HELPER (CommandsScreen);
+};
+
diff --git a/plugins/decor.cpp b/plugins/decor.cpp
index 6ccf98d..089590e 100644
--- a/plugins/decor.cpp
+++ b/plugins/decor.cpp
@@ -1453,7 +1453,7 @@ DecorWindow::damageRect (bool initial, const CompRect &rect)
}
void
-DecorWindow::getOutputExtents (CompWindowExtents *output)
+DecorWindow::getOutputExtents (CompWindowExtents& output)
{
window->getOutputExtents (output);
@@ -1461,14 +1461,14 @@ DecorWindow::getOutputExtents (CompWindowExtents *output)
{
CompWindowExtents *e = &wd->decor->output;
- if (e->left > output->left)
- output->left = e->left;
- if (e->right > output->right)
- output->right = e->right;
- if (e->top > output->top)
- output->top = e->top;
- if (e->bottom > output->bottom)
- output->bottom = e->bottom;
+ if (e->left > output.left)
+ output.left = e->left;
+ if (e->right > output.right)
+ output.right = e->right;
+ if (e->top > output.top)
+ output.top = e->top;
+ if (e->bottom > output.bottom)
+ output.bottom = e->bottom;
}
}
@@ -1702,7 +1702,7 @@ DecorScreen::~DecorScreen ()
{
for (unsigned int i = 0; i < DECOR_NUM; i++)
if (decor[i])
- delete decor[i];
+ Decoration::release (decor[i]);
}
DecorWindow::DecorWindow (CompWindow *w) :
diff --git a/plugins/decor.h b/plugins/decor.h
index f7b023e..596e784 100644
--- a/plugins/decor.h
+++ b/plugins/decor.h
@@ -173,7 +173,7 @@ class DecorWindow :
DecorWindow (CompWindow *w);
~DecorWindow ();
- void getOutputExtents (CompWindowExtents *);
+ void getOutputExtents (CompWindowExtents&);
void resizeNotify (int, int, int, int);
void moveNotify (int, int, bool);
void stateChangeNotify (unsigned int);
diff --git a/plugins/gnomecompat.cpp b/plugins/gnomecompat.cpp
new file mode 100644
index 0000000..8b8e331
--- /dev/null
+++ b/plugins/gnomecompat.cpp
@@ -0,0 +1,170 @@
+/*
+ * Copyright © 2009 Danny Baumann
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Danny Baumann not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Danny Baumann makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * DANNY BAUMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Danny Baumann <dannybaumann@web.de>
+ */
+
+#include "gnomecompat.h"
+
+COMPIZ_PLUGIN_20081216 (gnomecompat, GnomeCompatPluginVTable);
+
+static bool
+runCommand (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector& options,
+ unsigned int commandOption)
+{
+ Window xid;
+
+ GNOME_SCREEN (screen);
+
+ xid = CompOption::getIntOptionNamed (options, "root", 0);
+ if (xid != screen->root ())
+ return false;
+
+ screen->runCommand (gs->opt[commandOption].value ().s ());
+
+ return true;
+}
+
+void
+GnomeCompatScreen::panelAction (CompOption::Vector& options,
+ Atom actionAtom)
+{
+ Window xid;
+ XEvent event;
+ Time time;
+
+ xid = CompOption::getIntOptionNamed (options, "root", 0);
+ if (xid != screen->root ())
+ return;
+
+ time = CompOption::getIntOptionNamed (options, "time", CurrentTime);
+
+ /* we need to ungrab the keyboard here, otherwise the panel main
+ menu won't popup as it wants to grab the keyboard itself */
+ XUngrabKeyboard (screen->dpy (), time);
+
+ event.type = ClientMessage;
+ event.xclient.window = screen->root ();
+ event.xclient.message_type = panelActionAtom;
+ event.xclient.format = 32;
+ event.xclient.data.l[0] = actionAtom;
+ event.xclient.data.l[1] = time;
+ event.xclient.data.l[2] = 0;
+ event.xclient.data.l[3] = 0;
+ event.xclient.data.l[4] = 0;
+
+ XSendEvent (screen->dpy (), screen->root (), FALSE,
+ StructureNotifyMask, &event);
+}
+
+static bool
+showMainMenu (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector& options)
+{
+ GNOME_SCREEN (screen);
+
+ gs->panelAction (options, gs->panelMainMenuAtom);
+
+ return true;
+}
+
+static bool
+showRunDialog (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector& options)
+{
+ GNOME_SCREEN (screen);
+
+ gs->panelAction (options, gs->panelRunDialogAtom);
+
+ return true;
+}
+
+#define COMMAND_BIND(opt) \
+ boost::bind (runCommand, _1, _2, _3, opt)
+
+static const CompMetadata::OptionInfo gnomeOptionInfo[] = {
+ { "main_menu_key", "key", 0, showMainMenu, 0 },
+ { "run_key", "key", 0, showRunDialog, 0 },
+ { "command_screenshot", "string", 0, 0, 0 },
+ { "run_command_screenshot_key", "key", 0,
+ COMMAND_BIND (GNOME_OPTION_SCREENSHOT_CMD), 0 },
+ { "command_window_screenshot", "string", 0, 0, 0 },
+ { "run_command_window_screenshot_key", "key", 0,
+ COMMAND_BIND (GNOME_OPTION_WINDOW_SCREENSHOT_CMD), 0 },
+ { "command_terminal", "string", 0, 0, 0 },
+ { "run_command_terminal_key", "key", 0,
+ COMMAND_BIND (GNOME_OPTION_TERMINAL_CMD), 0 }
+};
+
+GnomeCompatScreen::GnomeCompatScreen (CompScreen *s) :
+ PrivateHandler<GnomeCompatScreen, CompScreen> (s)
+{
+ if (!gnomecompatVTable->getMetadata ()->initOptions (gnomeOptionInfo,
+ GNOME_OPTION_NUM,
+ opt))
+ {
+ setFailed ();
+ return;
+ }
+
+ panelActionAtom =
+ XInternAtom (screen->dpy (), "_GNOME_PANEL_ACTION", FALSE);
+ panelMainMenuAtom =
+ XInternAtom (screen->dpy (), "_GNOME_PANEL_ACTION_MAIN_MENU", FALSE);
+ panelRunDialogAtom =
+ XInternAtom (screen->dpy (), "_GNOME_PANEL_ACTION_RUN_DIALOG", FALSE);
+}
+
+CompOption::Vector&
+GnomeCompatScreen::getOptions ()
+{
+ return opt;
+}
+
+bool
+GnomeCompatScreen::setOption (const char *name,
+ CompOption::Value& value)
+{
+ CompOption *o;
+
+ o = CompOption::findOption (opt, name, NULL);
+ if (!o)
+ return false;
+
+ return CompOption::setOption (*o, value);
+}
+
+bool
+GnomeCompatPluginVTable::init ()
+{
+ if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
+ return false;
+
+ getMetadata ()->addFromOptionInfo (gnomeOptionInfo, GNOME_OPTION_NUM);
+ getMetadata ()->addFromFile (name ());
+
+ return true;
+}
diff --git a/plugins/gnomecompat.h b/plugins/gnomecompat.h
new file mode 100644
index 0000000..56c4b7a
--- /dev/null
+++ b/plugins/gnomecompat.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright © 2009 Danny Baumann
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Danny Baumann not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Danny Baumann makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * DANNY BAUMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Danny Baumann <dannybaumann@web.de>
+ */
+
+#include <core/core.h>
+#include <core/privatehandler.h>
+
+#define GNOME_OPTION_MAIN_MENU_KEY 0
+#define GNOME_OPTION_RUN_DIALOG_KEY 1
+#define GNOME_OPTION_SCREENSHOT_CMD 2
+#define GNOME_OPTION_RUN_SCREENSHOT_KEY 3
+#define GNOME_OPTION_WINDOW_SCREENSHOT_CMD 4
+#define GNOME_OPTION_RUN_WINDOW_SCREENSHOT_KEY 5
+#define GNOME_OPTION_TERMINAL_CMD 6
+#define GNOME_OPTION_RUN_TERMINAL_KEY 7
+#define GNOME_OPTION_NUM 8
+
+class GnomeCompatScreen :
+ public PrivateHandler<GnomeCompatScreen, CompScreen>
+{
+ public:
+ GnomeCompatScreen (CompScreen *s);
+
+ CompOption::Vector & getOptions ();
+ bool setOption (const char *name, CompOption::Value& value);
+
+ void panelAction (CompOption::Vector& options, Atom action);
+
+ Atom panelActionAtom;
+ Atom panelMainMenuAtom;
+ Atom panelRunDialogAtom;
+
+ CompOption::Vector opt;
+};
+
+#define GNOME_SCREEN(s) \
+ GnomeCompatScreen *gs = GnomeCompatScreen::get (s)
+
+class GnomeCompatPluginVTable :
+ public CompPlugin::VTableForScreen<GnomeCompatScreen>
+{
+ public:
+ bool init ();
+
+ PLUGIN_OPTION_HELPER (GnomeCompatScreen);
+};
diff --git a/plugins/ini.cpp b/plugins/ini.cpp
index ff521af..6f5d4af 100644
--- a/plugins/ini.cpp
+++ b/plugins/ini.cpp
@@ -27,6 +27,7 @@
*/
#include "ini.h"
+#include <errno.h>
#include <boost/lexical_cast.hpp>
COMPIZ_PLUGIN_20081216 (ini, IniPluginVTable)
@@ -52,7 +53,7 @@ IniFile::open (bool write)
if (homeDir.empty ())
return false;
- filePath = homeDir;
+ filePath = homeDir;
if (strcmp (plugin->vTable->name ().c_str (), "core") == 0)
filePath += "general";
else
@@ -61,13 +62,8 @@ IniFile::open (bool write)
mode = write ? std::ios::out : std::ios::in;
optionFile.open (filePath.c_str (), mode);
- if (optionFile.fail ())
- {
- mkdir (homeDir.c_str (), 0700);
- optionFile.open (filePath.c_str (), mode);
- }
-
- return true;
+
+ return !optionFile.fail ();
}
void
@@ -83,9 +79,6 @@ IniFile::load ()
return;
if (!open (false))
- return;
-
- if (optionFile.fail ())
{
compLogMessage ("ini", CompLogLevelWarn,
"Could not open config for plugin %s - using defaults.",
@@ -471,6 +464,33 @@ IniScreen::getHomeDir ()
}
bool
+IniScreen::createDir (const CompString& path)
+{
+ size_t pos;
+
+ if (mkdir (path.c_str (), 0700) == 0)
+ return true;
+
+ /* did it already exist? */
+ if (errno == EEXIST)
+ return true;
+
+ /* was parent present? if yes, fail */
+ if (errno != ENOENT)
+ return false;
+
+ /* skip last character which may be a '/' */
+ pos = path.rfind ('/', path.size () - 2);
+ if (pos == CompString::npos)
+ return false;
+
+ if (!createDir (path.substr (0, pos)))
+ return false;
+
+ return (mkdir (path.c_str (), 0700) == 0);
+}
+
+bool
IniScreen::setOptionForPlugin (const char *plugin,
const char *name,
CompOption::Value &v)
@@ -520,7 +540,7 @@ IniScreen::IniScreen (CompScreen *screen) :
int mask;
homeDir = getHomeDir ();
- if (homeDir.empty ())
+ if (homeDir.empty () || !createDir (homeDir))
{
setFailed ();
return;
diff --git a/plugins/ini.h b/plugins/ini.h
index 0ac051f..83f1ae9 100644
--- a/plugins/ini.h
+++ b/plugins/ini.h
@@ -59,6 +59,7 @@ class IniScreen :
public:
static CompString getHomeDir ();
+ static bool createDir (const CompString& path);
};
class IniPluginVTable :
diff --git a/plugins/inotify.cpp b/plugins/inotify.cpp
index b690a46..58b0205 100644
--- a/plugins/inotify.cpp
+++ b/plugins/inotify.cpp
@@ -130,7 +130,7 @@ InotifyScreen::fileWatchAdded (CompFileWatch *fileWatch)
InotifyWatch iw;
iw.handle = fileWatch->handle;
- iw.wd = inotify_add_watch (fd, fileWatch->path,
+ iw.wd = inotify_add_watch (fd, fileWatch->path.c_str (),
inotifyMask (fileWatch));
if (iw.wd < 0)
{
diff --git a/plugins/opengl/texture.cpp b/plugins/opengl/texture.cpp
index 0d45fa4..9713aa5 100644
--- a/plugins/opengl/texture.cpp
+++ b/plugins/opengl/texture.cpp
@@ -103,6 +103,8 @@ GLTexture::GLTexture () :
GLTexture::~GLTexture ()
{
+ if (priv)
+ delete priv;
}
PrivateTexture::PrivateTexture (GLTexture *texture) :
diff --git a/plugins/place.cpp b/plugins/place.cpp
index 599e0a5..f3428a6 100644
--- a/plugins/place.cpp
+++ b/plugins/place.cpp
@@ -32,6 +32,7 @@ static const CompMetadata::OptionInfo placeOptionInfo[] = {
{ "position_matches", "list", "<type>match</type>", 0, 0 },
{ "position_x_values", "list", "<type>int</type>", 0, 0 },
{ "position_y_values", "list", "<type>int</type>", 0, 0 },
+ { "position_constrain_workarea", "list", "<type>bool</type>", 0, 0 },
{ "viewport_matches", "list", "<type>match</type>", 0, 0 },
{ "viewport_x_values", "list",
"<type>int</type><min>1</min><max>32</max>", 0, 0 },
@@ -57,6 +58,89 @@ PlaceScreen::~PlaceScreen ()
{
}
+static void
+getWindowExtentsRect (CompWindow *w,
+ XRectangle &rect)
+{
+ rect.x = w->serverX () - w->input ().left;
+ rect.y = w->serverY () - w->input ().top;
+ rect.width = w->serverWidth ();
+ rect.height = w->serverHeight ();
+}
+
+void
+PlaceScreen::handleScreenSizeChange (int width,
+ int height)
+{
+ int vpX, vpY, shiftX, shiftY;
+ XRectangle extents;
+ unsigned int mask;
+ XWindowChanges xwc;
+
+ foreach (CompWindow *w, screen->windows ())
+ {
+ if (!w->managed ())
+ continue;
+
+ if (w->wmType () & (CompWindowTypeDockMask |
+ CompWindowTypeDesktopMask))
+ continue;
+
+ mask = 0;
+ getWindowExtentsRect (w, extents);
+
+ vpX = extents.x / screen->width ();
+ if (extents.x < 0)
+ vpX -= 1;
+ vpY = extents.y / screen->height ();
+ if (extents.y < 0)
+ vpY -= 1;
+
+ shiftX = vpX * (width - screen->width ());
+ shiftY = vpY * (height - screen->height ());
+
+ extents.x = extents.x % screen->width ();
+ if (extents.x < 0)
+ extents.x += screen->width ();
+ extents.y = extents.y % screen->height ();
+ if (extents.y < 0)
+ extents.y += screen->height ();
+
+ if (extents.x + extents.width > width)
+ shiftX += width - extents.x - extents.width;
+ if (extents.y + extents.height > height)
+ shiftY += height - extents.y - extents.height;
+
+ if (shiftX)
+ {
+ mask |= CWX;
+ xwc.x = w->serverX () + shiftX;
+ }
+
+ if (shiftY)
+ {
+ mask |= CWY;
+ xwc.y = w->serverY () + shiftY;
+ }
+
+ if (mask)
+ w->configureXWindow (mask, &xwc);
+ }
+}
+
+void
+PlaceScreen::handleEvent (XEvent *event)
+{
+ if (event->type == ConfigureNotify &&
+ event->xconfigure.window == screen->root ())
+ {
+ handleScreenSizeChange (event->xconfigure.width,
+ event->xconfigure.height);
+ }
+
+ screen->handleEvent (event);
+}
+
CompOption::Vector &
PlaceScreen::getOptions ()
{
@@ -87,13 +171,13 @@ PlaceScreen::setOption (const char *name,
return true;
}
-/* sort sort functions */
+/* sort functions */
static bool
compareLeftmost (CompWindow *a,
CompWindow *b)
{
- int ax, bx;
+ int ax, bx;
ax = a->serverX () - a->input ().left;
bx = b->serverX () - b->input ().left;
@@ -105,7 +189,7 @@ static bool
compareTopmost (CompWindow *a,
CompWindow *b)
{
- int ay, by;
+ int ay, by;
ay = a->serverY () - a->input ().top;
by = b->serverY () - b->input ().top;
@@ -117,9 +201,9 @@ static bool
compareNorthWestCorner (CompWindow *a,
CompWindow *b)
{
- int fromOriginA;
- int fromOriginB;
- int ax, ay, bx, by;
+ int fromOriginA;
+ int fromOriginB;
+ int ax, ay, bx, by;
ax = a->serverX () - a->input ().left;
ay = a->serverY () - a->input ().top;
@@ -191,6 +275,12 @@ PlaceWindow::validateResizeRequest (unsigned int &mask,
window->validateResizeRequest (mask, xwc, source);
+ if (!mask)
+ return;
+
+ if (source == ClientTypePager)
+ return;
+
if (window->state () & CompWindowStateFullscreenMask)
return;
@@ -217,11 +307,11 @@ PlaceWindow::validateResizeRequest (unsigned int &mask,
sizes as we don't need to validate movements to other viewports;
we are only interested in inner-viewport movements */
x = xwc->x % screen->width ();
- if (x < 0)
+ if ((x + xwc->width) < 0)
x += screen->width ();
y = xwc->y % screen->height ();
- if (y < 0)
+ if ((y + xwc->height) < 0)
y += screen->height ();
left = x - window->input ().left;
@@ -237,7 +327,12 @@ PlaceWindow::validateResizeRequest (unsigned int &mask,
if (xwc->width >= workArea.width &&
xwc->height >= workArea.height)
{
- sendMaximizationRequest ();
+ if ((window->actions () & MAXIMIZE_STATE) == MAXIMIZE_STATE &&
+ (window->mwmDecor () & (MwmDecorAll | MwmDecorTitle)) &&
+ !(window->state () & CompWindowStateFullscreenMask))
+ {
+ sendMaximizationRequest ();
+ }
}
if ((right - left) > workArea.width)
@@ -322,17 +417,19 @@ PlaceWindow::doPlacement (CompPoint &pos)
XRectangle workArea;
CompPoint targetVp;
PlacementStrategy strategy;
+ bool keepInWorkarea;
PLACE_SCREEN (screen);
- strategy = getStrategy ();
- if (strategy == NoPlacement)
- return;
-
- if (matchPosition (pos))
+ if (matchPosition (pos, keepInWorkarea))
+ {
+ strategy = keepInWorkarea ? ConstrainOnly : NoPlacement;
+ }
+ else
{
- /* FIXME: perhaps ConstrainOnly? */
- strategy = NoPlacement;
+ strategy = getStrategy ();
+ if (strategy == NoPlacement)
+ return;
}
const CompOutput &output = getPlacementOutput (strategy, pos);
@@ -700,16 +797,6 @@ PlaceWindow::placeSmart (XRectangle &workArea,
}
static void
-getWindowExtentsRect (CompWindow *w,
- XRectangle &rect)
-{
- rect.x = w->serverX () - w->input ().left;
- rect.y = w->serverY () - w->input ().top;
- rect.width = w->serverWidth ();
- rect.height = w->serverHeight ();
-}
-
-static void
centerTileRectInArea (XRectangle &rect,
XRectangle &workArea)
{
@@ -1016,6 +1103,8 @@ PlaceWindow::cascadeFindNext (CompWindowList &windows,
PlaceWindow::PlacementStrategy
PlaceWindow::getStrategy ()
{
+ int opt;
+
PLACE_SCREEN (screen);
if (window->type () & (CompWindowTypeDockMask |
@@ -1030,7 +1119,8 @@ PlaceWindow::getStrategy ()
return NoPlacement;
}
- if (window->wmType () & (CompWindowTypeDockMask | CompWindowTypeDesktopMask))
+ if (window->wmType () & (CompWindowTypeDockMask |
+ CompWindowTypeDesktopMask))
{
/* see above */
return NoPlacement;
@@ -1040,7 +1130,8 @@ PlaceWindow::getStrategy ()
if (!(window->actions () & CompWindowActionMoveMask))
return NoPlacement;
- if (!ps->opt[PLACE_OPTION_FORCE_PLACEMENT].value ().match ().evaluate (window))
+ opt = PLACE_OPTION_FORCE_PLACEMENT;
+ if (!ps->opt[opt].value ().match ().evaluate (window))
{
if ((window->type () & CompWindowTypeNormalMask) ||
ps->opt[PLACE_OPTION_WORKAROUND].value ().b ())
@@ -1058,12 +1149,16 @@ PlaceWindow::getStrategy ()
}
if (window->transientFor () &&
- (window->type () & (CompWindowTypeDialogMask | CompWindowTypeModalDialogMask)))
+ (window->type () & (CompWindowTypeDialogMask |
+ CompWindowTypeModalDialogMask)))
{
- return PlaceOverParent;
+ CompWindow *parent = screen->findWindow (window->transientFor ());
+
+ if (parent && parent->managed ())
+ return PlaceOverParent;
}
- if (window->type () & (CompWindowTypeDialogMask |
+ if (window->type () & (CompWindowTypeDialogMask |
CompWindowTypeModalDialogMask |
CompWindowTypeSplashMask))
{
@@ -1156,35 +1251,31 @@ PlaceWindow::constrainToWorkarea (XRectangle &workArea,
CompPoint &pos)
{
CompWindowExtents extents;
- int width, height;
+ int delta;
extents.left = pos.x ()- window->input ().left;
extents.top = pos.y () - window->input ().top;
extents.right = extents.left + window->serverWidth ();
extents.bottom = extents.top + window->serverHeight ();
- width = extents.right - extents.left;
- height = extents.bottom - extents.top;
+ delta = workArea.x + workArea.width - extents.right;
+ if (delta < 0)
+ extents.left += delta;
- if (extents.left < workArea.x)
- {
- pos.setX (pos.x () + workArea.x - extents.left);
- }
- else if (width <= workArea.width &&
- extents.right > workArea.x + workArea.width)
- {
- pos.setX (pos.x () + workArea.x + workArea.width - extents.right);
- }
+ delta = workArea.x - extents.left;
+ if (delta > 0)
+ extents.left += delta;
- if (extents.top < workArea.y)
- {
- pos.setY (pos.y () + workArea.y - extents.top);
- }
- else if (height <= workArea.height &&
- extents.bottom > workArea.y + workArea.height)
- {
- pos.setY (pos.y () + workArea.y + workArea.height - extents.bottom);
- }
+ delta = workArea.y + workArea.height - extents.bottom;
+ if (delta < 0)
+ extents.top += delta;
+
+ delta = workArea.y - extents.top;
+ if (delta > 0)
+ extents.top += delta;
+
+ pos.setX (extents.left + window->input ().left);
+ pos.setY (extents.top + window->input ().top);
}
bool
@@ -1229,7 +1320,9 @@ bool
PlaceWindow::matchXYValue (CompOption::Value::Vector &matches,
CompOption::Value::Vector &xValues,
CompOption::Value::Vector &yValues,
- CompPoint &pos)
+ CompPoint &pos,
+ CompOption::Value::Vector *constrainValues,
+ bool *keepInWorkarea)
{
int i, min;
@@ -1246,6 +1339,14 @@ PlaceWindow::matchXYValue (CompOption::Value::Vector &matches,
pos.setX (xValues[i].i ());
pos.setY (yValues[i].i ());
+ if (keepInWorkarea)
+ {
+ if (constrainValues && constrainValues->size () > i)
+ *keepInWorkarea = (*constrainValues)[i].b ();
+ else
+ *keepInWorkarea = true;
+ }
+
return true;
}
}
@@ -1254,7 +1355,8 @@ PlaceWindow::matchXYValue (CompOption::Value::Vector &matches,
}
bool
-PlaceWindow::matchPosition (CompPoint &pos)
+PlaceWindow::matchPosition (CompPoint &pos,
+ bool &keepInWorkarea)
{
PLACE_SCREEN (screen);
@@ -1262,7 +1364,9 @@ PlaceWindow::matchPosition (CompPoint &pos)
ps->opt[PLACE_OPTION_POSITION_MATCHES].value ().list (),
ps->opt[PLACE_OPTION_POSITION_X_VALUES].value ().list (),
ps->opt[PLACE_OPTION_POSITION_Y_VALUES].value ().list (),
- pos);
+ pos,
+ &ps->opt[PLACE_OPTION_POSITION_CONSTRAIN].value ().list (),
+ &keepInWorkarea);
}
bool
diff --git a/plugins/place.h b/plugins/place.h
index 291d65f..08549da 100644
--- a/plugins/place.h
+++ b/plugins/place.h
@@ -41,17 +41,18 @@
#define PLACE_MOMODE_FULLSCREEN 3
#define PLACE_MOMODE_LAST PLACE_MOMODE_FULLSCREEN
-#define PLACE_OPTION_WORKAROUND 0
-#define PLACE_OPTION_MODE 1
-#define PLACE_OPTION_MULTIOUTPUT_MODE 2
-#define PLACE_OPTION_FORCE_PLACEMENT 3
-#define PLACE_OPTION_POSITION_MATCHES 4
-#define PLACE_OPTION_POSITION_X_VALUES 5
-#define PLACE_OPTION_POSITION_Y_VALUES 6
-#define PLACE_OPTION_VIEWPORT_MATCHES 7
-#define PLACE_OPTION_VIEWPORT_X_VALUES 8
-#define PLACE_OPTION_VIEWPORT_Y_VALUES 9
-#define PLACE_OPTION_NUM 10
+#define PLACE_OPTION_WORKAROUND 0
+#define PLACE_OPTION_MODE 1
+#define PLACE_OPTION_MULTIOUTPUT_MODE 2
+#define PLACE_OPTION_FORCE_PLACEMENT 3
+#define PLACE_OPTION_POSITION_MATCHES 4
+#define PLACE_OPTION_POSITION_X_VALUES 5
+#define PLACE_OPTION_POSITION_Y_VALUES 6
+#define PLACE_OPTION_POSITION_CONSTRAIN 7
+#define PLACE_OPTION_VIEWPORT_MATCHES 8
+#define PLACE_OPTION_VIEWPORT_X_VALUES 9
+#define PLACE_OPTION_VIEWPORT_Y_VALUES 10
+#define PLACE_OPTION_NUM 11
#define PLACE_SCREEN(s) PlaceScreen *ps = PlaceScreen::get (s)
@@ -63,6 +64,9 @@ class PlaceScreen :
PlaceScreen (CompScreen *screen);
~PlaceScreen ();
+ void handleEvent (XEvent *event);
+ void handleScreenSizeChange (int width, int height);
+
CompOption::Vector & getOptions ();
bool setOption (const char *name, CompOption::Value &value);
@@ -110,13 +114,15 @@ class PlaceWindow :
void cascadeFindNext (CompWindowList &windows, XRectangle &workArea,
CompPoint &pos);
- bool matchPosition (CompPoint &pos);
+ bool matchPosition (CompPoint &pos, bool& keepInWorkarea);
bool matchViewport (CompPoint &pos);
bool matchXYValue (CompOption::Value::Vector &matches,
CompOption::Value::Vector &xValues,
CompOption::Value::Vector &yValues,
- CompPoint &pos);
+ CompPoint &pos,
+ CompOption::Value::Vector *constrainValues = NULL,
+ bool *keepInWorkarea = NULL);
CompWindow *window;
};
diff --git a/plugins/regex.cpp b/plugins/regex.cpp
index b926b2a..c09f66d 100644
--- a/plugins/regex.cpp
+++ b/plugins/regex.cpp
@@ -23,229 +23,150 @@
* Author: David Reveman <davidr@novell.com>
*/
-#include <stdlib.h>
-#include <string.h>
+#include "regexplugin.h"
#include <limits.h>
-#include <regex.h>
+COMPIZ_PLUGIN_20081216 (regex, RegexPluginVTable);
-#include <X11/Xatom.h>
-
-#include <compiz-core.h>
-
-static CompMetadata regexMetadata;
-
-static int displayPrivateIndex;
-
-typedef struct _RegexDisplay {
- int screenPrivateIndex;
- HandleEventProc handleEvent;
- MatchInitExpProc matchInitExp;
- Atom roleAtom;
- Atom visibleNameAtom;
-} RegexDisplay;
-
-typedef struct _RegexScreen {
- int windowPrivateIndex;
-} RegexScreen;
-
-typedef struct _RegexWindow {
- char *title;
- char *role;
-} RegexWindow;
-
-#define GET_REGEX_DISPLAY(d) \
- ((RegexDisplay *) (d)->base.privates[displayPrivateIndex].ptr)
-
-#define REGEX_DISPLAY(d) \
- RegexDisplay *rd = GET_REGEX_DISPLAY (d)
-
-#define GET_REGEX_SCREEN(s, rd) \
- ((RegexScreen *) (s)->base.privates[(rd)->screenPrivateIndex].ptr)
-
-#define REGEX_SCREEN(s) \
- RegexScreen *rs = GET_REGEX_SCREEN (s, GET_REGEX_DISPLAY (s->display))
-
-#define GET_REGEX_WINDOW(w, rs) \
- ((RegexWindow *) (w)->base.privates[(rs)->windowPrivateIndex].ptr)
+class RegexExp : public CompMatch::Expression
+{
+ public:
+ typedef enum {
+ TypeTitle,
+ TypeRole,
+ TypeClass,
+ TypeName,
+ } Type;
+
+ RegexExp (const CompString& str, int item);
+ virtual ~RegexExp ();
+
+ bool evaluate (CompWindow *w);
+ static int matches (const CompString& str);
+
+ private:
+ typedef struct {
+ const char *name;
+ size_t length;
+ Type type;
+ unsigned int flags;
+ } Prefix;
+
+ static const Prefix prefix[];
+
+ Type mType;
+ regex_t *mRegex;
+};
-#define REGEX_WINDOW(w) \
- RegexWindow *rw = GET_REGEX_WINDOW (w, \
- GET_REGEX_SCREEN (w->screen, \
- GET_REGEX_DISPLAY (w->screen->display)))
+const RegexExp::Prefix RegexExp::prefix[] = {
+ { "title=", 6, TypeTitle, 0 },
+ { "role=", 5, TypeRole, 0 },
+ { "class=", 6, TypeClass, 0 },
+ { "name=", 5, TypeName, 0 },
+ { "ititle=", 7, TypeTitle, REG_ICASE },
+ { "irole=", 6, TypeRole, REG_ICASE },
+ { "iclass=", 7, TypeClass, REG_ICASE },
+ { "iname=", 6, TypeName, REG_ICASE }
+};
-static void
-regexMatchExpFini (CompDisplay *d,
- CompPrivate private)
+RegexExp::RegexExp (const CompString& str, int item) :
+ mRegex (NULL)
{
- regex_t *preg = (regex_t *) private.ptr;
-
- if (preg)
+ if (item < sizeof (prefix) / sizeof (prefix[0]))
{
- regfree (preg);
- free (preg);
- }
-}
+ int status;
+ CompString value;
-static Bool
-regexMatchExpEvalTitle (CompDisplay *d,
- CompWindow *w,
- CompPrivate private)
-{
- regex_t *preg = (regex_t *) private.ptr;
- int status;
+ value = str.substr (prefix[item].length);
+ mRegex = new regex_t;
+ status = regcomp (mRegex, value.c_str (),
+ REG_NOSUB | prefix[item].flags);
- REGEX_WINDOW (w);
+ if (status)
+ {
+ char errMsg[1024];
- if (!preg)
- return FALSE;
+ regerror (status, mRegex, errMsg, sizeof (errMsg));
- if (!rw->title)
- return FALSE;
+ compLogMessage ("regex", CompLogLevelWarn,
+ "%s = %s", errMsg, value.c_str ());
- status = regexec (preg, rw->title, 0, NULL, 0);
- if (status)
- return FALSE;
+ regfree (mRegex);
+ delete mRegex;
+ mRegex = NULL;
+ }
- return TRUE;
+ mType = prefix[item].type;
+ }
}
-static Bool
-regexMatchExpEvalRole (CompDisplay *d,
- CompWindow *w,
- CompPrivate private)
+RegexExp::~RegexExp ()
{
- regex_t *preg = (regex_t *) private.ptr;
- int status;
-
- REGEX_WINDOW (w);
-
- if (!preg)
- return FALSE;
-
- if (!rw->role)
- return FALSE;
-
- status = regexec (preg, rw->role, 0, NULL, 0);
- if (status)
- return FALSE;
-
- return TRUE;
+ if (mRegex)
+ {
+ regfree (mRegex);
+ delete mRegex;
+ }
}
-static Bool
-regexMatchExpEvalClass (CompDisplay *d,
- CompWindow *w,
- CompPrivate private)
+bool
+RegexExp::evaluate (CompWindow *w)
{
- regex_t *preg = (regex_t *) private.ptr;
- int status;
+ CompString *string = NULL;
+ RegexWindow *rw = RegexWindow::get (w);
- if (!preg)
- return FALSE;
+ switch (mType)
+ {
+ case TypeRole:
+ string = &rw->role;
+ break;
+ case TypeTitle:
+ string = &rw->title;
+ break;
+ case TypeClass:
+ string = &rw->resClass;
+ break;
+ case TypeName:
+ string = &rw->resName;
+ break;
+ }
- if (!w->resClass)
- return FALSE;
+ if (!mRegex || !string)
+ return false;
- status = regexec (preg, w->resClass, 0, NULL, 0);
- if (status)
- return FALSE;
+ if (regexec (mRegex, string->c_str (), 0, NULL, 0))
+ return false;
- return TRUE;
+ return true;
}
-static Bool
-regexMatchExpEvalName (CompDisplay *d,
- CompWindow *w,
- CompPrivate private)
+int
+RegexExp::matches (const CompString& str)
{
- regex_t *preg = (regex_t *) private.ptr;
- int status;
+ int i;
- if (!preg)
- return FALSE;
-
- if (!w->resName)
- return FALSE;
-
- status = regexec (preg, w->resName, 0, NULL, 0);
- if (status)
- return FALSE;
+ for (i = 0; i < sizeof (prefix) / sizeof (prefix[0]); i++)
+ if (str.compare (0, prefix[i].length, prefix[i].name) == 0)
+ return i;
- return TRUE;
+ return -1;
}
-static void
-regexMatchInitExp (CompDisplay *d,
- CompMatchExp *exp,
- const char *value)
+CompMatch::Expression *
+RegexScreen::matchInitExp (const CompString& str)
{
- static struct _Prefix {
- char *s;
- int len;
- CompMatchExpEvalProc eval;
- unsigned int flags;
- } prefix[] = {
- { "title=", 6, regexMatchExpEvalTitle, 0 },
- { "role=", 5, regexMatchExpEvalRole, 0 },
- { "class=", 6, regexMatchExpEvalClass, 0 },
- { "name=", 5, regexMatchExpEvalName, 0 },
- { "ititle=", 7, regexMatchExpEvalTitle, REG_ICASE },
- { "irole=", 6, regexMatchExpEvalRole, REG_ICASE },
- { "iclass=", 7, regexMatchExpEvalClass, REG_ICASE },
- { "iname=", 6, regexMatchExpEvalName, REG_ICASE },
- };
- int i;
-
- REGEX_DISPLAY (d);
-
- for (i = 0; i < sizeof (prefix) / sizeof (prefix[0]); i++)
- if (strncmp (value, prefix[i].s, prefix[i].len) == 0)
- break;
-
- if (i < sizeof (prefix) / sizeof (prefix[0]))
- {
- regex_t *preg;
-
- preg = malloc (sizeof (regex_t));
- if (preg)
- {
- int status;
-
- value += prefix[i].len;
+ int item = RegexExp::matches (str);
- status = regcomp (preg, value, REG_NOSUB | prefix[i].flags);
- if (status)
- {
- char errMsg[1024];
+ if (item >= 0)
+ return new RegexExp (str, item);
- regerror (status, preg, errMsg, sizeof (errMsg));
-
- compLogMessage (d, "regex", CompLogLevelWarn,
- "%s = %s", errMsg, value);
-
- regfree (preg);
- free (preg);
- preg = NULL;
- }
- }
-
- exp->fini = regexMatchExpFini;
- exp->eval = prefix[i].eval;
- exp->priv.ptr = preg;
- }
- else
- {
- UNWRAP (rd, d, matchInitExp);
- (*d->matchInitExp) (d, exp, value);
- WRAP (rd, d, matchInitExp, regexMatchInitExp);
- }
+ return screen->matchInitExp (str);
}
-static char *
-regexGetStringProperty (CompWindow *w,
- Atom propAtom,
- Atom formatAtom)
+bool
+RegexWindow::getStringProperty (Atom nameAtom,
+ Atom typeAtom,
+ CompString& string)
{
Atom type;
unsigned long nItems;
@@ -254,305 +175,138 @@ regexGetStringProperty (CompWindow *w,
int format, result;
char *retval;
- result = XGetWindowProperty (w->screen->display->display,
- w->id, propAtom, 0, LONG_MAX,
- FALSE, formatAtom, &type, &format, &nItems,
- &bytesAfter, (unsigned char **) &str);
+ result = XGetWindowProperty (screen->dpy (), window->id (), nameAtom, 0,
+ LONG_MAX, FALSE, typeAtom, &type, &format,
+ &nItems, &bytesAfter, (unsigned char **) &str);
if (result != Success)
- return NULL;
+ return false;
- if (type != formatAtom)
+ if (type != typeAtom)
{
XFree (str);
- return NULL;
+ return false;
}
- retval = strdup ((char *) str);
+ string = (char *) str;
XFree (str);
- return retval;
+ return true;
}
-static char *
-regexGetWindowTitle (CompWindow *w)
+void
+RegexWindow::updateRole ()
{
- CompDisplay *d = w->screen->display;
- char *title;
-
- REGEX_DISPLAY (d);
+ RegexScreen *rs = RegexScreen::get (screen);
- title = regexGetStringProperty (w, rd->visibleNameAtom, d->utf8StringAtom);
- if (title)
- return title;
-
- title = regexGetStringProperty (w, d->wmNameAtom, d->utf8StringAtom);
- if (title)
- return title;
-
- return regexGetStringProperty (w, XA_WM_NAME, XA_STRING);
+ role = "";
+ getStringProperty (rs->roleAtom, XA_STRING, role);
}
-static void
-regexHandleEvent (CompDisplay *d,
- XEvent *event)
+void
+RegexWindow::updateTitle ()
{
- REGEX_DISPLAY (d);
+ RegexScreen *rs = RegexScreen::get (screen);
- UNWRAP (rd, d, handleEvent);
- (*d->handleEvent) (d, event);
- WRAP (rd, d, handleEvent, regexHandleEvent);
+ title = "";
- if (event->type == PropertyNotify)
- {
- CompWindow *w;
+ if (getStringProperty (rs->visibleNameAtom, Atoms::utf8String, title))
+ return;
- if (event->xproperty.atom == XA_WM_NAME)
- {
- w = findWindowAtDisplay (d, event->xproperty.window);
- if (w)
- {
- REGEX_WINDOW (w);
+ if (getStringProperty (Atoms::wmName, Atoms::utf8String, title))
+ return;
- if (rw->title)
- free (rw->title);
-
- rw->title = regexGetWindowTitle (w);
-
- (*d->matchPropertyChanged) (d, w);
- }
- }
- if (event->xproperty.atom == rd->roleAtom)
- {
- w = findWindowAtDisplay (d, event->xproperty.window);
- if (w)
- {
- REGEX_WINDOW (w);
-
- if (rw->role)
- free (rw->role);
-
- rw->role = regexGetStringProperty (w, rd->roleAtom, XA_STRING);
-
- (*d->matchPropertyChanged) (d, w);
- }
- }
- else if (event->xproperty.atom == XA_WM_CLASS)
- {
- w = findWindowAtDisplay (d, event->xproperty.window);
- if (w)
- (*d->matchPropertyChanged) (d, w);
- }
- }
+ getStringProperty (XA_WM_NAME, XA_STRING, title);
}
-static Bool
-regexRegisterExpHandler (void *closure)
+void RegexWindow::updateClass ()
{
- CompDisplay *display = (CompDisplay *) closure;
+ XClassHint classHint;
- (*display->matchExpHandlerChanged) (display);
+ resClass = "";
+ resName = "";
- return FALSE;
-}
-
-static Bool
-regexInitDisplay (CompPlugin *p,
- CompDisplay *d)
-{
- RegexDisplay *rd;
-
- if (!checkPluginABI ("core", CORE_ABIVERSION))
- return FALSE;
+ if (!XGetClassHint (screen->dpy (), window->id (), &classHint) != Success)
+ return;
- rd = malloc (sizeof (RegexDisplay));
- if (!rd)
- return FALSE;
-
- rd->screenPrivateIndex = allocateScreenPrivateIndex (d);
- if (rd->screenPrivateIndex < 0)
+ if (classHint.res_name)
{
- free (rd);
- return FALSE;
+ resName = classHint.res_name;
+ XFree (classHint.res_name);
}
- rd->roleAtom = XInternAtom (d->display, "WM_WINDOW_ROLE", 0);
- rd->visibleNameAtom = XInternAtom (d->display, "_NET_WM_VISIBLE_NAME", 0);
-
- WRAP (rd, d, handleEvent, regexHandleEvent);
- WRAP (rd, d, matchInitExp, regexMatchInitExp);
-
- d->base.privates[displayPrivateIndex].ptr = rd;
-
- /* one shot timeout to which will register the expression handler
- after all screens and windows have been initialized */
- compAddTimeout (0, 0, regexRegisterExpHandler, (void *) d);
-
- return TRUE;
-}
-
-static void
-regexFiniDisplay (CompPlugin *p,
- CompDisplay *d)
-{
- REGEX_DISPLAY (d);
-
- freeScreenPrivateIndex (d, rd->screenPrivateIndex);
-
- UNWRAP (rd, d, handleEvent);
- UNWRAP (rd, d, matchInitExp);
-
- if (d->base.parent)
- (*d->matchExpHandlerChanged) (d);
-
- free (rd);
-}
-
-static Bool
-regexInitScreen (CompPlugin *p,
- CompScreen *s)
-{
- RegexScreen *rs;
-
- REGEX_DISPLAY (s->display);
-
- rs = malloc (sizeof (RegexScreen));
- if (!rs)
- return FALSE;
-
- rs->windowPrivateIndex = allocateWindowPrivateIndex (s);
- if (rs->windowPrivateIndex < 0)
+ if (classHint.res_class)
{
- free (rs);
- return FALSE;
+ resClass = classHint.res_class;
+ XFree (classHint.res_class);
}
-
- s->base.privates[rd->screenPrivateIndex].ptr = rs;
-
- return TRUE;
-}
-
-static void
-regexFiniScreen (CompPlugin *p,
- CompScreen *s)
-{
- REGEX_SCREEN (s);
-
- freeWindowPrivateIndex (s, rs->windowPrivateIndex);
-
- free (rs);
}
-static Bool
-regexInitWindow (CompPlugin *p,
- CompWindow *w)
+void
+RegexScreen::handleEvent (XEvent *event)
{
- RegexWindow *rw;
-
- REGEX_DISPLAY (w->screen->display);
- REGEX_SCREEN (w->screen);
+ CompWindow *w;
- rw = malloc (sizeof (RegexWindow));
- if (!rw)
- return FALSE;
+ screen->handleEvent (event);
- rw->title = regexGetWindowTitle (w);
- rw->role = regexGetStringProperty (w, rd->roleAtom, XA_STRING);
+ if (event->type != PropertyNotify)
+ return;
- w->base.privates[rs->windowPrivateIndex].ptr = rw;
+ w = screen->findWindow (event->xproperty.window);
+ if (!w)
+ return;
- return TRUE;
+ if (event->xproperty.atom == XA_WM_NAME)
+ {
+ RegexWindow::get (w)->updateTitle ();
+ screen->matchPropertyChanged (w);
+ }
+ else if (event->xproperty.atom == roleAtom)
+ {
+ RegexWindow::get (w)->updateRole ();
+ screen->matchPropertyChanged (w);
+ }
+ else if (event->xproperty.atom == XA_WM_CLASS)
+ {
+ RegexWindow::get (w)->updateClass ();
+ screen->matchPropertyChanged (w);
+ }
}
-static void
-regexFiniWindow (CompPlugin *p,
- CompWindow *w)
+RegexScreen::RegexScreen (CompScreen *s) :
+ PrivateHandler<RegexScreen, CompScreen> (s)
{
- REGEX_WINDOW (w);
-
- if (rw->title)
- free (rw->title);
+ ScreenInterface::setHandler (s);
- if (rw->role)
- free (rw->role);
+ roleAtom = XInternAtom (s->dpy (), "WM_WINDOW_ROLE", 0);
+ visibleNameAtom = XInternAtom (s->dpy (), "_NET_WM_VISIBLE_NAME", 0);
- free (rw);
+ s->matchExpHandlerChanged ();
}
-static CompBool
-regexInitObject (CompPlugin *p,
- CompObject *o)
+RegexScreen::~RegexScreen ()
{
- static InitPluginObjectProc dispTab[] = {
- (InitPluginObjectProc) 0, /* InitCore */
- (InitPluginObjectProc) regexInitDisplay,
- (InitPluginObjectProc) regexInitScreen,
- (InitPluginObjectProc) regexInitWindow
- };
-
- RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), TRUE, (p, o));
+ screen->matchInitExpSetEnabled (this, false);
+ screen->matchExpHandlerChanged ();
}
-static void
-regexFiniObject (CompPlugin *p,
- CompObject *o)
+RegexWindow::RegexWindow (CompWindow *w) :
+ PrivateHandler<RegexWindow, CompWindow> (w),
+ window (w)
{
- static FiniPluginObjectProc dispTab[] = {
- (FiniPluginObjectProc) 0, /* FiniCore */
- (FiniPluginObjectProc) regexFiniDisplay,
- (FiniPluginObjectProc) regexFiniScreen,
- (FiniPluginObjectProc) regexFiniWindow
- };
-
- DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), (p, o));
+ updateRole ();
+ updateTitle ();
+ updateClass ();
}
-static Bool
-regexInit (CompPlugin *p)
+bool
+RegexPluginVTable::init ()
{
- if (!compInitPluginMetadataFromInfo (&regexMetadata, p->vTable->name,
- 0, 0, 0, 0))
- return FALSE;
+ if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
+ return false;
- displayPrivateIndex = allocateDisplayPrivateIndex ();
- if (displayPrivateIndex < 0)
- {
- compFiniMetadata (&regexMetadata);
- return FALSE;
- }
-
- compAddMetadataFromFile (&regexMetadata, p->vTable->name);
-
- return TRUE;
-}
-
-static void
-regexFini (CompPlugin *p)
-{
- freeDisplayPrivateIndex (displayPrivateIndex);
- compFiniMetadata (&regexMetadata);
-}
-
-static CompMetadata *
-regexGetMetadata (CompPlugin *plugin)
-{
- return &regexMetadata;
-}
+ getMetadata ()->addFromFile (name ());
-static CompPluginVTable regexVTable = {
- "regex",
- regexGetMetadata,
- regexInit,
- regexFini,
- regexInitObject,
- regexFiniObject,
- 0, /* GetObjectOptions */
- 0 /* SetObjectOption */
-};
-
-CompPluginVTable *
-getCompPluginInfo20070830 (void)
-{
- return &regexVTable;
+ return true;
}
diff --git a/plugins/regexplugin.h b/plugins/regexplugin.h
new file mode 100644
index 0000000..49c4ea6
--- /dev/null
+++ b/plugins/regexplugin.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright © 2007 Novell, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Novell, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Novell, Inc. makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: David Reveman <davidr@novell.com>
+ */
+
+#include <regex.h>
+#include <X11/Xatom.h>
+
+#include <core/core.h>
+#include <core/atoms.h>
+#include <core/privatehandler.h>
+
+class RegexScreen :
+ public PrivateHandler<RegexScreen, CompScreen>,
+ public ScreenInterface
+{
+ public:
+ RegexScreen (CompScreen *s);
+ ~RegexScreen ();
+
+ void handleEvent (XEvent *event);
+
+ CompMatch::Expression * matchInitExp (const CompString& value);
+
+ Atom roleAtom;
+ Atom visibleNameAtom;
+};
+
+class RegexWindow :
+ public PrivateHandler<RegexWindow, CompWindow>
+{
+ public:
+ RegexWindow (CompWindow *w);
+
+ void updateRole ();
+ void updateTitle ();
+ void updateClass ();
+ bool getStringProperty (Atom nameAtom, Atom typeAtom,
+ CompString& string);
+
+ CompString role;
+ CompString title;
+ CompString resName;
+ CompString resClass;
+
+ CompWindow *window;
+};
+
+class RegexPluginVTable :
+ public CompPlugin::VTableForScreenAndWindow<RegexScreen, RegexWindow>
+{
+ public:
+ bool init ();
+};
diff --git a/plugins/scale/privates.h b/plugins/scale/privates.h
index 15321ae..972669a 100644
--- a/plugins/scale/privates.h
+++ b/plugins/scale/privates.h
@@ -105,7 +105,7 @@ class PrivateScaleScreen :
void activateEvent (bool activating);
- void layoutSlotsForArea (CompRect, int);
+ void layoutSlotsForArea (const CompRect&, int);
void layoutSlots ();
void findBestSlots ();
bool fillInWindows ();
diff --git a/plugins/scale/scale.cpp b/plugins/scale/scale.cpp
index 23fdd8b..2ae42a8 100644
--- a/plugins/scale/scale.cpp
+++ b/plugins/scale/scale.cpp
@@ -49,7 +49,6 @@ class ScalePluginVTable :
public:
bool init ();
-
void fini ();
PLUGIN_OPTION_HELPER (ScaleScreen)
@@ -63,7 +62,8 @@ PrivateScaleWindow::isNeverScaleWin () const
if (window->overrideRedirect ())
return true;
- if (window->wmType () & (CompWindowTypeDockMask | CompWindowTypeDesktopMask))
+ if (window->wmType () & (CompWindowTypeDockMask |
+ CompWindowTypeDesktopMask))
return true;
return false;
@@ -124,24 +124,24 @@ PrivateScaleScreen::activateEvent (bool activating)
}
void
-ScaleWindowInterface::scalePaintDecoration (const GLWindowPaintAttrib &attrib,
- const GLMatrix &transform,
- const CompRegion &region,
- unsigned int mask)
+ScaleWindowInterface::scalePaintDecoration (const GLWindowPaintAttrib& attrib,
+ const GLMatrix& transform,
+ const CompRegion& region,
+ unsigned int mask)
WRAPABLE_DEF (scalePaintDecoration, attrib, transform, region, mask)
void
-ScaleWindow::scalePaintDecoration (const GLWindowPaintAttrib &attrib,
- const GLMatrix &transform,
- const CompRegion &region, unsigned int mask)
+ScaleWindow::scalePaintDecoration (const GLWindowPaintAttrib& attrib,
+ const GLMatrix& transform,
+ const CompRegion& region,
+ unsigned int mask)
{
- WRAPABLE_HND_FUNC(0, scalePaintDecoration, attrib, transform,
- region, mask)
+ WRAPABLE_HND_FUNC(0, scalePaintDecoration, attrib, transform, region, mask)
if (priv->spScreen->opt[SCALE_OPTION_ICON].value ().i () != SCALE_ICON_NONE)
{
GLWindowPaintAttrib sAttrib (attrib);
- GLTexture *icon;
+ GLTexture *icon;
icon = priv->gWindow->getIcon (96, 96);
if (!icon)
@@ -167,7 +167,7 @@ ScaleWindow::scalePaintDecoration (const GLWindowPaintAttrib &attrib,
default:
sAttrib.opacity /= 3;
scale = MIN (((float) scaledWinWidth / icon->width ()),
- ((float) scaledWinHeight / icon->height ()));
+ ((float) scaledWinHeight / icon->height ()));
break;
}
@@ -192,20 +192,18 @@ ScaleWindow::scalePaintDecoration (const GLWindowPaintAttrib &attrib,
if (priv->slot)
{
- priv->delta =
- fabs (priv->slot->x1 - priv->window->x ()) +
- fabs (priv->slot->y1 - priv->window->y ()) +
- fabs (1.0f - priv->slot->scale) * 500.0f;
+ priv->delta = fabs (priv->slot->x1 - priv->window->x ()) +
+ fabs (priv->slot->y1 - priv->window->y ()) +
+ fabs (1.0f - priv->slot->scale) * 500.0f;
}
if (priv->delta)
{
float o;
- ds =
- fabs (priv->tx) +
- fabs (priv->ty) +
- fabs (1.0f - priv->scale) * 500.0f;
+ ds = fabs (priv->tx) +
+ fabs (priv->ty) +
+ fabs (1.0f - priv->scale) * 500.0f;
if (ds > priv->delta)
ds = priv->delta;
@@ -230,18 +228,19 @@ ScaleWindow::scalePaintDecoration (const GLWindowPaintAttrib &attrib,
mask |= PAINT_WINDOW_BLEND_MASK;
- CompRegion iconReg (0, 0, width, height);
+ CompRegion iconReg (0, 0, width, height);
GLTexture::MatrixList ml (1);
- ml[0] = icon->matrix ();
+ ml[0] = icon->matrix ();
priv->gWindow->geometry().reset ();
+
if (width && height)
priv->gWindow->glAddGeometry (ml, iconReg, iconReg);
if (priv->gWindow->geometry().vCount)
{
GLFragment::Attrib fragment (sAttrib);
- GLMatrix wTransform (transform);
+ GLMatrix wTransform (transform);
wTransform.scale (scale, scale, 1.0f);
wTransform.translate (x / scale, y / scale, 0.0f);
@@ -258,12 +257,11 @@ ScaleWindow::scalePaintDecoration (const GLWindowPaintAttrib &attrib,
}
bool
-ScaleWindowInterface::setScaledPaintAttributes (GLWindowPaintAttrib &attrib)
+ScaleWindowInterface::setScaledPaintAttributes (GLWindowPaintAttrib& attrib)
WRAPABLE_DEF (setScaledPaintAttributes, attrib)
-
bool
-ScaleWindow::setScaledPaintAttributes (GLWindowPaintAttrib &attrib)
+ScaleWindow::setScaledPaintAttributes (GLWindowPaintAttrib& attrib)
{
WRAPABLE_HND_FUNC_RETURN (1, bool, setScaledPaintAttributes, attrib)
@@ -293,14 +291,15 @@ ScaleWindow::setScaledPaintAttributes (GLWindowPaintAttrib &attrib)
that are not in scale mode */
if (!priv->isNeverScaleWin ())
{
- int moMode;
- moMode = priv->spScreen->opt[SCALE_OPTION_MULTIOUTPUT_MODE].
- value ().i ();
+ int opt, moMode, output;
+
+ opt = SCALE_OPTION_MULTIOUTPUT_MODE;
+ moMode = priv->spScreen->opt[opt].value ().i ();
switch (moMode) {
case SCALE_MOMODE_CURRENT:
- if (priv->window->outputDevice () ==
- screen->currentOutputDev ().id ())
+ output = screen->currentOutputDev ().id ();
+ if (priv->window->outputDevice () == output)
attrib.opacity = 0;
break;
default:
@@ -314,10 +313,10 @@ ScaleWindow::setScaledPaintAttributes (GLWindowPaintAttrib &attrib)
}
bool
-PrivateScaleWindow::glPaint (const GLWindowPaintAttrib &attrib,
- const GLMatrix &transform,
- const CompRegion &region,
- unsigned int mask)
+PrivateScaleWindow::glPaint (const GLWindowPaintAttrib& attrib,
+ const GLMatrix& transform,
+ const CompRegion& region,
+ unsigned int mask)
{
bool status;
@@ -336,7 +335,7 @@ PrivateScaleWindow::glPaint (const GLWindowPaintAttrib &attrib,
if (scaled)
{
GLFragment::Attrib fragment (gWindow->lastPaintAttrib ());
- GLMatrix wTransform (transform);
+ GLMatrix wTransform (transform);
if (mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK)
return false;
@@ -376,7 +375,8 @@ PrivateScaleWindow::compareWindowsDistance (ScaleWindow *w1,
}
void
-PrivateScaleScreen::layoutSlotsForArea (CompRect workArea, int nWindows)
+PrivateScaleScreen::layoutSlotsForArea (const CompRect& workArea,
+ int nWindows)
{
int i, j;
int x, y, width, height;
@@ -395,8 +395,7 @@ PrivateScaleScreen::layoutSlotsForArea (CompRect workArea, int nWindows)
for (i = 0; i < lines; i++)
{
- n = MIN (nWindows - nSlots,
- ceilf ((float)nWindows / lines));
+ n = MIN (nWindows - nSlots, ceilf ((float) nWindows / lines));
x = workArea.x () + spacing;
width = (workArea.width () - (n + 1) * spacing) / n;
@@ -423,7 +422,7 @@ PrivateScaleScreen::layoutSlotsForArea (CompRect workArea, int nWindows)
SlotArea::vector
PrivateScaleScreen::getSlotAreas ()
{
- int i;
+ int i = 0;
CompRect workArea;
std::vector<float> size;
float sizePerWindow, sum = 0.0f;
@@ -435,7 +434,6 @@ PrivateScaleScreen::getSlotAreas ()
left = windows.size ();
- i = 0;
foreach (CompOutput &o, screen->outputDevs ())
{
/* determine the size of the workarea for each output device */
@@ -500,7 +498,6 @@ PrivateScaleScreen::layoutSlots ()
if (screen->outputDevs ().size () == 1)
moMode = SCALE_MOMODE_CURRENT;
-
nSlots = 0;
switch (moMode)
@@ -509,11 +506,8 @@ PrivateScaleScreen::layoutSlots ()
{
SlotArea::vector slotAreas = getSlotAreas ();
if (slotAreas.size ())
- {
foreach (SlotArea &sa, slotAreas)
- layoutSlotsForArea (sa.workArea,
- sa.nWindows);
- }
+ layoutSlotsForArea (sa.workArea, sa.nWindows);
}
break;
case SCALE_MOMODE_CURRENT:
@@ -530,7 +524,7 @@ void
PrivateScaleScreen::findBestSlots ()
{
CompWindow *w;
- int i, j, d, d0 = 0;
+ int i, d, d0 = 0;
float sx, sy, cx, cy;
foreach (ScaleWindow *sw, windows)
@@ -543,12 +537,12 @@ PrivateScaleScreen::findBestSlots ()
sw->priv->sid = 0;
sw->priv->distance = MAXSHORT;
- for (j = 0; j < nSlots; j++)
+ for (i = 0; i < nSlots; i++)
{
- if (!slots[j].filled)
+ if (!slots[i].filled)
{
- sx = (slots[j].x2 + slots[j].x1) / 2;
- sy = (slots[j].y2 + slots[j].y1) / 2;
+ sx = (slots[i].x2 + slots[i].x1) / 2;
+ sy = (slots[i].y2 + slots[i].y1) / 2;
cx = w->serverX () + w->width () / 2;
cy = w->serverY () + w->height () / 2;
@@ -559,7 +553,7 @@ PrivateScaleScreen::findBestSlots ()
d = sqrt (cx * cx + cy * cy);
if (d0 + d < sw->priv->distance)
{
- sw->priv->sid = j;
+ sw->priv->sid = i;
sw->priv->distance = d0 + d;
}
}
@@ -638,7 +632,6 @@ ScaleScreen::layoutSlotsAndAssignWindows ()
/* sort windows, window with closest distance to a slot first */
priv->windows.sort (PrivateScaleWindow::compareWindowsDistance);
-
} while (priv->fillInWindows ());
return true;
@@ -765,20 +758,16 @@ PrivateScaleWindow::adjustScaleVelocity ()
}
bool
-PrivateScaleScreen::glPaintOutput (const GLScreenPaintAttrib &sAttrib,
- const GLMatrix &transform,
- const CompRegion &region,
- CompOutput *output,
- unsigned int mask)
+PrivateScaleScreen::glPaintOutput (const GLScreenPaintAttrib& sAttrib,
+ const GLMatrix& transform,
+ const CompRegion& region,
+ CompOutput *output,
+ unsigned int mask)
{
- bool status;
-
if (state != ScaleScreen::Idle)
mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK;
- status = gScreen->glPaintOutput (sAttrib, transform, region, output, mask);
-
- return status;
+ return gScreen->glPaintOutput (sAttrib, transform, region, output, mask);
}
void
@@ -786,15 +775,16 @@ PrivateScaleScreen::preparePaint (int msSinceLastPaint)
{
if (state != ScaleScreen::Idle && state != ScaleScreen::Wait)
{
- int steps;
- float amount, chunk;
+ int steps;
+ float amount, chunk;
amount = msSinceLastPaint * 0.05f *
- opt[SCALE_OPTION_SPEED].value ().f ();
- steps = amount /
- (0.5f * opt[SCALE_OPTION_TIMESTEP].value ().f ());
- if (!steps) steps = 1;
- chunk = amount / (float) steps;
+ opt[SCALE_OPTION_SPEED].value ().f ();
+ steps = amount / (0.5f * opt[SCALE_OPTION_TIMESTEP].value ().f ());
+
+ if (!steps)
+ steps = 1;
+ chunk = amount / (float) steps;
while (steps--)
{
@@ -865,7 +855,7 @@ PrivateScaleScreen::donePaint ()
ScaleWindow *
PrivateScaleScreen::checkForWindowAt (int x, int y)
{
- int x1, y1, x2, y2;
+ int x1, y1, x2, y2;
CompWindowList::reverse_iterator rit = screen->windows ().rbegin ();
for (; rit != screen->windows ().rend (); rit++)
@@ -877,8 +867,10 @@ PrivateScaleScreen::checkForWindowAt (int x, int y)
{
x1 = w->x () - w->input ().left * sw->priv->scale;
y1 = w->y () - w->input ().top * sw->priv->scale;
- x2 = w->x () + (w->width () + w->input ().right) * sw->priv->scale;
- y2 = w->y () + (w->height () + w->input ().bottom) * sw->priv->scale;
+ x2 = w->x () +
+ (w->width () + w->input ().right) * sw->priv->scale;
+ y2 = w->y () +
+ (w->height () + w->input ().bottom) * sw->priv->scale;
x1 += sw->priv->tx;
y1 += sw->priv->ty;
@@ -919,72 +911,67 @@ PrivateScaleScreen::scaleTerminate (CompAction *action,
CompAction::State state,
CompOption::Vector &options)
{
- CompScreen *s;
- Window xid;
-
- xid = CompOption::getIntOptionNamed (options, "root");
+ Window xid;
- if (!xid || ::screen->root () == xid)
- {
- SCALE_SCREEN (::screen);
+ action->setState (action->state () & ~(CompAction::StateTermKey |
+ CompAction::StateTermButton));
- if (ss->priv->grab)
- {
- if (ss->priv->grabIndex)
- {
- ::screen->removeGrab (ss->priv->grabIndex, 0);
- ss->priv->grabIndex = 0;
- }
+ xid = CompOption::getIntOptionNamed (options, "root");
+ if (xid && ::screen->root () != xid)
+ return false;
- if (ss->priv->dndTarget)
- XUnmapWindow (::screen->dpy (), ss->priv->dndTarget);
+ SCALE_SCREEN (::screen);
- ss->priv->grab = false;
+ if (!ss->priv->grab)
+ return false;
- if (ss->priv->state != ScaleScreen::Idle)
- {
- foreach (CompWindow *w, ::screen->windows ())
- {
- SCALE_WINDOW (w);
+ if (ss->priv->grabIndex)
+ {
+ ::screen->removeGrab (ss->priv->grabIndex, 0);
+ ss->priv->grabIndex = 0;
+ }
- if (sw->priv->slot)
- {
- sw->priv->slot = NULL;
- sw->priv->adjust = true;
- }
- }
+ if (ss->priv->dndTarget)
+ XUnmapWindow (::screen->dpy (), ss->priv->dndTarget);
- if (state & CompAction::StateCancel)
- {
- if (::screen->activeWindow () !=
- ss->priv->previousActiveWindow)
- {
- CompWindow *w =
- ::screen->findWindow (ss->priv->previousActiveWindow);
- if (w)
- w->moveInputFocusTo ();
- }
- }
- else if (ss->priv->state != ScaleScreen::In)
- {
- CompWindow *w =
- ::screen->findWindow (ss->priv->selectedWindow);
- if (w)
- w->activate ();
- }
+ ss->priv->grab = false;
- ss->priv->state = ScaleScreen::In;
+ if (ss->priv->state != ScaleScreen::Idle)
+ {
+ foreach (CompWindow *w, ::screen->windows ())
+ {
+ SCALE_WINDOW (w);
- ss->priv->cScreen->damageScreen ();
+ if (sw->priv->slot)
+ {
+ sw->priv->slot = NULL;
+ sw->priv->adjust = true;
}
+ }
- ss->priv->lastActiveNum = 0;
+ if (state & CompAction::StateCancel)
+ {
+ if (::screen->activeWindow () != ss->priv->previousActiveWindow)
+ {
+ CompWindow *w;
+
+ w = ::screen->findWindow (ss->priv->previousActiveWindow);
+ if (w)
+ w->moveInputFocusTo ();
+ }
}
+ else if (ss->priv->state != ScaleScreen::In)
+ {
+ CompWindow *w = ::screen->findWindow (ss->priv->selectedWindow);
+ if (w)
+ w->activate ();
+ }
+
+ ss->priv->state = ScaleScreen::In;
+ ss->priv->cScreen->damageScreen ();
}
- action->setState (action->state () &
- ~(CompAction::StateTermKey |
- CompAction::StateTermButton));
+ ss->priv->lastActiveNum = 0;
return false;
}
@@ -1040,7 +1027,9 @@ PrivateScaleScreen::scaleInitiate (CompAction *action,
else if (state & EDGE_STATE)
{
if (ss->priv->type == type)
- return scaleTerminate (action, CompAction::StateCancel, options);
+ return scaleTerminate (action,
+ CompAction::StateCancel,
+ options);
}
}
@@ -1151,7 +1140,9 @@ ScaleWindow::hasSlot () const
}
bool
-PrivateScaleScreen::selectWindowAt (int x, int y, bool moveInputFocus)
+PrivateScaleScreen::selectWindowAt (int x,
+ int y,
+ bool moveInputFocus)
{
ScaleWindow *w = checkForWindowAt (x, y);
if (w && w->priv->isScaleWin ())
@@ -1177,7 +1168,8 @@ PrivateScaleScreen::selectWindowAt (int x, int y, bool moveInputFocus)
}
void
-PrivateScaleScreen::moveFocusWindow (int dx, int dy)
+PrivateScaleScreen::moveFocusWindow (int dx,
+ int dy)
{
CompWindow *active;
CompWindow *focus = NULL;
@@ -1260,50 +1252,48 @@ ScaleScreen::relayoutSlots (const CompMatch& match)
{
priv->state = ScaleScreen::Out;
priv->moveFocusWindow (0, 0);
- priv->cScreen->damageScreen ();
}
+
+ priv->cScreen->damageScreen ();
}
void
PrivateScaleScreen::windowRemove (Window id)
{
CompWindow *w = screen->findWindow (id);
- if (w)
+ if (!w)
+ return;
+
+ if (state != ScaleScreen::Idle && state != ScaleScreen::In)
+ return;
+
+ foreach (ScaleWindow *lw, windows)
{
- if (state != ScaleScreen::Idle && state != ScaleScreen::In)
+ if (lw->priv->window == w)
{
- foreach (ScaleWindow *lw, windows)
+ if (layoutThumbs ())
{
- if (lw->priv->window == w)
- {
- if (layoutThumbs ())
- {
- state = ScaleScreen::Out;
- cScreen->damageScreen ();
- break;
- }
- else
- {
-
- CompOption::Vector o (0);
- CompAction *action;
+ state = ScaleScreen::Out;
+ cScreen->damageScreen ();
+ break;
+ }
+ else
+ {
+ CompOption::Vector o (0);
+ CompAction *action;
- /* terminate scale mode if the recently closed
- * window was the last scaled window */
+ /* terminate scale mode if the recently closed
+ * window was the last scaled window */
- o.push_back (CompOption ("root", CompOption::TypeInt));
- o[0].value ().set ((int) screen->root ());
+ o.push_back (CompOption ("root", CompOption::TypeInt));
+ o[0].value ().set ((int) screen->root ());
- action =
- &opt[SCALE_OPTION_INITIATE_EDGE].value ().action ();
- scaleTerminate (action, CompAction::StateCancel, o);
+ action = &opt[SCALE_OPTION_INITIATE_EDGE].value ().action ();
+ scaleTerminate (action, CompAction::StateCancel, o);
- action =
- &opt[SCALE_OPTION_INITIATE_KEY].value ().action ();
- scaleTerminate (action, CompAction::StateCancel, o);
- break;
- }
- }
+ action = &opt[SCALE_OPTION_INITIATE_KEY].value ().action ();
+ scaleTerminate (action, CompAction::StateCancel, o);
+ break;
}
}
}
@@ -1314,9 +1304,9 @@ PrivateScaleScreen::hoverTimeout ()
{
if (grab && state != ScaleScreen::In)
{
- CompWindow *w;
+ CompWindow *w;
CompOption::Vector o (0);
- int option;
+ int option;
w = screen->findWindow (selectedWindow);
if (w)
@@ -1342,7 +1332,6 @@ PrivateScaleScreen::hoverTimeout ()
void
PrivateScaleScreen::handleEvent (XEvent *event)
{
-
switch (event->type) {
case KeyPress:
if (screen->root () == event->xkey.root)
@@ -1361,67 +1350,55 @@ PrivateScaleScreen::handleEvent (XEvent *event)
}
break;
case ButtonPress:
- if (event->xbutton.button == Button1)
+ if (event->xbutton.button == Button1 &&
+ screen->root () == event->xbutton.root &&
+ grabIndex &&
+ state != ScaleScreen::In)
{
- if (screen->root () == event->xbutton.root)
- {
- int option;
+ XButtonEvent *button = &event->xbutton;
+ int option;
+ CompOption::Vector o (0);
- if (grabIndex && state != ScaleScreen::In)
- {
- CompOption::Vector o (0);
- o.push_back (CompOption ("root", CompOption::TypeInt));
- o[0].value ().set ((int) screen->root ());
+ o.push_back (CompOption ("root", CompOption::TypeInt));
+ o[0].value ().set ((int) screen->root ());
+ if (selectWindowAt (button->x_root, button->y_root, true))
+ {
+ option = SCALE_OPTION_INITIATE_EDGE;
+ scaleTerminate (&opt[option].value ().action (), 0, o);
+ option = SCALE_OPTION_INITIATE_KEY;
+ scaleTerminate (&opt[option].value ().action (), 0, o);
+ }
+ else if (opt[SCALE_OPTION_SHOW_DESKTOP].value ().b ())
+ {
+ CompPoint pointer (button->x_root, button->y_root);
+ CompRect workArea (screen->workArea ());
- if (selectWindowAt (event->xbutton.x_root,
- event->xbutton.y_root,
- true))
- {
- option = SCALE_OPTION_INITIATE_EDGE;
- scaleTerminate (&opt[option].value ().action (),
- 0, o);
- option = SCALE_OPTION_INITIATE_KEY;
- scaleTerminate (&opt[option].value ().action (),
- 0, o);
- }
- else if (event->xbutton.x_root > screen->workArea ().x &&
- event->xbutton.x_root < (screen->workArea ().x +
- screen->workArea ().width) &&
- event->xbutton.y_root > screen->workArea ().y &&
- event->xbutton.y_root < (screen->workArea ().y +
- screen->workArea ().height))
- {
- if (opt[SCALE_OPTION_SHOW_DESKTOP].value ().b ())
- {
- option = SCALE_OPTION_INITIATE_EDGE;
- scaleTerminate (&opt[option].value ().action (),
- 0, o);
- option = SCALE_OPTION_INITIATE_KEY;
- scaleTerminate (&opt[option].value ().action (),
- 0, o);
- screen->enterShowDesktopMode ();
- }
- }
+ if (workArea.contains (pointer))
+ {
+ option = SCALE_OPTION_INITIATE_EDGE;
+ scaleTerminate (&opt[option].value ().action (), 0, o);
+ option = SCALE_OPTION_INITIATE_KEY;
+ scaleTerminate (&opt[option].value ().action (), 0, o);
+ screen->enterShowDesktopMode ();
}
}
}
break;
case MotionNotify:
- if (screen->root () == event->xmotion.root)
+ if (screen->root () == event->xmotion.root &&
+ grabIndex &&
+ state != ScaleScreen::In)
{
- if (grabIndex && state != ScaleScreen::In)
- {
- bool focus = false;
- CompOption *o = screen->getOption ("click_to_focus");
+ bool focus = false;
+ CompOption *o = screen->getOption ("click_to_focus");
- if (o && o->value ().b ())
- focus = true;
+ if (o && o->value ().b ())
+ focus = true;
- selectWindowAt (event->xmotion.x_root,
- event->xmotion.y_root,
- focus);
- }
+ selectWindowAt (event->xmotion.x_root,
+ event->xmotion.y_root,
+ focus);
}
break;
case ClientMessage:
@@ -1432,7 +1409,7 @@ PrivateScaleScreen::handleEvent (XEvent *event)
w = screen->findWindow (event->xclient.window);
if (w)
{
- bool focus = false;
+ bool focus = false;
CompOption *o = screen->getOption ("click_to_focus");
if (o && o->value ().b ())
@@ -1458,15 +1435,11 @@ PrivateScaleScreen::handleEvent (XEvent *event)
if (hover.active ())
{
if (w->id () != selectedWindow)
- {
hover.stop ();
- }
}
if (!hover.active ())
- hover.start (boost::bind (&PrivateScaleScreen::hoverTimeout, this),
- time, (float) time * 1.2);
-
+ hover.start (time, (float) time * 1.2);
selectWindowAt (x, y, focus);
}
@@ -1479,7 +1452,7 @@ PrivateScaleScreen::handleEvent (XEvent *event)
}
}
else if (event->xclient.message_type == Atoms::xdndDrop ||
- event->xclient.message_type == Atoms::xdndLeave)
+ event->xclient.message_type == Atoms::xdndLeave)
{
CompWindow *w = screen->findWindow (event->xclient.window);
if (w)
@@ -1515,11 +1488,11 @@ PrivateScaleScreen::handleEvent (XEvent *event)
windowRemove (event->xdestroywindow.window);
break;
}
-
}
bool
-PrivateScaleWindow::damageRect (bool initial, const CompRect &rect)
+PrivateScaleWindow::damageRect (bool initial,
+ const CompRect& rect)
{
bool status = false;
@@ -1549,33 +1522,34 @@ PrivateScaleWindow::damageRect (bool initial, const CompRect &rect)
return status;
}
-#define SCALEBIND(a) boost::bind (PrivateScaleScreen::scaleInitiate, _1, _2, _3, a)
+#define SCALEBIND(a) \
+ boost::bind (PrivateScaleScreen::scaleInitiate, _1, _2, _3, a)
static const CompMetadata::OptionInfo scaleOptionInfo[] = {
{ "initiate_edge", "edge", 0,
- SCALEBIND(ScaleTypeNormal), PrivateScaleScreen::scaleTerminate },
+ SCALEBIND (ScaleTypeNormal), PrivateScaleScreen::scaleTerminate },
{ "initiate_button", "button", 0,
- SCALEBIND(ScaleTypeNormal), PrivateScaleScreen::scaleTerminate },
+ SCALEBIND (ScaleTypeNormal), PrivateScaleScreen::scaleTerminate },
{ "initiate_key", "key", 0,
- SCALEBIND(ScaleTypeNormal), PrivateScaleScreen::scaleTerminate },
+ SCALEBIND (ScaleTypeNormal), PrivateScaleScreen::scaleTerminate },
{ "initiate_all_edge", "edge", 0,
- SCALEBIND(ScaleTypeAll), PrivateScaleScreen::scaleTerminate },
+ SCALEBIND (ScaleTypeAll), PrivateScaleScreen::scaleTerminate },
{ "initiate_all_button", "button", 0,
- SCALEBIND(ScaleTypeAll), PrivateScaleScreen::scaleTerminate },
+ SCALEBIND (ScaleTypeAll), PrivateScaleScreen::scaleTerminate },
{ "initiate_all_key", "key", 0,
- SCALEBIND(ScaleTypeAll), PrivateScaleScreen::scaleTerminate },
+ SCALEBIND (ScaleTypeAll), PrivateScaleScreen::scaleTerminate },
{ "initiate_group_edge", "edge", 0,
- SCALEBIND(ScaleTypeGroup), PrivateScaleScreen::scaleTerminate },
+ SCALEBIND (ScaleTypeGroup), PrivateScaleScreen::scaleTerminate },
{ "initiate_group_button", "button", 0,
- SCALEBIND(ScaleTypeGroup), PrivateScaleScreen::scaleTerminate },
+ SCALEBIND (ScaleTypeGroup), PrivateScaleScreen::scaleTerminate },
{ "initiate_group_key", "key", 0,
- SCALEBIND(ScaleTypeGroup), PrivateScaleScreen::scaleTerminate },
+ SCALEBIND (ScaleTypeGroup), PrivateScaleScreen::scaleTerminate },
{ "initiate_output_edge", "edge", 0,
- SCALEBIND(ScaleTypeOutput), PrivateScaleScreen::scaleTerminate },
+ SCALEBIND (ScaleTypeOutput), PrivateScaleScreen::scaleTerminate },
{ "initiate_output_button", "button", 0,
- SCALEBIND(ScaleTypeOutput), PrivateScaleScreen::scaleTerminate },
+ SCALEBIND (ScaleTypeOutput), PrivateScaleScreen::scaleTerminate },
{ "initiate_output_key", "key", 0,
- SCALEBIND(ScaleTypeOutput), PrivateScaleScreen::scaleTerminate },
+ SCALEBIND (ScaleTypeOutput), PrivateScaleScreen::scaleTerminate },
{ "show_desktop", "bool", 0, 0, 0 },
{ "spacing", "int", "<min>0</min>", 0, 0 },
{ "speed", "float", "<min>0.1</min>", 0, 0 },
@@ -1646,6 +1620,7 @@ PrivateScaleScreen::PrivateScaleScreen (CompScreen *s) :
opacity = (OPAQUE * opt[SCALE_OPTION_OPACITY].value ().i ()) / 100;
+ hover.setCallback (boost::bind (&PrivateScaleScreen::hoverTimeout, this));
ScreenInterface::setHandler (s);
CompositeScreenInterface::setHandler (cScreen, false);
@@ -1698,8 +1673,7 @@ ScaleScreen::getOptions ()
CompOption *
ScaleScreen::getOption (const char *name)
{
- CompOption *o = CompOption::findOption (priv->opt, name);
- return o;
+ return CompOption::findOption (priv->opt, name);
}
bool
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0e58e57..72b2b35 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -6,6 +6,7 @@ gtk/window-decorator/gtk-window-decorator.c
metadata/annotate.xml.in
metadata/blur.xml.in
metadata/clone.xml.in
+metadata/commands.xml.in
metadata/composite.xml.in
metadata/copytex.xml.in
metadata/core.xml.in
@@ -16,6 +17,7 @@ metadata/fade.xml.in
metadata/fs.xml.in
metadata/gconf.xml.in
metadata/glib.xml.in
+metadata/gnomecompat.xml.in
metadata/imgpng.xml.in
metadata/imgsvg.xml.in
metadata/ini.xml.in
diff --git a/src/action.cpp b/src/action.cpp
index 9a06697..c13a8ff 100644
--- a/src/action.cpp
+++ b/src/action.cpp
@@ -72,7 +72,7 @@ struct _Edge {
static CompString
modifiersToString (unsigned int modMask)
{
- CompString binding = "";
+ CompString binding;
for (unsigned int i = 0; i < N_MODIFIERS; i++)
{
@@ -112,8 +112,8 @@ bindingStringToEdgeMask (CompString str)
static CompString
edgeMaskToBindingString (unsigned int edgeMask)
{
- CompString binding = "";
- int i;
+ CompString binding;
+ int i;
for (i = 0; i < SCREEN_EDGE_NUM; i++)
if (edgeMask & (1 << i))
@@ -185,8 +185,9 @@ CompAction::KeyBinding::fromString (const CompString &str)
return false;
}
- sStr = str.substr (pos);
+ sStr = str.substr (pos);
keysym = XStringToKeysym (sStr.c_str ());
+
if (keysym != NoSymbol)
{
KeyCode keycode;
@@ -215,7 +216,7 @@ CompAction::KeyBinding::fromString (const CompString &str)
CompString
CompAction::KeyBinding::toString () const
{
- CompString binding = "";
+ CompString binding;
if (!screen)
return "";
@@ -231,13 +232,9 @@ CompAction::KeyBinding::toString () const
keyname = XKeysymToString (keysym);
if (keyname)
- {
binding += keyname;
- }
else
- {
binding += compPrintf ("0x%x", mKeycode);
- }
}
return binding;
@@ -288,7 +285,8 @@ CompAction::ButtonBinding::fromString (const CompString &str)
while (pos < str.size () && !isalnum (str[pos]))
pos++;
- if (pos != std::string::npos && pos != str.size () &&
+ if (pos != std::string::npos &&
+ pos != str.size () &&
str.compare (pos, 6, "Button") == 0)
{
int buttonNum;
@@ -382,13 +380,9 @@ CompAction::setKey (const CompAction::KeyBinding &key)
priv->key = key;
if (key.modifiers () || key.keycode ())
- {
priv->type = CompAction::BindingTypeKey;
- }
else
- {
priv->type = CompAction::BindingTypeNone;
- }
}
CompAction::ButtonBinding &
@@ -413,7 +407,6 @@ CompAction::setButton (const CompAction::ButtonBinding &button)
{
priv->type = CompAction::BindingTypeNone;
}
-
}
unsigned int
@@ -458,9 +451,10 @@ CompAction::setState (CompAction::State state)
void
CompAction::copyState (const CompAction &action)
{
- priv->initiate = action.priv->initiate;
+ priv->initiate = action.priv->initiate;
priv->terminate = action.priv->terminate;
- priv->state = action.priv->state;
+ priv->state = action.priv->state;
+
memcpy (&priv->priv, &action.priv->priv, sizeof (CompPrivate));
}
@@ -494,6 +488,7 @@ CompAction::operator= (const CompAction &action)
{
delete priv;
priv = new PrivateAction (*action.priv);
+
return *this;
}
@@ -576,7 +571,7 @@ CompAction::keyToString ()
CompString binding;
binding = priv->key.toString ();
- if (binding.size () == 0)
+ if (!binding.size ())
return "Disabled";
return binding;
@@ -585,14 +580,14 @@ CompAction::keyToString ()
CompString
CompAction::buttonToString ()
{
- CompString binding = "", edge = "";
+ CompString binding, edge;
binding = modifiersToString (priv->button.modifiers ());
binding += edgeMaskToBindingString (priv->edgeMask);
binding += compPrintf ("Button%d", priv->button.button ());
- if (priv->button.button () == 0)
+ if (!priv->button.button ())
return "Disabled";
return binding;
@@ -601,13 +596,14 @@ CompAction::buttonToString ()
CompString
CompAction::edgeMaskToString ()
{
- CompString edge = "";
+ CompString edge;
for (int i = 0; i < SCREEN_EDGE_NUM; i++)
{
if (priv->edgeMask & (1 << i))
{
- edge += " | ";
+ if (!edge.empty ())
+ edge += " | ";
edge += edgeToString (i);
}
@@ -620,7 +616,7 @@ CompAction::edgeMaskToString ()
CompString
CompAction::edgeToString (unsigned int edge)
{
- return CompString (edges[edge].name);
+ return edges[edge].name;
}
PrivateAction::PrivateAction () :
diff --git a/src/actions.cpp b/src/actions.cpp
index 18f41b2..8ede0cf 100644
--- a/src/actions.cpp
+++ b/src/actions.cpp
@@ -51,38 +51,6 @@ CompScreen::closeWin (CompAction *action,
}
bool
-CompScreen::mainMenu (CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- unsigned int time;
-
- time = CompOption::getIntOptionNamed (options, "time", CurrentTime);
-
- if (screen->priv->grabs.empty ())
- screen->toolkitAction (Atoms::toolkitActionMainMenu, time,
- screen->priv->root, 0, 0, 0);
-
- return true;
-}
-
-bool
-CompScreen::runDialog (CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- unsigned int time;
-
- time = CompOption::getIntOptionNamed (options, "time", CurrentTime);
-
- if (screen->priv->grabs.empty ())
- screen->toolkitAction (Atoms::toolkitActionRunDialog, time,
- screen->priv->root , 0, 0, 0);
-
- return true;
-}
-
-bool
CompScreen::unmaximizeWin (CompAction *action,
CompAction::State state,
CompOption::Vector &options)
@@ -215,65 +183,6 @@ CompScreen::lowerWin (CompAction *action,
}
bool
-CompScreen::runCommandDispatch (CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- int index = -1;
- int i = COMP_OPTION_RUN_COMMAND0_KEY;
-
- while (i <= COMP_OPTION_RUN_COMMAND11_KEY)
- {
- if (action == &screen->priv->opt[i].value ().action ())
- {
- index = i - COMP_OPTION_RUN_COMMAND0_KEY +
- COMP_OPTION_COMMAND0;
- break;
- }
-
- i++;
- }
-
- if (index > 0)
- screen->runCommand (screen->priv->opt[index].value ().s ());
-
- return true;
-}
-
-bool
-CompScreen::runCommandScreenshot (CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- screen->runCommand (
- screen->priv->opt[COMP_OPTION_SCREENSHOT].value ().s ());
-
- return true;
-}
-
-bool
-CompScreen::runCommandWindowScreenshot (CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- screen->runCommand (
- screen->priv->opt[COMP_OPTION_WINDOW_SCREENSHOT].value ().s ());
-
- return true;
-}
-
-bool
-CompScreen::runCommandTerminal (CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- screen->runCommand (
- screen->priv->opt[COMP_OPTION_TERMINAL].value ().s ());
-
- return true;
-}
-
-bool
CompScreen::windowMenu (CompAction *action,
CompAction::State state,
CompOption::Vector &options)
diff --git a/src/atoms.cpp b/src/atoms.cpp
index 1e3d2b7..6c7310e 100644
--- a/src/atoms.cpp
+++ b/src/atoms.cpp
@@ -120,6 +120,8 @@ namespace Atoms {
Atom wmSyncRequestCounter;
+ Atom wmFullscreenMonitors;
+
Atom closeWindow;
Atom wmMoveResize;
Atom moveResizeWindow;
@@ -130,8 +132,6 @@ namespace Atoms {
Atom xBackground[2];
Atom toolkitAction;
- Atom toolkitActionMainMenu;
- Atom toolkitActionRunDialog;
Atom toolkitActionWindowMenu;
Atom toolkitActionForceQuitDialog;
@@ -283,6 +283,9 @@ namespace Atoms {
wmSyncRequestCounter =
XInternAtom (dpy, "_NET_WM_SYNC_REQUEST_COUNTER", 0);
+ wmFullscreenMonitors =
+ XInternAtom (dpy, "_NET_WM_FULLSCREEN_MONITORS", 0);
+
closeWindow = XInternAtom (dpy, "_NET_CLOSE_WINDOW", 0);
wmMoveResize = XInternAtom (dpy, "_NET_WM_MOVERESIZE", 0);
moveResizeWindow = XInternAtom (dpy, "_NET_MOVERESIZE_WINDOW", 0);
@@ -295,10 +298,6 @@ namespace Atoms {
toolkitAction =
XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION", 0);
- toolkitActionMainMenu =
- XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION_MAIN_MENU", 0);
- toolkitActionRunDialog =
- XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION_RUN_DIALOG", 0);
toolkitActionWindowMenu =
XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION_WINDOW_MENU", 0);
toolkitActionForceQuitDialog =
diff --git a/src/event.cpp b/src/event.cpp
index 1aab5ac..8781d26 100644
--- a/src/event.cpp
+++ b/src/event.cpp
@@ -1475,6 +1475,21 @@ CompScreen::handleEvent (XEvent *event)
if (w)
w->priv->setDesktop (event->xclient.data.l[0]);
}
+ else if (event->xclient.message_type == Atoms::wmFullscreenMonitors)
+ {
+ w = findWindow (event->xclient.window);
+ if (w)
+ {
+ CompFullscreenMonitorSet monitors;
+
+ monitors.top = event->xclient.data.l[0];
+ monitors.bottom = event->xclient.data.l[1];
+ monitors.left = event->xclient.data.l[2];
+ monitors.right = event->xclient.data.l[3];
+
+ w->priv->setFullscreenMonitors (&monitors);
+ }
+ }
break;
case MappingNotify:
priv->updateModifierMappings ();
@@ -1626,7 +1641,6 @@ CompScreen::handleEvent (XEvent *event)
if (!priv->opt[COMP_OPTION_CLICK_TO_FOCUS].value ().b () &&
priv->grabs.empty () &&
event->xcrossing.mode != NotifyGrab &&
- event->xcrossing.mode != NotifyUngrab &&
event->xcrossing.detail != NotifyInferior)
{
Bool raise;
diff --git a/src/main.cpp b/src/main.cpp
index b9ba1c5..8554ac1 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -53,8 +53,8 @@ CompWindow *lastFoundWindow = 0;
bool replaceCurrentWm = false;
bool indirectRendering = false;
bool noDetection = false;
-bool useDesktopHints = true;
-
+bool useDesktopHints = false;
+bool debugOutput = false;
bool useCow = true;
CompMetadata *coreMetadata = NULL;
@@ -65,22 +65,22 @@ static void
usage (void)
{
printf ("Usage: %s "
- "[--display DISPLAY] "
- "[--bg-image PNG] "
+ "[--replace] "
+ "[--display DISPLAY]\n "
"[--indirect-rendering] "
- "[--replace]\n "
"[--sm-disable] "
- "[--sm-client-id ID] "
- "[--no-detection]\n "
- "[--ignore-desktop-hints] "
- " [--use-root-window]\n "
+ "[--sm-client-id ID]\n "
+ "[--bg-image PNG] "
+ "[--no-detection] "
+ "[--keep-desktop-hints]\n "
+ "[--use-root-window] "
+ "[--debug] "
"[--version] "
"[--help] "
"[PLUGIN]...\n",
programName);
}
-
static void
signalHandler (int sig)
{
@@ -91,11 +91,11 @@ signalHandler (int sig)
waitpid (-1, &status, WNOHANG | WUNTRACED);
break;
case SIGHUP:
- restartSignal = TRUE;
+ restartSignal = true;
break;
case SIGINT:
case SIGTERM:
- shutDown = TRUE;
+ shutDown = true;
default:
break;
}
@@ -179,6 +179,10 @@ main (int argc, char **argv)
printf (PACKAGE_STRING "\n");
return 0;
}
+ else if (!strcmp (argv[i], "--debug"))
+ {
+ debugOutput = true;
+ }
else if (!strcmp (argv[i], "--display"))
{
if (i + 1 < argc)
@@ -186,23 +190,27 @@ main (int argc, char **argv)
}
else if (!strcmp (argv[i], "--indirect-rendering"))
{
- indirectRendering = TRUE;
+ indirectRendering = true;
+ }
+ else if (!strcmp (argv[i], "--keep-desktop-hints"))
+ {
+ useDesktopHints = true;
}
else if (!strcmp (argv[i], "--ignore-desktop-hints"))
{
- useDesktopHints = FALSE;
+ /* backward compatibility */
}
else if (!strcmp (argv[i], "--use-root-window"))
{
- useCow = FALSE;
+ useCow = false;
}
else if (!strcmp (argv[i], "--replace"))
{
- replaceCurrentWm = TRUE;
+ replaceCurrentWm = true;
}
else if (!strcmp (argv[i], "--sm-disable"))
{
- disableSm = TRUE;
+ disableSm = true;
}
else if (!strcmp (argv[i], "--sm-client-id"))
{
@@ -211,7 +219,7 @@ main (int argc, char **argv)
}
else if (!strcmp (argv[i], "--no-detection"))
{
- noDetection = TRUE;
+ noDetection = true;
}
else if (!strcmp (argv[i], "--bg-image"))
{
diff --git a/src/match.cpp b/src/match.cpp
index 072083e..fd4b6c1 100644
--- a/src/match.cpp
+++ b/src/match.cpp
@@ -53,7 +53,7 @@ class CoreExp : public CompMatch::Expression {
TypeType
} Type;
- CoreExp (CompString str)
+ CoreExp (const CompString& str)
{
if (str.compare (0, 4, "xid=") == 0)
{
@@ -78,20 +78,18 @@ class CoreExp : public CompMatch::Expression {
}
else
{
- if (str.compare (0, 5, "type=") == 0)
- str = str.substr (5);
+ size_t offset = (str.compare (0, 5, "type=") == 0) ? 5 : 0;
mType = TypeType;
- priv.uval = PrivateWindow::windowTypeFromString (str.c_str ());
+ priv.uval = PrivateWindow::windowTypeFromString (
+ str.substr (offset).c_str ());
}
}
bool evaluate (CompWindow *w)
{
-
switch (mType)
{
-
case TypeXid:
return ((unsigned int) priv.val == w->id ());
case TypeState:
@@ -116,7 +114,7 @@ class CoreExp : public CompMatch::Expression {
};
CompMatch::Expression *
-CompScreen::matchInitExp (const CompString str)
+CompScreen::matchInitExp (const CompString& str)
{
WRAPABLE_HND_FUNC_RETURN(10, CompMatch::Expression *, matchInitExp, str)
@@ -124,7 +122,7 @@ CompScreen::matchInitExp (const CompString str)
}
static void
-matchUpdateMatchOptions (CompOption::Vector options)
+matchUpdateMatchOptions (CompOption::Vector& options)
{
foreach (CompOption &option, options)
{
@@ -162,8 +160,6 @@ CompScreen::matchPropertyChanged (CompWindow *w)
WRAPABLE_HND_FUNC(12, matchPropertyChanged, w)
}
-
-
static void
matchResetOps (MatchOp::List &list)
{
@@ -177,10 +173,7 @@ matchResetOps (MatchOp::List &list)
case MatchOp::TypeExp:
exp = dynamic_cast <MatchExpOp *> (op);
if (exp && exp->e)
- {
-
exp->e.reset ();
- }
break;
default:
break;
@@ -192,11 +185,10 @@ static bool
matchOpsEqual (MatchOp::List &list1,
MatchOp::List &list2)
{
+ MatchGroupOp *g1, *g2;
+ MatchExpOp *e1, *e2;
MatchOp::List::iterator it1 = list1.begin (), it2 = list2.begin ();
- MatchGroupOp *g1, *g2;
- MatchExpOp *e1, *e2;
-
if (list1.size () != list2.size ())
return false;
@@ -236,7 +228,6 @@ matchOpsEqual (MatchOp::List &list1,
return true;
}
-
static unsigned int
nextIndex (CompString &str,
unsigned int i)
@@ -248,7 +239,6 @@ nextIndex (CompString &str,
return i;
}
-
static CompString
strndupValue (CompString str)
{
@@ -400,7 +390,9 @@ matchOpsToString (MatchOp::List &list)
{
switch (op->type ()) {
case MatchOp::TypeGroup:
- group = matchOpsToString (dynamic_cast <MatchGroupOp *> (op)->op);
+ group =
+ matchOpsToString (dynamic_cast <MatchGroupOp *> (op)->op);
+
if (group.length ())
{
if (value.length ())
@@ -414,14 +406,12 @@ matchOpsToString (MatchOp::List &list)
}
break;
case MatchOp::TypeExp:
-
if (value.length ())
- {
- value += ((op->flags & MATCH_OP_AND_MASK) ?
- "& " : "| ");
- }
+ value += ((op->flags & MATCH_OP_AND_MASK) ? "& " : "| ");
+
if (op->flags & MATCH_OP_NOT_MASK)
value += "!";
+
value += dynamic_cast <MatchExpOp *> (op)->value;
value += " ";
break;
@@ -482,7 +472,8 @@ matchEvalOps (MatchOp::List &list,
switch (op->type ()) {
case MatchOp::TypeGroup:
- value = matchEvalOps (dynamic_cast <MatchGroupOp *> (op)->op, w);
+ value =
+ matchEvalOps (dynamic_cast <MatchGroupOp *> (op)->op, w);
break;
case MatchOp::TypeExp:
exp = dynamic_cast <MatchExpOp *> (op);
@@ -527,6 +518,7 @@ MatchExpOp::MatchExpOp (const MatchExpOp &ex) :
value (ex.value),
e (ex.e)
{
+ flags = ex.flags;
}
MatchGroupOp::MatchGroupOp () :
@@ -538,6 +530,7 @@ MatchGroupOp::MatchGroupOp (const MatchGroupOp &gr) :
op (0)
{
*this = gr;
+ flags = gr.flags;
}
MatchGroupOp::~MatchGroupOp ()
@@ -681,9 +674,11 @@ const CompMatch &
CompMatch::operator! ()
{
MatchGroupOp *g = new MatchGroupOp (priv->op);
+
g->flags ^= MATCH_OP_NOT_MASK;
priv->op = MatchGroupOp ();
priv->op.op.push_back (g);
+
return *this;
}
@@ -692,31 +687,40 @@ CompMatch::operator= (const CompString &str)
{
priv->op = MatchGroupOp ();
matchAddFromString (priv->op.op, str);
+
return *this;
}
CompMatch &
CompMatch::operator&= (const CompString &str)
{
- return CompMatch (*this) &= CompMatch (str);
+ *this &= CompMatch (str);
+
+ return *this;
}
CompMatch &
CompMatch::operator|= (const CompString &str)
{
- return CompMatch (*this) |= CompMatch (str);
+ *this |= CompMatch (str);
+
+ return *this;
}
const CompMatch &
CompMatch::operator& (const CompString &str)
{
- return CompMatch(*this) &= str;
+ *this &= str;
+
+ return *this;
}
const CompMatch &
CompMatch::operator| (const CompString &str)
{
- return CompMatch(*this) |= str;
+ *this |= str;
+
+ return *this;
}
bool
diff --git a/src/option.cpp b/src/option.cpp
index c41f6a1..009cdd6 100644
--- a/src/option.cpp
+++ b/src/option.cpp
@@ -345,42 +345,54 @@ CompOption::Value::operator== (const CompOption::Value &val)
{
if (priv->type != val.priv->type)
return false;
+
switch (priv->type)
{
case CompOption::TypeBool:
return priv->value.b == val.priv->value.b;
break;
+
case CompOption::TypeInt:
return priv->value.i == val.priv->value.i;
break;
+
case CompOption::TypeFloat:
return priv->value.f == val.priv->value.f;
break;
+
case CompOption::TypeColor:
return (priv->value.c[0] == val.priv->value.c[0]) &&
(priv->value.c[1] == val.priv->value.c[1]) &&
(priv->value.c[2] == val.priv->value.c[2]) &&
(priv->value.c[3] == val.priv->value.c[3]);
break;
+
case CompOption::TypeString:
return priv->string.compare (val.priv->string) == 0;
break;
+
case CompOption::TypeMatch:
return priv->match == val.priv->match;
break;
+
case CompOption::TypeAction:
return priv->action == val.priv->action;
break;
+
case CompOption::TypeList:
if (priv->listType != val.priv->listType)
return false;
+
if (priv->list.size () != val.priv->list.size ())
return false;
+
for (unsigned int i = 0; i < priv->list.size (); i++)
if (priv->list[i] != val.priv->list[i])
return false;
+
return true;
break;
+
default:
break;
}
@@ -399,6 +411,7 @@ CompOption::Value::operator= (const CompOption::Value &val)
{
delete priv;
priv = new PrivateValue (*val.priv);
+
return *this;
}
@@ -552,7 +565,6 @@ CompOption::Restriction::operator= (const CompOption::Restriction &rest)
return *this;
}
-
CompOption *
CompOption::findOption (CompOption::Vector &options,
CompString name,
@@ -601,12 +613,15 @@ finiScreenOptionValue (CompScreen *s,
case CompOption::TypeButton:
case CompOption::TypeEdge:
case CompOption::TypeBell:
-if (v.action ().state () & CompAction::StateAutoGrab)
+ if (v.action ().state () & CompAction::StateAutoGrab)
s->removeAction (&v.action ());
break;
+
case CompOption::TypeList:
foreach (CompOption::Value &val, v.list ())
finiScreenOptionValue (s, val, v.listType ());
+ break;
+
default:
break;
}
@@ -623,13 +638,14 @@ finiOptionValue (CompOption::Value &v,
case CompOption::TypeEdge:
case CompOption::TypeBell:
if (v.action ().state () & CompAction::StateAutoGrab && screen)
- {
screen->removeAction (&v.action ());
- }
break;
+
case CompOption::TypeList:
foreach (CompOption::Value &val, v.list ())
finiOptionValue (val, v.listType ());
+ break;
+
default:
break;
}
@@ -675,10 +691,7 @@ CompOption::rest ()
bool
CompOption::set (CompOption::Value &val)
{
- if (priv->type == CompOption::TypeKey ||
- priv->type == CompOption::TypeButton ||
- priv->type == CompOption::TypeEdge ||
- priv->type == CompOption::TypeBell)
+ if (isAction () && priv->type != CompOption::TypeAction)
val.action ().copyState (priv->value.action ());
if (priv->value == val)
@@ -688,21 +701,18 @@ CompOption::set (CompOption::Value &val)
priv->value.action ().state () & CompAction::StateAutoGrab && screen)
{
if (!screen->addAction (&val.action ()))
- {
return false;
- }
else
- {
screen->removeAction (&priv->value.action ());
- }
}
switch (priv->type)
{
- case CompOption::TypeInt:
+ case CompOption::TypeInt:
if (!priv->rest.inRange (val.i ()))
return false;
break;
+
case CompOption::TypeFloat:
{
float v, p;
@@ -717,21 +727,27 @@ CompOption::set (CompOption::Value &val)
priv->value.set (v);
return true;
}
+
case CompOption::TypeAction:
return false;
+
case CompOption::TypeKey:
if (!(val.action ().type () & CompAction::BindingTypeKey))
return false;
break;
+
case CompOption::TypeButton:
if (!(val.action ().type () & (CompAction::BindingTypeButton |
CompAction::BindingTypeEdgeButton)))
return false;
break;
+
default:
break;
}
+
priv->value = val;
+
return true;
}
@@ -749,7 +765,6 @@ CompOption::operator= (const CompOption &option)
return *this;
}
-
bool
CompOption::getBoolOptionNamed (const Vector& options,
const CompString& name,
@@ -774,7 +789,6 @@ CompOption::getIntOptionNamed (const Vector& options,
return defaultValue;
}
-
float
CompOption::getFloatOptionNamed (const Vector& options,
const CompString& name,
@@ -787,7 +801,6 @@ CompOption::getFloatOptionNamed (const Vector& options,
return defaultValue;
}
-
CompString
CompOption::getStringOptionNamed (const Vector& options,
const CompString& name,
@@ -800,7 +813,6 @@ CompOption::getStringOptionNamed (const Vector& options,
return defaultValue;
}
-
unsigned short *
CompOption::getColorOptionNamed (const Vector& options,
const CompString& name,
@@ -813,7 +825,6 @@ CompOption::getColorOptionNamed (const Vector& options,
return defaultValue;
}
-
CompMatch
CompOption::getMatchOptionNamed (const Vector& options,
const CompString& name,
@@ -826,8 +837,6 @@ CompOption::getMatchOptionNamed (const Vector& options,
return defaultValue;
}
-
-
bool
CompOption::stringToColor (CompString color,
unsigned short *rgba)
diff --git a/src/plugin.cpp b/src/plugin.cpp
index 60071a2..4b1c3df 100644
--- a/src/plugin.cpp
+++ b/src/plugin.cpp
@@ -28,6 +28,9 @@
#include <string.h>
#include <dlfcn.h>
#include <dirent.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <list>
#include <boost/foreach.hpp>
@@ -123,19 +126,34 @@ dlloaderLoadPlugin (CompPlugin *p,
const char *path,
const char *name)
{
- char *file;
- void *dlhand;
+ CompString file;
+ void *dlhand;
+ bool loaded = false;
+ struct stat fileInfo;
- file = (char *) malloc ((path ? strlen (path) : 0) + strlen (name) + 8);
- if (!file)
- return false;
+ if (cloaderLoadPlugin (p, path, name))
+ return true;
if (path)
- sprintf (file, "%s/lib%s.so", path, name);
- else
- sprintf (file, "lib%s.so", name);
+ {
+ file = path;
+ file += "/";
+ }
+
+ file += "lib";
+ file += name;
+ file += ".so";
- dlhand = dlopen (file, RTLD_LAZY);
+ if (stat (file.c_str (), &fileInfo) != 0)
+ {
+ /* file likely not present */
+ compLogMessage ("core", CompLogLevelDebug,
+ "Could not stat() file %s : %s",
+ file.c_str (), strerror (errno));
+ return false;
+ }
+
+ dlhand = dlopen (file.c_str (), RTLD_LAZY);
if (dlhand)
{
PluginGetInfoProc getInfo;
@@ -144,15 +162,13 @@ dlloaderLoadPlugin (CompPlugin *p,
dlerror ();
- snprintf(sym, 1024, "getCompPluginVTable20081216_%s", name);
- getInfo = (PluginGetInfoProc)
- dlsym (dlhand, sym);
+ snprintf (sym, 1024, "getCompPluginVTable20081216_%s", name);
+ getInfo = (PluginGetInfoProc) dlsym (dlhand, sym);
error = dlerror ();
if (error)
{
compLogMessage ("core", CompLogLevelError, "dlsym: %s", error);
-
getInfo = 0;
}
@@ -162,41 +178,34 @@ dlloaderLoadPlugin (CompPlugin *p,
if (!p->vTable)
{
compLogMessage ("core", CompLogLevelError,
- "Couldn't get vtable from '%s' plugin", file);
-
- dlclose (dlhand);
- free (file);
-
- return false;
+ "Couldn't get vtable from '%s' plugin",
+ file.c_str ());
+ }
+ else
+ {
+ p->devPrivate.ptr = dlhand;
+ p->devType = "dlloader";
+ loaded = true;
}
- }
- else
- {
- dlclose (dlhand);
- free (file);
-
- return false;
}
}
else
{
- free (file);
-
- return cloaderLoadPlugin (p, path, name);
+ compLogMessage ("core", CompLogLevelError,
+ "Couldn't load plugin '%s' : %s",
+ file.c_str (), dlerror ());
}
- free (file);
+ if (!loaded && dlhand)
+ dlclose (dlhand);
- p->devPrivate.ptr = dlhand;
- p->devType = "dlloader";
-
- return true;
+ return loaded;
}
static void
dlloaderUnloadPlugin (CompPlugin *p)
{
- if (p->devType.compare ("dlloader") == 0)
+ if (p->devType == "dlloader")
{
delete p->vTable;
dlclose (p->devPrivate.ptr);
diff --git a/src/privates.cpp b/src/privates.cpp
index 9d5b51c..1d7b6ef 100644
--- a/src/privates.cpp
+++ b/src/privates.cpp
@@ -27,47 +27,48 @@
#include <core/privates.h>
-CompPrivateStorage::CompPrivateStorage (CompPrivateStorage::Indices *iList) :
+CompPrivateStorage::CompPrivateStorage (CompPrivateStorage::Indices& iList) :
privates (0)
{
- if (iList->size() > 0)
- privates.resize (iList->size ());
+ if (iList.size() > 0)
+ privates.resize (iList.size ());
}
int
-CompPrivateStorage::allocatePrivateIndex (CompPrivateStorage::Indices *iList)
+CompPrivateStorage::allocatePrivateIndex (CompPrivateStorage::Indices& iList)
{
- if (!iList)
- return -1;
+ unsigned int i;
- for (unsigned int i = 0; i < iList->size(); i++)
+ for (i = 0; i < iList.size (); i++)
{
- if (!iList->at (i))
+ if (!iList.at (i))
{
- iList->at (i) = true;
+ iList.at (i) = true;
return i;
}
}
- unsigned int i = iList->size ();
- iList->resize (i + 1);
- iList->at (i) = true;
+
+ i = iList.size ();
+ iList.resize (i + 1);
+ iList.at (i) = true;
return i;
}
void
-CompPrivateStorage::freePrivateIndex (CompPrivateStorage::Indices *iList,
- int idx)
+CompPrivateStorage::freePrivateIndex (CompPrivateStorage::Indices& iList,
+ int idx)
{
- if (!iList || idx < 0 || idx >= (int) iList->size())
+ int size = iList.size ();
+
+ if (idx < 0 || idx >= size)
return;
- if (idx < (int) iList->size () - 1)
+ if (idx < size - 1)
{
- iList->at(idx) = false;
+ iList.at (idx) = false;
return;
}
- unsigned int i = iList->size () - 1;
- iList->resize (i);
+ iList.resize (size - 1);
}
diff --git a/src/privatescreen.h b/src/privatescreen.h
index f5699b1..8dd1334 100644
--- a/src/privatescreen.h
+++ b/src/privatescreen.h
@@ -55,73 +55,41 @@ extern bool useDesktopHints;
#define COMP_OPTION_AUTORAISE_DELAY 3
#define COMP_OPTION_CLOSE_WINDOW_KEY 4
#define COMP_OPTION_CLOSE_WINDOW_BUTTON 5
-#define COMP_OPTION_MAIN_MENU_KEY 6
-#define COMP_OPTION_RUN_DIALOG_KEY 7
-#define COMP_OPTION_COMMAND0 8
-#define COMP_OPTION_COMMAND1 9
-#define COMP_OPTION_COMMAND2 10
-#define COMP_OPTION_COMMAND3 11
-#define COMP_OPTION_COMMAND4 12
-#define COMP_OPTION_COMMAND5 13
-#define COMP_OPTION_COMMAND6 14
-#define COMP_OPTION_COMMAND7 15
-#define COMP_OPTION_COMMAND8 16
-#define COMP_OPTION_COMMAND9 17
-#define COMP_OPTION_COMMAND10 18
-#define COMP_OPTION_COMMAND11 19
-#define COMP_OPTION_RUN_COMMAND0_KEY 20
-#define COMP_OPTION_RUN_COMMAND1_KEY 21
-#define COMP_OPTION_RUN_COMMAND2_KEY 22
-#define COMP_OPTION_RUN_COMMAND3_KEY 23
-#define COMP_OPTION_RUN_COMMAND4_KEY 24
-#define COMP_OPTION_RUN_COMMAND5_KEY 25
-#define COMP_OPTION_RUN_COMMAND6_KEY 26
-#define COMP_OPTION_RUN_COMMAND7_KEY 27
-#define COMP_OPTION_RUN_COMMAND8_KEY 28
-#define COMP_OPTION_RUN_COMMAND9_KEY 29
-#define COMP_OPTION_RUN_COMMAND10_KEY 30
-#define COMP_OPTION_RUN_COMMAND11_KEY 31
-#define COMP_OPTION_RAISE_WINDOW_KEY 32
-#define COMP_OPTION_RAISE_WINDOW_BUTTON 33
-#define COMP_OPTION_LOWER_WINDOW_KEY 34
-#define COMP_OPTION_LOWER_WINDOW_BUTTON 35
-#define COMP_OPTION_UNMAXIMIZE_WINDOW_KEY 36
-#define COMP_OPTION_MINIMIZE_WINDOW_KEY 37
-#define COMP_OPTION_MINIMIZE_WINDOW_BUTTON 38
-#define COMP_OPTION_MAXIMIZE_WINDOW_KEY 39
-#define COMP_OPTION_MAXIMIZE_WINDOW_HORZ_KEY 40
-#define COMP_OPTION_MAXIMIZE_WINDOW_VERT_KEY 41
-#define COMP_OPTION_SCREENSHOT 42
-#define COMP_OPTION_RUN_SCREENSHOT_KEY 43
-#define COMP_OPTION_WINDOW_SCREENSHOT 44
-#define COMP_OPTION_RUN_WINDOW_SCREENSHOT_KEY 45
-#define COMP_OPTION_WINDOW_MENU_BUTTON 46
-#define COMP_OPTION_WINDOW_MENU_KEY 47
-#define COMP_OPTION_SHOW_DESKTOP_KEY 48
-#define COMP_OPTION_SHOW_DESKTOP_EDGE 49
-#define COMP_OPTION_RAISE_ON_CLICK 50
-#define COMP_OPTION_AUDIBLE_BELL 51
-#define COMP_OPTION_TOGGLE_WINDOW_MAXIMIZED_KEY 52
-#define COMP_OPTION_TOGGLE_WINDOW_MAXIMIZED_BUTTON 53
-#define COMP_OPTION_TOGGLE_WINDOW_MAXIMIZED_HORZ_KEY 54
-#define COMP_OPTION_TOGGLE_WINDOW_MAXIMIZED_VERT_KEY 55
-#define COMP_OPTION_HIDE_SKIP_TASKBAR_WINDOWS 56
-#define COMP_OPTION_TOGGLE_WINDOW_SHADED_KEY 57
-#define COMP_OPTION_IGNORE_HINTS_WHEN_MAXIMIZED 58
-#define COMP_OPTION_TERMINAL 59
-#define COMP_OPTION_RUN_TERMINAL_KEY 60
-#define COMP_OPTION_PING_DELAY 61
-#define COMP_OPTION_EDGE_DELAY 62
-#define COMP_OPTION_HSIZE 63
-#define COMP_OPTION_VSIZE 64
-#define COMP_OPTION_DEFAULT_ICON 65
-#define COMP_OPTION_NUMBER_OF_DESKTOPS 66
-#define COMP_OPTION_DETECT_OUTPUTS 67
-#define COMP_OPTION_OUTPUTS 68
-#define COMP_OPTION_OVERLAPPING_OUTPUTS 69
-#define COMP_OPTION_FOCUS_PREVENTION_LEVEL 70
-#define COMP_OPTION_FOCUS_PREVENTION_MATCH 71
-#define COMP_OPTION_NUM 72
+#define COMP_OPTION_RAISE_WINDOW_KEY 6
+#define COMP_OPTION_RAISE_WINDOW_BUTTON 7
+#define COMP_OPTION_LOWER_WINDOW_KEY 8
+#define COMP_OPTION_LOWER_WINDOW_BUTTON 9
+#define COMP_OPTION_UNMAXIMIZE_WINDOW_KEY 10
+#define COMP_OPTION_MINIMIZE_WINDOW_KEY 11
+#define COMP_OPTION_MINIMIZE_WINDOW_BUTTON 12
+#define COMP_OPTION_MAXIMIZE_WINDOW_KEY 13
+#define COMP_OPTION_MAXIMIZE_WINDOW_HORZ_KEY 14
+#define COMP_OPTION_MAXIMIZE_WINDOW_VERT_KEY 15
+#define COMP_OPTION_WINDOW_MENU_BUTTON 16
+#define COMP_OPTION_WINDOW_MENU_KEY 17
+#define COMP_OPTION_SHOW_DESKTOP_KEY 18
+#define COMP_OPTION_SHOW_DESKTOP_EDGE 19
+#define COMP_OPTION_RAISE_ON_CLICK 20
+#define COMP_OPTION_AUDIBLE_BELL 21
+#define COMP_OPTION_TOGGLE_WINDOW_MAXIMIZED_KEY 22
+#define COMP_OPTION_TOGGLE_WINDOW_MAXIMIZED_BUTTON 23
+#define COMP_OPTION_TOGGLE_WINDOW_MAXIMIZED_HORZ_KEY 24
+#define COMP_OPTION_TOGGLE_WINDOW_MAXIMIZED_VERT_KEY 25
+#define COMP_OPTION_HIDE_SKIP_TASKBAR_WINDOWS 26
+#define COMP_OPTION_TOGGLE_WINDOW_SHADED_KEY 27
+#define COMP_OPTION_IGNORE_HINTS_WHEN_MAXIMIZED 28
+#define COMP_OPTION_PING_DELAY 29
+#define COMP_OPTION_EDGE_DELAY 30
+#define COMP_OPTION_HSIZE 31
+#define COMP_OPTION_VSIZE 32
+#define COMP_OPTION_DEFAULT_ICON 33
+#define COMP_OPTION_NUMBER_OF_DESKTOPS 34
+#define COMP_OPTION_DETECT_OUTPUTS 35
+#define COMP_OPTION_OUTPUTS 36
+#define COMP_OPTION_OVERLAPPING_OUTPUTS 37
+#define COMP_OPTION_FOCUS_PREVENTION_LEVEL 38
+#define COMP_OPTION_FOCUS_PREVENTION_MATCH 39
+#define COMP_OPTION_NUM 40
extern bool inHandleEvent;
diff --git a/src/privatewindow.h b/src/privatewindow.h
index 7eb2ec7..ee3224e 100644
--- a/src/privatewindow.h
+++ b/src/privatewindow.h
@@ -41,6 +41,7 @@
(w)->attrib.x - (w)->output.left >= (int) screen->width () || \
(w)->attrib.y - (w)->output.top >= (int) screen->height () )
+typedef CompWindowExtents CompFullscreenMonitorSet;
class PrivateWindow {
@@ -60,7 +61,6 @@ class PrivateWindow {
bool isGroupTransient (Window clientLeader);
-
static bool stackLayerCheck (CompWindow *w,
Window clientLeader,
CompWindow *below);
@@ -117,7 +117,7 @@ class PrivateWindow {
static void unminimizeTransients (CompWindow *w,
CompWindow *ancestor);
- bool getUsageTimestamp (Time *timestamp);
+ bool getUsageTimestamp (Time& timestamp);
bool isWindowFocusAllowed (Time timestamp);
@@ -165,12 +165,10 @@ class PrivateWindow {
unsigned int adjustConfigureRequestForGravity (XWindowChanges *xwc,
unsigned int xwcm,
int gravity);
-
void updateSize ();
- bool getUserTime (Time *time);
-
+ bool getUserTime (Time& time);
void setUserTime (Time time);
bool allowWindowFocus (unsigned int noFocusMask,
@@ -186,6 +184,8 @@ class PrivateWindow {
void processMap ();
+ void setFullscreenMonitors (CompFullscreenMonitorSet *monitors);
+
static unsigned int windowTypeFromString (const char *str);
static int compareWindowActiveness (CompWindow *w1,
@@ -193,6 +193,8 @@ class PrivateWindow {
void setOverrideRedirect (bool overrideRedirect);
+ void readIconHint ();
+
public:
PrivateWindow *priv;
@@ -211,6 +213,7 @@ class PrivateWindow {
Window transientFor;
Window clientLeader;
XSizeHints sizeHints;
+ XWMHints *hints;
bool inputHint;
bool alpha;
@@ -236,7 +239,10 @@ class PrivateWindow {
CompPoint initialViewport;
Time initialTimestamp;
- Bool initialTimestampSet;
+ bool initialTimestampSet;
+
+ bool fullscreenMonitorsSet;
+ CompRect fullscreenMonitorRect;
bool placed;
bool minimized;
diff --git a/src/rect.cpp b/src/rect.cpp
index 38ea292..ee51ffd 100644
--- a/src/rect.cpp
+++ b/src/rect.cpp
@@ -86,6 +86,21 @@ CompRect::setGeometry (int x1, int x2, int y1, int y2)
}
bool
+CompRect::contains (const CompPoint& point) const
+{
+ if (point.x () < x1 ())
+ return false;
+ if (point.x () > x2 ())
+ return false;
+ if (point.y () < y1 ())
+ return false;
+ if (point.y () > y2 ())
+ return false;
+
+ return true;
+}
+
+bool
CompRect::operator== (const CompRect &rect) const
{
if (mRegion.extents.x1 != rect.mRegion.extents.x1)
diff --git a/src/region.cpp b/src/region.cpp
index b3f6de8..7819728 100644
--- a/src/region.cpp
+++ b/src/region.cpp
@@ -133,8 +133,11 @@ CompRegion::contains (const CompPoint &p) const
bool
CompRegion::contains (const CompRect &r) const
{
- return XRectInRegion (handle (), r.x (), r.y (), r.width (), r.height ())
- != RectangleOut;
+ int result;
+
+ result = XRectInRegion (handle (), r.x (), r.y (), r.width (), r.height ());
+
+ return result == RectangleIn;
}
CompRegion
@@ -164,7 +167,10 @@ CompRegion::intersects (const CompRegion &r) const
bool
CompRegion::intersects (const CompRect &r) const
{
- return !intersected (r).isEmpty ();
+ int result;
+ result = XRectInRegion (handle (), r.x (), r.y (), r.width (), r.height ());
+
+ return result != RectangleOut;
}
bool
diff --git a/src/screen.cpp b/src/screen.cpp
index 642cf10..21a5927 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -97,22 +97,23 @@ CompPrivateStorage::Indices screenPrivateIndices (0);
int
CompScreen::allocPrivateIndex ()
{
- int i = CompPrivateStorage::allocatePrivateIndex (&screenPrivateIndices);
+ int i = CompPrivateStorage::allocatePrivateIndex (screenPrivateIndices);
+
if (screenPrivateIndices.size () != screen->privates.size ())
screen->privates.resize (screenPrivateIndices.size ());
+
return i;
}
void
CompScreen::freePrivateIndex (int index)
{
- CompPrivateStorage::freePrivateIndex (&screenPrivateIndices, index);
+ CompPrivateStorage::freePrivateIndex (screenPrivateIndices, index);
+
if (screenPrivateIndices.size () != screen->privates.size ())
screen->privates.resize (screenPrivateIndices.size ());
}
-
-
#define TIMEVALDIFF(tv1, tv2) \
((tv1)->tv_sec == (tv2)->tv_sec || (tv1)->tv_usec >= (tv2)->tv_usec) ? \
((((tv1)->tv_sec - (tv2)->tv_sec) * 1000000) + \
@@ -120,7 +121,6 @@ CompScreen::freePrivateIndex (int index)
((((tv1)->tv_sec - 1 - (tv2)->tv_sec) * 1000000) + \
(1000000 + (tv1)->tv_usec - (tv2)->tv_usec)) / 1000
-
void
CompScreen::eventLoop ()
{
@@ -158,10 +158,12 @@ CompScreen::eventLoop ()
time = t->mMaxLeft;
it++;
}
+
if (time < 5)
usleep (time * 1000);
else
priv->doPoll (time);
+
gettimeofday (&tv, 0);
priv->handleTimers (&tv);
}
@@ -184,7 +186,7 @@ CompScreen::addFileWatch (const char *path,
if (!fileWatch)
return 0;
- fileWatch->path = strdup (path);
+ fileWatch->path = path;
fileWatch->mask = mask;
fileWatch->callBack = callBack;
fileWatch->handle = priv->lastFileWatchHandle++;
@@ -300,8 +302,10 @@ CompScreen::removeWatchFd (CompWatchFdHandle handle)
for (it = priv->watchFds.begin(), i = priv->nWatchFds - 1;
it != priv->watchFds.end(); it++, i--)
+ {
if ((*it)->handle == handle)
break;
+ }
if (it == priv->watchFds.end())
return;
@@ -322,7 +326,9 @@ void
CompScreen::storeValue (CompString key, CompPrivate value)
{
std::map<CompString,CompPrivate>::iterator it;
+
it = priv->valueMap.find (key);
+
if (it != priv->valueMap.end ())
{
it->second = value;
@@ -397,8 +403,10 @@ PrivateScreen::doPoll (int timeout)
for (it = watchFds.begin(), i = nWatchFds - 1; it != watchFds.end();
it++, i--)
+ {
if (watchPollFds[i].revents != 0 && (*it)->callBack)
(*it)->callBack ();
+ }
}
return rv;
@@ -455,8 +463,8 @@ CompScreen::setOptionForPlugin (const char *plugin,
const char *name,
CompOption::Value &value)
{
- WRAPABLE_HND_FUNC_RETURN(4, bool, setOptionForPlugin,
- plugin, name, value)
+ WRAPABLE_HND_FUNC_RETURN (4, bool, setOptionForPlugin,
+ plugin, name, value)
CompPlugin *p = CompPlugin::find (plugin);
if (p)
@@ -467,8 +475,8 @@ CompScreen::setOptionForPlugin (const char *plugin,
void
CompScreen::sessionEvent (CompSession::Event event,
- CompOption::Vector &arguments)
- WRAPABLE_HND_FUNC(5, sessionEvent, event, arguments)
+ CompOption::Vector &arguments)
+ WRAPABLE_HND_FUNC (5, sessionEvent, event, arguments)
void
ScreenInterface::fileWatchAdded (CompFileWatch *watch)
@@ -489,7 +497,7 @@ ScreenInterface::finiPluginForScreen (CompPlugin *plugin)
bool
ScreenInterface::setOptionForPlugin (const char *plugin,
- const char *name,
+ const char *name,
CompOption::Value &value)
WRAPABLE_DEF (setOptionForPlugin, plugin, name, value)
@@ -498,8 +506,6 @@ ScreenInterface::sessionEvent (CompSession::Event event,
CompOption::Vector &arguments)
WRAPABLE_DEF (sessionEvent, event, arguments)
-
-
const CompMetadata::OptionInfo coreOptionInfo[COMP_OPTION_NUM] = {
{ "active_plugins", "list", "<type>string</type>", 0, 0 },
{ "click_to_focus", "bool", 0, 0, 0 },
@@ -507,32 +513,6 @@ const CompMetadata::OptionInfo coreOptionInfo[COMP_OPTION_NUM] = {
{ "autoraise_delay", "int", 0, 0, 0 },
{ "close_window_key", "key", 0, CompScreen::closeWin, 0 },
{ "close_window_button", "button", 0, CompScreen::closeWin, 0 },
- { "main_menu_key", "key", 0, CompScreen::mainMenu, 0 },
- { "run_key", "key", 0, CompScreen::runDialog, 0 },
- { "command0", "string", 0, 0, 0 },
- { "command1", "string", 0, 0, 0 },
- { "command2", "string", 0, 0, 0 },
- { "command3", "string", 0, 0, 0 },
- { "command4", "string", 0, 0, 0 },
- { "command5", "string", 0, 0, 0 },
- { "command6", "string", 0, 0, 0 },
- { "command7", "string", 0, 0, 0 },
- { "command8", "string", 0, 0, 0 },
- { "command9", "string", 0, 0, 0 },
- { "command10", "string", 0, 0, 0 },
- { "command11", "string", 0, 0, 0 },
- { "run_command0_key", "key", 0, CompScreen::runCommandDispatch, 0 },
- { "run_command1_key", "key", 0, CompScreen::runCommandDispatch, 0 },
- { "run_command2_key", "key", 0, CompScreen::runCommandDispatch, 0 },
- { "run_command3_key", "key", 0, CompScreen::runCommandDispatch, 0 },
- { "run_command4_key", "key", 0, CompScreen::runCommandDispatch, 0 },
- { "run_command5_key", "key", 0, CompScreen::runCommandDispatch, 0 },
- { "run_command6_key", "key", 0, CompScreen::runCommandDispatch, 0 },
- { "run_command7_key", "key", 0, CompScreen::runCommandDispatch, 0 },
- { "run_command8_key", "key", 0, CompScreen::runCommandDispatch, 0 },
- { "run_command9_key", "key", 0, CompScreen::runCommandDispatch, 0 },
- { "run_command10_key", "key", 0, CompScreen::runCommandDispatch, 0 },
- { "run_command11_key", "key", 0, CompScreen::runCommandDispatch, 0 },
{ "raise_window_key", "key", 0, CompScreen::raiseWin, 0 },
{ "raise_window_button", "button", 0, CompScreen::raiseWin, 0 },
{ "lower_window_key", "key", 0, CompScreen::lowerWin, 0 },
@@ -545,12 +525,6 @@ const CompMetadata::OptionInfo coreOptionInfo[COMP_OPTION_NUM] = {
CompScreen::maximizeWinHorizontally, 0 },
{ "maximize_window_vertically_key", "key", 0,
CompScreen::maximizeWinVertically, 0 },
- { "command_screenshot", "string", 0, 0, 0 },
- { "run_command_screenshot_key", "key", 0,
- CompScreen::runCommandScreenshot, 0 },
- { "command_window_screenshot", "string", 0, 0, 0 },
- { "run_command_window_screenshot_key", "key", 0,
- CompScreen::runCommandWindowScreenshot, 0 },
{ "window_menu_button", "button", 0, CompScreen::windowMenu, 0 },
{ "window_menu_key", "key", 0, CompScreen::windowMenu, 0 },
{ "show_desktop_key", "key", 0, CompScreen::showDesktop, 0 },
@@ -568,9 +542,6 @@ const CompMetadata::OptionInfo coreOptionInfo[COMP_OPTION_NUM] = {
{ "hide_skip_taskbar_windows", "bool", 0, 0, 0 },
{ "toggle_window_shaded_key", "key", 0, CompScreen::shadeWin, 0 },
{ "ignore_hints_when_maximized", "bool", 0, 0, 0 },
- { "command_terminal", "string", 0, 0, 0 },
- { "run_command_terminal_key", "key", 0,
- CompScreen::runCommandTerminal, 0 },
{ "ping_delay", "int", "<min>1000</min>", 0, 0 },
{ "edge_delay", "int", "<min>0</min>", 0, 0 },
{ "hsize", "int", "<min>1</min><max>32</max>", 0, 0 },
@@ -654,7 +625,6 @@ CompScreen::dpy ()
return priv->dpy;
}
-
CompOption *
CompScreen::getOption (const char *name)
{
@@ -692,7 +662,6 @@ CompScreen::syncEvent ()
return priv->syncEvent;
}
-
SnDisplay *
CompScreen::snDisplay ()
{
@@ -732,8 +701,6 @@ PrivateScreen::updateScreenInfo ()
}
}
-
-
void
PrivateScreen::setAudibleBell (bool audible)
{
@@ -838,7 +805,8 @@ CompScreen::setOption (const char *name,
if (o->value ().i () * width () > MAXSHORT)
return false;
- priv->setVirtualScreenSize (o->value ().i (), vsize->value ().i ());
+ priv->setVirtualScreenSize (o->value ().i (),
+ vsize->value ().i ());
return true;
}
break;
@@ -855,7 +823,8 @@ CompScreen::setOption (const char *name,
if (o->value ().i () * height () > MAXSHORT)
return false;
- priv->setVirtualScreenSize (hsize->value ().i (), o->value ().i ());
+ priv->setVirtualScreenSize (hsize->value ().i (),
+ o->value ().i ());
return true;
}
break;
@@ -900,38 +869,36 @@ PrivateScreen::updateModifierMappings ()
for (i = 0; i < CompModNum; i++)
modMask[i] = 0;
- XDisplayKeycodes (this->dpy, &minKeycode, &maxKeycode);
- key = XGetKeyboardMapping (this->dpy,
- minKeycode, (maxKeycode - minKeycode + 1),
+ XDisplayKeycodes (dpy, &minKeycode, &maxKeycode);
+ key = XGetKeyboardMapping (dpy, minKeycode, maxKeycode - minKeycode + 1,
&keysymsPerKeycode);
- if (this->modMap)
- XFreeModifiermap (this->modMap);
+ if (modMap)
+ XFreeModifiermap (modMap);
- this->modMap = XGetModifierMapping (this->dpy);
- if (this->modMap && this->modMap->max_keypermod > 0)
+ modMap = XGetModifierMapping (dpy);
+ if (modMap && modMap->max_keypermod > 0)
{
KeySym keysym;
int index, size, mask;
- size = maskTableSize * this->modMap->max_keypermod;
+ size = maskTableSize * modMap->max_keypermod;
for (i = 0; i < size; i++)
{
- if (!this->modMap->modifiermap[i])
+ if (!modMap->modifiermap[i])
continue;
index = 0;
do
{
- keysym = XKeycodeToKeysym (this->dpy,
- this->modMap->modifiermap[i],
+ keysym = XKeycodeToKeysym (dpy, modMap->modifiermap[i],
index++);
} while (!keysym && index < keysymsPerKeycode);
if (keysym)
{
- mask = maskTable[i / this->modMap->max_keypermod];
+ mask = maskTable[i / modMap->max_keypermod];
if (keysym == XK_Alt_L ||
keysym == XK_Alt_R)
@@ -978,11 +945,11 @@ PrivateScreen::updateModifierMappings ()
{
memcpy (this->modMask, modMask, sizeof (modMask));
- this->ignoredModMask = LockMask |
+ ignoredModMask = LockMask |
(modMask[CompModNumLock] & ~CompNoMask) |
(modMask[CompModScrollLock] & ~CompNoMask);
- this->updatePassiveKeyGrabs ();
+ updatePassiveKeyGrabs ();
}
}
@@ -1174,11 +1141,11 @@ PrivateScreen::updatePlugins ()
/* from fvwm2, Copyright Matthias Clasen, Dominik Vogt */
static bool
-convertProperty (Display *dpy,
- Time time,
- Window w,
- Atom target,
- Atom property)
+convertProperty (Display *dpy,
+ Time time,
+ Window w,
+ Atom target,
+ Atom property)
{
#define N_TARGETS 4
@@ -1303,7 +1270,6 @@ PrivateScreen::handleSelectionClear (XEvent *event)
shutDown = TRUE;
}
-
#define HOME_IMAGEDIR ".compiz/images"
bool
@@ -1373,14 +1339,13 @@ PrivateScreen::getActiveWindow (Window root)
return w;
}
-
bool
CompScreen::fileToImage (CompString &name,
CompSize &size,
int &stride,
void *&data)
{
- WRAPABLE_HND_FUNC_RETURN(8, bool, fileToImage, name, size, stride, data);
+ WRAPABLE_HND_FUNC_RETURN (8, bool, fileToImage, name, size, stride, data);
return false;
}
@@ -1391,8 +1356,8 @@ CompScreen::imageToFile (CompString &path,
int stride,
void *data)
{
- WRAPABLE_HND_FUNC_RETURN(9, bool, imageToFile, path, format, size,
- stride, data)
+ WRAPABLE_HND_FUNC_RETURN (9, bool, imageToFile, path, format, size,
+ stride, data)
return false;
}
@@ -1422,6 +1387,9 @@ logMessage (const char *componentName,
CompLogLevel level,
const char *message)
{
+ if (!debugOutput && level >= CompLogLevelDebug)
+ return;
+
fprintf (stderr, "%s (%s) - %s: %s\n",
programName, componentName,
logLevelToString (level), message);
@@ -1437,7 +1405,7 @@ CompScreen::logMessage (const char *componentName,
}
void
-compLogMessage (const char *componentName,
+compLogMessage (const char *componentName,
CompLogLevel level,
const char *format,
...)
@@ -1869,7 +1837,7 @@ ScreenInterface::imageToFile (CompString &path,
WRAPABLE_DEF (imageToFile, path, format, size, stride, data)
CompMatch::Expression *
-ScreenInterface::matchInitExp (const CompString value)
+ScreenInterface::matchInitExp (const CompString& value)
WRAPABLE_DEF (matchInitExp, value)
void
@@ -1993,14 +1961,12 @@ PrivateScreen::setVirtualScreenSize (int newh, int newv)
void
PrivateScreen::updateOutputDevices ()
{
- CompOption::Value::Vector &list =
- opt[COMP_OPTION_OUTPUTS].value ().list ();
-
- unsigned int nOutput = 0;
- int x, y, bits;
- unsigned int width, height;
- int x1, y1, x2, y2;
- char str[10];
+ CompOption::Value::Vector &list = opt[COMP_OPTION_OUTPUTS].value ().list ();
+ unsigned int nOutput = 0;
+ int x, y, bits;
+ unsigned int width, height;
+ int x1, y1, x2, y2;
+ char str[10];
foreach (CompOption::Value &value, list)
{
@@ -2061,11 +2027,16 @@ PrivateScreen::updateOutputDevices ()
outputDevs[i].setId (str, i);
}
-
hasOverlappingOutputs = false;
setCurrentOutput (currentOutputDev);
+ /* clear out fullscreen monitor hints of all windows as
+ suggested on monitor layout changes in EWMH */
+ foreach (CompWindow *w, windows)
+ if (w->priv->fullscreenMonitorsSet)
+ w->priv->setFullscreenMonitors (NULL);
+
updateWorkarea ();
screen->outputChangeNotify ();
@@ -2165,9 +2136,7 @@ PrivateScreen::addSequence (SnStartupSequence *sequence)
startupSequences.push_front (s);
if (!startupSequenceTimer.active ())
- startupSequenceTimer.start (
- boost::bind (&PrivateScreen::handleStartupSequenceTimeout, this),
- 1000, 1500);
+ startupSequenceTimer.start ();
updateStartupFeedback ();
}
@@ -2215,7 +2184,7 @@ CompScreen::compScreenSnEvent (SnMonitorEvent *event,
screen->priv->addSequence (sequence);
break;
case SN_MONITOR_EVENT_COMPLETED:
- screen->priv->removeSequence (sn_monitor_event_get_startup_sequence (event));
+ screen->priv->removeSequence (sequence);
break;
case SN_MONITOR_EVENT_CHANGED:
case SN_MONITOR_EVENT_CANCELED:
@@ -2247,14 +2216,17 @@ PrivateScreen::updateScreenEdges ()
{
if (screenEdge[i].id)
XMoveResizeWindow (dpy, screenEdge[i].id,
- geometry[i].xw * screen->width () + geometry[i].x0,
- geometry[i].yh * screen->height () + geometry[i].y0,
- geometry[i].ww * screen->width () + geometry[i].w0,
- geometry[i].hh * screen->height () + geometry[i].h0);
+ geometry[i].xw * screen->width () +
+ geometry[i].x0,
+ geometry[i].yh * screen->height () +
+ geometry[i].y0,
+ geometry[i].ww * screen->width () +
+ geometry[i].w0,
+ geometry[i].hh * screen->height () +
+ geometry[i].h0);
}
}
-
void
PrivateScreen::setCurrentOutput (unsigned int outputNum)
{
@@ -2295,8 +2267,6 @@ PrivateScreen::configure (XConfigureEvent *ce)
}
}
-
-
void
PrivateScreen::setSupportingWmCheck ()
{
@@ -2422,6 +2392,8 @@ PrivateScreen::setSupported ()
data[i++] = Atoms::moveResizeWindow;
data[i++] = Atoms::restackWindow;
+ data[i++] = Atoms::wmFullscreenMonitors;
+
XChangeProperty (dpy, root, Atoms::supported,
XA_ATOM, 32, PropModeReplace, (unsigned char *) data, i);
}
@@ -2772,8 +2744,11 @@ CompScreen::insertWindow (CompWindow *w, Window aboveId)
while (it != priv->windows.end ())
{
- if ((*it)->id () == aboveId || ((*it)->frame () && (*it)->frame () == aboveId))
+ if ((*it)->id () == aboveId ||
+ ((*it)->frame () && (*it)->frame () == aboveId))
+ {
break;
+ }
it++;
}
@@ -2917,12 +2892,12 @@ CompScreen::removeGrab (CompScreen::GrabHandle handle,
}
else
{
- if (restorePointer)
- warpPointer (restorePointer->x () - pointerX,
- restorePointer->y () - pointerY);
+ if (restorePointer)
+ warpPointer (restorePointer->x () - pointerX,
+ restorePointer->y () - pointerY);
- XUngrabPointer (priv->dpy, CurrentTime);
- XUngrabKeyboard (priv->dpy, CurrentTime);
+ XUngrabPointer (priv->dpy, CurrentTime);
+ XUngrabKeyboard (priv->dpy, CurrentTime);
}
}
@@ -3329,6 +3304,13 @@ PrivateScreen::computeWorkareaForBox (BoxPtr pBox,
}
}
+ if (XEmptyRegion (region))
+ {
+ compLogMessage ("core", CompLogLevelWarn,
+ "Empty box after applying struts, ignoring struts");
+ region->extents = *pBox;
+ }
+
area->x = region->extents.x1;
area->y = region->extents.y1;
area->width = region->extents.x2 - region->extents.x1;
@@ -3744,7 +3726,6 @@ CompScreen::sendWindowActivationRequest (Window id)
SubstructureRedirectMask | SubstructureNotifyMask, &xev);
}
-
void
PrivateScreen::enableEdge (int edge)
{
@@ -3860,8 +3841,6 @@ CompScreen::getWorkareaForOutput (int output, XRectangle *area)
*area = priv->outputDevs[output].workArea ();
}
-
-
void
CompScreen::outputChangeNotify ()
WRAPABLE_HND_FUNC(16, outputChangeNotify)
@@ -3875,8 +3854,7 @@ CompScreen::outputChangeNotify ()
located. */
void
CompScreen::viewportForGeometry (CompWindow::Geometry gm,
- int *viewportX,
- int *viewportY)
+ CompPoint& viewport)
{
int centerX;
int centerY;
@@ -3884,40 +3862,34 @@ CompScreen::viewportForGeometry (CompWindow::Geometry gm,
gm.setWidth (gm.width () + (gm.border () * 2));
gm.setHeight (gm.height () + (gm.border () * 2));
- if (viewportX)
- {
- centerX = gm.x () + (gm.width () >> 1);
- if (centerX < 0)
- *viewportX = priv->vp.x () + ((centerX / width ()) - 1) %
- priv->vpSize.width ();
- else
- *viewportX = priv->vp.x () + (centerX / width ()) %
- priv->vpSize.width ();
- }
+ centerX = gm.x () + (gm.width () >> 1);
+ if (centerX < 0)
+ viewport.setX (priv->vp.x () + ((centerX / width ()) - 1) %
+ priv->vpSize.width ());
+ else
+ viewport.setX (priv->vp.x () + (centerX / width ()) %
+ priv->vpSize.width ());
- if (viewportY)
- {
- centerY = gm.y () + (gm.height () >> 1);
- if (centerY < 0)
- *viewportY = priv->vp.y () +
- ((centerY / height ()) - 1) % priv->vpSize.height ();
- else
- *viewportY = priv->vp.y () + (centerY / height ()) %
- priv->vpSize.height ();
- }
+ centerY = gm.y () + (gm.height () >> 1);
+ if (centerY < 0)
+ viewport.setY (priv->vp.y () +
+ ((centerY / height ()) - 1) % priv->vpSize.height ());
+ else
+ viewport.setY (priv->vp.y () + (centerY / height ()) %
+ priv->vpSize.height ());
}
static int
-rectangleOverlapArea (BOX *rect1,
- BOX *rect2)
+rectangleOverlapArea (BOX& rect1,
+ BOX& rect2)
{
int left, right, top, bottom;
/* extents of overlapping rectangle */
- left = MAX (rect1->x1, rect2->x1);
- right = MIN (rect1->x2, rect2->x2);
- top = MAX (rect1->y1, rect2->y1);
- bottom = MIN (rect1->y2, rect2->y2);
+ left = MAX (rect1.x1, rect2.x1);
+ right = MIN (rect1.x2, rect2.x2);
+ top = MAX (rect1.y1, rect2.y1);
+ bottom = MIN (rect1.y2, rect2.y2);
if (left > right || top > bottom)
{
@@ -3986,16 +3958,19 @@ CompScreen::outputDeviceForGeometry (CompWindow::Geometry gm)
/* get amount of overlap on all output devices */
for (i = 0; i < priv->outputDevs.size (); i++)
overlapAreas[i] =
- rectangleOverlapArea (&priv->outputDevs[i].region ()->extents,
- &geomRect);
+ rectangleOverlapArea (priv->outputDevs[i].region ()->extents,
+ geomRect);
/* find output with largest overlap */
- for (i = 0, highest = 0, highestScore = 0; i < priv->outputDevs.size (); i++)
+ for (i = 0, highest = 0, highestScore = 0;
+ i < priv->outputDevs.size (); i++)
+ {
if (overlapAreas[i] > highestScore)
{
highest = i;
highestScore = overlapAreas[i];
}
+ }
/* look if the highest score is unique */
for (i = 0, seen = 0; i < priv->outputDevs.size (); i++)
@@ -4146,7 +4121,8 @@ CompScreen::xkbEvent ()
}
void
-CompScreen::warpPointer (int dx, int dy)
+CompScreen::warpPointer (int dx,
+ int dy)
{
XEvent event;
@@ -4258,7 +4234,6 @@ CompScreen::workArea ()
return priv->workArea;
}
-
unsigned int
CompScreen::currentDesktop ()
{
@@ -4327,7 +4302,7 @@ CompScreen::screenInfo ()
}
CompScreen::CompScreen ():
- CompPrivateStorage (&screenPrivateIndices)
+ CompPrivateStorage (screenPrivateIndices)
{
priv = new PrivateScreen (this);
assert (priv);
@@ -4450,22 +4425,10 @@ CompScreen::init (const char *name)
&priv->xineramaEvent,
&priv->xineramaError);
-
priv->updateScreenInfo();
- priv->escapeKeyCode =
- XKeysymToKeycode (dpy, XStringToKeysym ("Escape"));
- priv->returnKeyCode =
- XKeysymToKeycode (dpy, XStringToKeysym ("Return"));
-
-
-
-
-
-
-
-
-
+ priv->escapeKeyCode = XKeysymToKeycode (dpy, XStringToKeysym ("Escape"));
+ priv->returnKeyCode = XKeysymToKeycode (dpy, XStringToKeysym ("Return"));
sprintf (buf, "WM_S%d", DefaultScreen (dpy));
wmSnAtom = XInternAtom (dpy, buf, 0);
@@ -4685,9 +4648,11 @@ CompScreen::init (const char *name)
{
long xdndVersion = 3;
- priv->screenEdge[i].id = XCreateWindow (dpy, priv->root, -100, -100, 1, 1, 0,
+ priv->screenEdge[i].id = XCreateWindow (dpy, priv->root,
+ -100, -100, 1, 1, 0,
CopyFromParent, InputOnly,
- CopyFromParent, CWOverrideRedirect,
+ CopyFromParent,
+ CWOverrideRedirect,
&attrib);
XChangeProperty (dpy, priv->screenEdge[i].id, Atoms::xdndAware,
@@ -4715,15 +4680,13 @@ CompScreen::init (const char *name)
XUngrabServer (dpy);
- priv->setAudibleBell (
- priv->opt[COMP_OPTION_AUDIBLE_BELL].value ().b ());
+ priv->setAudibleBell (priv->opt[COMP_OPTION_AUDIBLE_BELL].value ().b ());
XGetInputFocus (dpy, &focus, &revertTo);
/* move input focus to root window so that we get a FocusIn event when
moving it to the default window */
- XSetInputFocus (dpy, priv->root,
- RevertToPointerRoot, CurrentTime);
+ XSetInputFocus (dpy, priv->root, RevertToPointerRoot, CurrentTime);
if (focus == None || focus == PointerRoot)
{
@@ -4735,18 +4698,17 @@ CompScreen::init (const char *name)
w = findWindow (focus);
if (w)
- {
w->moveInputFocusTo ();
- }
else
focusDefaultWindow ();
}
- priv->pingTimer.start (
- boost::bind(&PrivateScreen::handlePingTimeout, priv),
+ priv->pingTimer.setTimes (
priv->opt[COMP_OPTION_PING_DELAY].value ().i (),
priv->opt[COMP_OPTION_PING_DELAY].value ().i () + 500);
+ priv->pingTimer.start ();
+
priv->initialized = true;
priv->addScreenActions ();
@@ -4789,15 +4751,15 @@ CompScreen::~CompScreen ()
if (priv->snDisplay)
sn_display_unref (priv->snDisplay);
- XSync (priv->dpy, False);
- XCloseDisplay (priv->dpy);
-
if (priv->modMap)
XFreeModifiermap (priv->modMap);
if (priv->watchPollFds)
free (priv->watchPollFds);
+ XSync (priv->dpy, False);
+ XCloseDisplay (priv->dpy);
+
delete priv;
screen = NULL;
@@ -4859,6 +4821,13 @@ PrivateScreen::PrivateScreen (CompScreen *screen) :
modMask[i] = CompNoMask;
memset (history, 0, sizeof (history));
gettimeofday (&lastTimeout, 0);
+
+ pingTimer.setCallback (
+ boost::bind(&PrivateScreen::handlePingTimeout, this));
+
+ startupSequenceTimer.setCallback (
+ boost::bind (&PrivateScreen::handleStartupSequenceTimeout, this));
+ startupSequenceTimer.setTimes (1000, 1500);
}
PrivateScreen::~PrivateScreen ()
diff --git a/src/window.cpp b/src/window.cpp
index 83bb4fa..f511520 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -46,23 +46,25 @@
#include "privatewindow.h"
#include "privatescreen.h"
-
CompPrivateStorage::Indices windowPrivateIndices (0);
int
CompWindow::allocPrivateIndex ()
{
- int i = CompPrivateStorage::allocatePrivateIndex (&windowPrivateIndices);
- foreach (CompWindow *w, ::screen->windows ())
+ int i = CompPrivateStorage::allocatePrivateIndex (windowPrivateIndices);
+
+ foreach (CompWindow *w, screen->windows ())
if (windowPrivateIndices.size () != w->privates.size ())
w->privates.resize (windowPrivateIndices.size ());
+
return i;
}
void
CompWindow::freePrivateIndex (int index)
{
- CompPrivateStorage::freePrivateIndex (&windowPrivateIndices, index);
+ CompPrivateStorage::freePrivateIndex (windowPrivateIndices, index);
+
foreach (CompWindow *w, ::screen->windows ())
if (windowPrivateIndices.size () != w->privates.size ())
w->privates.resize (windowPrivateIndices.size ());
@@ -91,7 +93,7 @@ PrivateWindow::recalcNormalHints ()
int maxSize;
#warning fixme to max Texture size
- maxSize = MAXSHORT;
+ maxSize = MAXSHORT;
maxSize -= serverGeometry.border () * 2;
sizeHints.x = serverGeometry.x ();
@@ -223,16 +225,47 @@ PrivateWindow::updateNormalHints ()
void
PrivateWindow::updateWmHints ()
{
- XWMHints *hints;
+ XWMHints *newHints;
+ long dFlags = 0;
+ bool iconChanged = false;
- hints = XGetWMHints (screen->dpy (), priv->id);
if (hints)
+ dFlags = hints->flags;
+
+ inputHint = true;
+
+ newHints = XGetWMHints (screen->dpy (), id);
+ if (newHints)
{
- if (hints->flags & InputHint)
- priv->inputHint = hints->input;
+ dFlags ^= newHints->flags;
- XFree (hints);
+ if (newHints->flags & InputHint)
+ inputHint = newHints->input;
+
+ if (hints)
+ {
+ if ((newHints->flags & IconPixmapHint) &&
+ (hints->icon_pixmap != newHints->icon_pixmap))
+ {
+ iconChanged = true;
+ }
+ else if ((newHints->flags & IconMaskHint) &&
+ (hints->icon_mask != newHints->icon_mask))
+ {
+ iconChanged = true;
+ }
+ }
}
+
+ iconChanged |= (dFlags & (IconPixmapHint | IconMaskHint));
+
+ if (iconChanged)
+ freeIcons ();
+
+ if (hints)
+ XFree (hints);
+
+ hints = newHints;
}
void
@@ -325,7 +358,7 @@ PrivateWindow::updateIconGeometry ()
priv->iconGeometry.width = geometry[2];
priv->iconGeometry.height = geometry[3];
- priv->iconGeometrySet = TRUE;
+ priv->iconGeometrySet = true;
}
XFree (data);
@@ -409,6 +442,55 @@ PrivateWindow::getStartupId ()
}
void
+PrivateWindow::setFullscreenMonitors (CompFullscreenMonitorSet *monitors)
+{
+ bool hadFsMonitors = fullscreenMonitorsSet;
+ unsigned int outputs = screen->outputDevs ().size ();
+
+ fullscreenMonitorsSet = false;
+
+ if (monitors &&
+ monitors->left < outputs &&
+ monitors->right < outputs &&
+ monitors->top < outputs &&
+ monitors->bottom < outputs)
+ {
+ CompRect fsRect (screen->outputDevs ()[monitors->left].x1 (),
+ screen->outputDevs ()[monitors->top].y1 (),
+ screen->outputDevs ()[monitors->right].x2 (),
+ screen->outputDevs ()[monitors->bottom].y2 ());
+
+ if (fsRect.x1 () < fsRect.x2 () && fsRect.y1 () < fsRect.y2 ())
+ {
+ fullscreenMonitorsSet = true;
+ fullscreenMonitorRect = fsRect;
+ }
+ }
+
+ if (fullscreenMonitorsSet)
+ {
+ long data[4];
+
+ data[0] = monitors->top;
+ data[1] = monitors->bottom;
+ data[2] = monitors->left;
+ data[3] = monitors->right;
+
+ XChangeProperty (screen->dpy (), id, Atoms::wmFullscreenMonitors,
+ XA_CARDINAL, 32, PropModeReplace,
+ (unsigned char *) data, 4);
+ }
+ else if (hadFsMonitors)
+ {
+ XDeleteProperty (screen->dpy (), id, Atoms::wmFullscreenMonitors);
+ }
+
+ if (state & CompWindowStateFullscreenMask)
+ if (fullscreenMonitorsSet || hadFsMonitors)
+ window->updateAttributes (CompStackingUpdateModeNone);
+}
+
+void
CompWindow::changeState (unsigned int newState)
{
unsigned int oldState;
@@ -579,7 +661,8 @@ void
CompWindow::getAllowedActions (unsigned int &setActions,
unsigned int &clearActions)
{
- WRAPABLE_HND_FUNC(1, getAllowedActions, setActions, clearActions)
+ WRAPABLE_HND_FUNC (1, getAllowedActions, setActions, clearActions)
+
setActions = 0;
clearActions = 0;
}
@@ -665,12 +748,17 @@ CompWindow::recalcType ()
type = CompWindowTypeDialogMask;
}
- if (type == CompWindowTypeDockMask && (priv->state & CompWindowStateBelowMask))
+ if (type == CompWindowTypeDockMask &&
+ (priv->state & CompWindowStateBelowMask))
+ {
type = CompWindowTypeNormalMask;
+ }
if ((type & (CompWindowTypeNormalMask | CompWindowTypeDialogMask)) &&
(priv->state & CompWindowStateModalMask))
+ {
type = CompWindowTypeModalDialogMask;
+ }
priv->type = type;
}
@@ -725,7 +813,7 @@ CompWindow::updateWindowOutputExtents ()
{
CompWindowExtents output;
- getOutputExtents (&output);
+ getOutputExtents (output);
if (output.left != priv->output.left ||
output.right != priv->output.right ||
@@ -739,13 +827,14 @@ CompWindow::updateWindowOutputExtents ()
}
void
-CompWindow::getOutputExtents (CompWindowExtents *output)
+CompWindow::getOutputExtents (CompWindowExtents& output)
{
- WRAPABLE_HND_FUNC(0, getOutputExtents, output)
- output->left = 0;
- output->right = 0;
- output->top = 0;
- output->bottom = 0;
+ WRAPABLE_HND_FUNC (0, getOutputExtents, output)
+
+ output.left = 0;
+ output.right = 0;
+ output.top = 0;
+ output.bottom = 0;
}
void
@@ -821,18 +910,16 @@ PrivateWindow::updateStruts ()
unsigned long n, left;
unsigned char *data;
bool hasOld, hasNew;
- CompStruts old, c_new;
-
-#define MIN_EMPTY 76
+ CompStruts oldStrut, newStrut;
if (priv->struts)
{
hasOld = true;
- old.left = priv->struts->left;
- old.right = priv->struts->right;
- old.top = priv->struts->top;
- old.bottom = priv->struts->bottom;
+ oldStrut.left = priv->struts->left;
+ oldStrut.right = priv->struts->right;
+ oldStrut.top = priv->struts->top;
+ oldStrut.bottom = priv->struts->bottom;
}
else
{
@@ -841,25 +928,25 @@ PrivateWindow::updateStruts ()
hasNew = true;
- c_new.left.x = 0;
- c_new.left.y = 0;
- c_new.left.width = 0;
- c_new.left.height = screen->height ();
+ newStrut.left.x = 0;
+ newStrut.left.y = 0;
+ newStrut.left.width = 0;
+ newStrut.left.height = screen->height ();
- c_new.right.x = screen->width ();
- c_new.right.y = 0;
- c_new.right.width = 0;
- c_new.right.height = screen->height ();
+ newStrut.right.x = screen->width ();
+ newStrut.right.y = 0;
+ newStrut.right.width = 0;
+ newStrut.right.height = screen->height ();
- c_new.top.x = 0;
- c_new.top.y = 0;
- c_new.top.width = screen->width ();
- c_new.top.height = 0;
+ newStrut.top.x = 0;
+ newStrut.top.y = 0;
+ newStrut.top.width = screen->width ();
+ newStrut.top.height = 0;
- c_new.bottom.x = 0;
- c_new.bottom.y = screen->height ();
- c_new.bottom.width = screen->width ();
- c_new.bottom.height = 0;
+ newStrut.bottom.x = 0;
+ newStrut.bottom.y = screen->height ();
+ newStrut.bottom.width = screen->width ();
+ newStrut.bottom.height = 0;
result = XGetWindowProperty (screen->dpy (), priv->id,
Atoms::wmStrutPartial,
@@ -872,35 +959,25 @@ PrivateWindow::updateStruts ()
if (n == 12)
{
- int gap;
-
hasNew = true;
- gap = screen->width () - struts[0] - struts[1];
- gap -= MIN_EMPTY;
-
- c_new.left.width = (int) struts[0] + MIN (0, gap / 2);
- c_new.right.width = (int) struts[1] + MIN (0, gap / 2);
-
- gap = screen->height () - struts[2] - struts[3];
- gap -= MIN_EMPTY;
+ newStrut.left.y = struts[4];
+ newStrut.left.width = struts[0];
+ newStrut.left.height = struts[5] - newStrut.left.y + 1;
- c_new.top.height = (int) struts[2] + MIN (0, gap / 2);
- c_new.bottom.height = (int) struts[3] + MIN (0, gap / 2);
+ newStrut.right.width = struts[1];
+ newStrut.right.x = screen->width () - newStrut.right.width;
+ newStrut.right.y = struts[6];
+ newStrut.right.height = struts[7] - newStrut.right.y + 1;
- c_new.right.x = screen->width () - c_new.right.width;
- c_new.bottom.y = screen->height () -
- c_new.bottom.height;
+ newStrut.top.x = struts[8];
+ newStrut.top.width = struts[9] - newStrut.top.x + 1;
+ newStrut.top.height = struts[2];
- c_new.left.y = struts[4];
- c_new.left.height = struts[5] - c_new.left.y + 1;
- c_new.right.y = struts[6];
- c_new.right.height = struts[7] - c_new.right.y + 1;
-
- c_new.top.x = struts[8];
- c_new.top.width = struts[9] - c_new.top.x + 1;
- c_new.bottom.x = struts[10];
- c_new.bottom.width = struts[11] - c_new.bottom.x + 1;
+ newStrut.bottom.x = struts[10];
+ newStrut.bottom.width = struts[11] - newStrut.bottom.x + 1;
+ newStrut.bottom.height = struts[3];
+ newStrut.bottom.y = screen->height () - newStrut.bottom.height;
}
XFree (data);
@@ -919,29 +996,19 @@ PrivateWindow::updateStruts ()
if (n == 4)
{
- int gap;
-
hasNew = true;
- gap = screen->width () - struts[0] - struts[1];
- gap -= MIN_EMPTY;
-
- c_new.left.width = (int) struts[0] + MIN (0, gap / 2);
- c_new.right.width = (int) struts[1] + MIN (0, gap / 2);
+ newStrut.left.x = 0;
+ newStrut.left.width = struts[0];
- gap = screen->height () - struts[2] - struts[3];
- gap -= MIN_EMPTY;
+ newStrut.right.width = struts[1];
+ newStrut.right.x = screen->width () - newStrut.right.width;
- c_new.top.height = (int) struts[2] + MIN (0, gap / 2);
- c_new.bottom.height = (int) struts[3] + MIN (0, gap / 2);
+ newStrut.top.y = 0;
+ newStrut.top.height = struts[2];
- c_new.left.x = 0;
- c_new.right.x = screen->width () -
- c_new.right.width;
-
- c_new.top.y = 0;
- c_new.bottom.y = screen->height () -
- c_new.bottom.height;
+ newStrut.bottom.height = struts[3];
+ newStrut.bottom.y = screen->height () - newStrut.bottom.height;
}
XFree (data);
@@ -962,46 +1029,59 @@ PrivateWindow::updateStruts ()
x2 = x1 + screen->screenInfo ()[i].width;
y2 = y1 + screen->screenInfo ()[i].height;
- strutX1 = c_new.left.x;
- strutX2 = strutX1 + c_new.left.width;
+ strutX1 = newStrut.left.x;
+ strutX2 = strutX1 + newStrut.left.width;
+ strutY1 = newStrut.left.y;
+ strutY2 = strutY1 + newStrut.left.height;
- if (strutX2 > x1 && strutX2 <= x2)
+ if (strutX2 > x1 && strutX2 <= x2 &&
+ strutY1 < y2 && strutY2 > y1)
{
- c_new.left.x = x1;
- c_new.left.width = strutX2 - x1;
+ newStrut.left.x = x1;
+ newStrut.left.width = strutX2 - x1;
}
- strutX1 = c_new.right.x;
- strutX2 = strutX1 + c_new.right.width;
+ strutX1 = newStrut.right.x;
+ strutX2 = strutX1 + newStrut.right.width;
+ strutY1 = newStrut.right.y;
+ strutY2 = strutY1 + newStrut.right.height;
- if (strutX1 > x1 && strutX1 <= x2)
+ if (strutX1 > x1 && strutX1 <= x2 &&
+ strutY1 < y2 && strutY2 > y1)
{
- c_new.right.x = strutX1;
- c_new.right.width = x2 - strutX1;
+ newStrut.right.x = strutX1;
+ newStrut.right.width = x2 - strutX1;
}
- strutY1 = c_new.top.y;
- strutY2 = strutY1 + c_new.top.height;
+ strutX1 = newStrut.top.x;
+ strutX2 = strutX1 + newStrut.top.width;
+ strutY1 = newStrut.top.y;
+ strutY2 = strutY1 + newStrut.top.height;
- if (strutY2 > y1 && strutY2 <= y2)
+ if (strutX1 < x2 && strutX2 > x1 &&
+ strutY2 > y1 && strutY2 <= y2)
{
- c_new.top.y = y1;
- c_new.top.height = strutY2 - y1;
+ newStrut.top.y = y1;
+ newStrut.top.height = strutY2 - y1;
}
- strutY1 = c_new.bottom.y;
- strutY2 = strutY1 + c_new.bottom.height;
+ strutX1 = newStrut.bottom.x;
+ strutX2 = strutX1 + newStrut.bottom.width;
+ strutY1 = newStrut.bottom.y;
+ strutY2 = strutY1 + newStrut.bottom.height;
- if (strutY1 > y1 && strutY1 <= y2)
+ if (strutX1 < x2 && strutX2 > x1 &&
+ strutY1 > y1 && strutY1 <= y2)
{
- c_new.bottom.y = strutY1;
- c_new.bottom.height = y2 - strutY1;
+ newStrut.bottom.y = strutY1;
+ newStrut.bottom.height = y2 - strutY1;
}
}
}
- if (hasOld != hasNew || (hasNew && hasOld &&
- memcmp (&c_new, &old, sizeof (CompStruts))))
+ if (hasOld != hasNew ||
+ (hasNew && hasOld &&
+ memcmp (&newStrut, &oldStrut, sizeof (CompStruts))))
{
if (hasNew)
{
@@ -1012,7 +1092,7 @@ PrivateWindow::updateStruts ()
return false;
}
- *priv->struts = c_new;
+ *priv->struts = newStrut;
}
else
{
@@ -1054,8 +1134,6 @@ setDefaultWindowAttributes (XWindowAttributes *wa)
wa->screen = NULL;
}
-
-
void
CompWindow::destroy ()
{
@@ -1251,7 +1329,10 @@ CompWindow::resize (XWindowAttributes attr)
}
bool
-CompWindow::resize (int x, int y, unsigned int width, unsigned int height,
+CompWindow::resize (int x,
+ int y,
+ unsigned int width,
+ unsigned int height,
unsigned int border)
{
return resize (Geometry (x, y, width, height, border));
@@ -1271,9 +1352,7 @@ CompWindow::resize (CompWindow::Geometry gm)
ph = gm.height () + gm.border () * 2;
if (priv->shaded)
- {
ph = 0;
- }
dx = gm.x () - priv->attrib.x;
dy = gm.y () - priv->attrib.y;
@@ -1422,15 +1501,13 @@ CompWindow::sendSyncRequest ()
syncValueIncrement (&priv->syncValue);
- XSendEvent (screen->dpy (), priv->id, FALSE, 0,
- (XEvent *) &xev);
+ XSendEvent (screen->dpy (), priv->id, FALSE, 0, (XEvent *) &xev);
- priv->syncWait = TRUE;
+ priv->syncWait = true;
priv->syncGeometry = priv->serverGeometry;
if (!priv->syncWaitTimer.active ())
- priv->syncWaitTimer.start (
- boost::bind (&PrivateWindow::handleSyncAlarm, priv), 1000, 1200);
+ priv->syncWaitTimer.start ();
}
void
@@ -1505,7 +1582,9 @@ PrivateWindow::circulate (XCirculateEvent *ce)
}
void
-CompWindow::move (int dx, int dy, bool immediate)
+CompWindow::move (int dx,
+ int dy,
+ bool immediate)
{
if (dx || dy)
{
@@ -1546,7 +1625,7 @@ CompWindow::syncPosition ()
bool
CompWindow::focus ()
{
- WRAPABLE_HND_FUNC_RETURN(2, bool, focus)
+ WRAPABLE_HND_FUNC_RETURN (2, bool, focus)
if (overrideRedirect ())
return false;
@@ -1572,7 +1651,7 @@ CompWindow::focus ()
bool
CompWindow::place (CompPoint &pos)
{
- WRAPABLE_HND_FUNC_RETURN(4, bool, place, pos)
+ WRAPABLE_HND_FUNC_RETURN (4, bool, place, pos)
return false;
}
@@ -1580,45 +1659,45 @@ void
CompWindow::validateResizeRequest (unsigned int &mask,
XWindowChanges *xwc,
unsigned int source)
- WRAPABLE_HND_FUNC(5, validateResizeRequest, mask, xwc, source)
+ WRAPABLE_HND_FUNC (5, validateResizeRequest, mask, xwc, source)
void
CompWindow::resizeNotify (int dx,
int dy,
int dwidth,
int dheight)
- WRAPABLE_HND_FUNC(6, resizeNotify, dx, dy, dwidth, dheight)
+ WRAPABLE_HND_FUNC (6, resizeNotify, dx, dy, dwidth, dheight)
void
CompWindow::moveNotify (int dx,
int dy,
bool immediate)
- WRAPABLE_HND_FUNC(7, moveNotify, dx, dy, immediate)
+ WRAPABLE_HND_FUNC (7, moveNotify, dx, dy, immediate)
void
CompWindow::windowNotify (CompWindowNotify n)
WRAPABLE_HND_FUNC (8, windowNotify, n)
void
-CompWindow::grabNotify (int x,
- int y,
+CompWindow::grabNotify (int x,
+ int y,
unsigned int state,
unsigned int mask)
{
- WRAPABLE_HND_FUNC(9, grabNotify, x, y, state, mask)
+ WRAPABLE_HND_FUNC (9, grabNotify, x, y, state, mask)
priv->grabbed = true;
}
void
CompWindow::ungrabNotify ()
{
- WRAPABLE_HND_FUNC(10, ungrabNotify)
+ WRAPABLE_HND_FUNC (10, ungrabNotify)
priv->grabbed = false;
}
void
CompWindow::stateChangeNotify (unsigned int lastState)
- WRAPABLE_HND_FUNC(11, stateChangeNotify, lastState);
+ WRAPABLE_HND_FUNC (11, stateChangeNotify, lastState);
bool
PrivateWindow::isGroupTransient (Window clientLeader)
@@ -1712,7 +1791,8 @@ CompWindow::moveInputFocusTo ()
if (priv->state & CompWindowStateHiddenMask)
{
- XSetInputFocus (s->dpy (), priv->frame, RevertToPointerRoot, CurrentTime);
+ XSetInputFocus (s->dpy (), priv->frame,
+ RevertToPointerRoot, CurrentTime);
XChangeProperty (s->dpy (), s->root (), Atoms::winActive,
XA_WINDOW, 32, PropModeReplace,
(unsigned char *) &priv->id, 1);
@@ -1874,7 +1954,7 @@ PrivateWindow::avoidStackingRelativeTo (CompWindow *w)
/* goes through the stack, top-down until we find a window we should
stack above, normal windows can be stacked above fullscreen windows
- if aboveFs is TRUE. */
+ (and fullscreen windows over others in their layer) if aboveFs is TRUE. */
CompWindow *
PrivateWindow::findSiblingBelow (CompWindow *w,
bool aboveFs)
@@ -1912,6 +1992,9 @@ PrivateWindow::findSiblingBelow (CompWindow *w,
/* desktop window layer */
break;
case CompWindowTypeFullscreenMask:
+ if (aboveFs)
+ return below;
+ /* otherwise fall-through */
case CompWindowTypeDockMask:
/* fullscreen and dock layer */
if (below->priv->type & (CompWindowTypeFullscreenMask |
@@ -2154,18 +2237,19 @@ PrivateWindow::reconfigureXWindow (unsigned int valueMask,
if (frame)
{
XWindowChanges wc = *xwc;
+
wc.x -= input.left;
wc.y -= input.top;
wc.width += input.left + input.right;
wc.height += input.top + input.bottom;
- XConfigureWindow (screen->dpy (), frame,
- valueMask, &wc);
+ XConfigureWindow (screen->dpy (), frame, valueMask, &wc);
valueMask &= ~(CWSibling | CWStackMode);
+
xwc->x = input.left;
xwc->y = input.top;
- XConfigureWindow (screen->dpy (), wrapper,
- valueMask, xwc);
+ XConfigureWindow (screen->dpy (), wrapper, valueMask, xwc);
+
xwc->x = 0;
xwc->y = 0;
}
@@ -2216,10 +2300,13 @@ PrivateWindow::stackAncestors (CompWindow *w,
XWindowChanges *xwc)
{
CompWindow *transient = NULL;
+
if (w->priv->transientFor)
transient = screen->findWindow (w->priv->transientFor);
- if (transient && (xwc->sibling != transient->priv->id &&
- (!transient->priv->frame || xwc->sibling != transient->priv->frame)))
+
+ if (transient &&
+ xwc->sibling != transient->priv->id &&
+ (!transient->priv->frame || xwc->sibling != transient->priv->frame))
{
CompWindow *ancestor;
@@ -2250,7 +2337,7 @@ PrivateWindow::stackAncestors (CompWindow *w,
for (a = screen->windows ().back (); a; a = a->prev)
{
if (a->priv->clientLeader == w->priv->clientLeader &&
- a->priv->transientFor == None &&
+ a->priv->transientFor == None &&
!a->priv->isGroupTransient (w->priv->clientLeader))
{
if (xwc->sibling == a->priv->id ||
@@ -2268,8 +2355,7 @@ PrivateWindow::stackAncestors (CompWindow *w,
break;
if (a->priv->mapNum || a->priv->pendingMaps)
- a->priv->reconfigureXWindow (CWSibling | CWStackMode,
- xwc);
+ a->priv->reconfigureXWindow (CWSibling | CWStackMode, xwc);
}
}
}
@@ -2297,19 +2383,19 @@ CompWindow::configureXWindow (unsigned int valueMask,
}
int
-PrivateWindow::addWindowSizeChanges (XWindowChanges *xwc,
+PrivateWindow::addWindowSizeChanges (XWindowChanges *xwc,
CompWindow::Geometry old)
{
XRectangle workArea;
int mask = 0;
int x, y;
- int vx, vy;
int output;
+ CompPoint viewport;
- screen->viewportForGeometry (old, &vx, &vy);
+ screen->viewportForGeometry (old, viewport);
- x = (vx - screen->vp ().x ()) * screen->width ();
- y = (vy - screen->vp ().y ()) * screen->height ();
+ x = (viewport.x () - screen->vp ().x ()) * screen->width ();
+ y = (viewport.y () - screen->vp ().y ()) * screen->height ();
output = screen->outputDeviceForGeometry (old);
screen->getWorkareaForOutput (output, &workArea);
@@ -2318,11 +2404,24 @@ PrivateWindow::addWindowSizeChanges (XWindowChanges *xwc,
{
saveGeometry (CWX | CWY | CWWidth | CWHeight | CWBorderWidth);
- xwc->width = screen->outputDevs ()[output].width ();
- xwc->height = screen->outputDevs ()[output].height ();
+ if (fullscreenMonitorsSet)
+ {
+ xwc->x = x + fullscreenMonitorRect.x ();
+ xwc->y = y + fullscreenMonitorRect.y ();
+ xwc->width = fullscreenMonitorRect.width ();
+ xwc->height = fullscreenMonitorRect.height ();
+ }
+ else
+ {
+ xwc->x = x + screen->outputDevs ()[output].x ();
+ xwc->y = y + screen->outputDevs ()[output].y ();
+ xwc->width = screen->outputDevs ()[output].width ();
+ xwc->height = screen->outputDevs ()[output].height ();
+ }
+
xwc->border_width = 0;
- mask |= CWWidth | CWHeight | CWBorderWidth;
+ mask |= CWX | CWY | CWWidth | CWHeight | CWBorderWidth;
}
else
{
@@ -2383,18 +2482,8 @@ PrivateWindow::addWindowSizeChanges (XWindowChanges *xwc,
xwc->height = sizeHints.max_height;
mask |= CWHeight;
}
- }
-
- if (mask & (CWWidth | CWHeight))
- {
- if (type & CompWindowTypeFullscreenMask)
- {
- xwc->x = x + screen->outputDevs ()[output].x1 ();
- xwc->y = y + screen->outputDevs ()[output].y1 ();
- mask |= CWX | CWY;
- }
- else
+ if (mask & (CWWidth | CWHeight))
{
int width, height, max;
@@ -2624,7 +2713,7 @@ CompWindow::moveResize (XWindowChanges *xwc,
xwcm |= priv->adjustConfigureRequestForGravity (xwc, xwcm, gravity);
- if (!(priv->type & (CompWindowTypeDockMask |
+ if (!(priv->type & (CompWindowTypeDockMask |
CompWindowTypeFullscreenMask |
CompWindowTypeUnknownMask)))
{
@@ -2810,9 +2899,17 @@ CompWindow::raise ()
{
XWindowChanges xwc;
int mask;
+ bool aboveFs = false;
+
+ /* an active fullscreen window should be raised over all other
+ windows in its layer */
+ if (priv->type & CompWindowTypeFullscreenMask)
+ if (priv->id == screen->activeWindow ())
+ aboveFs = true;
mask = priv->addWindowStackChanges (&xwc,
- PrivateWindow::findSiblingBelow (this, false));
+ PrivateWindow::findSiblingBelow (this, aboveFs));
+
if (mask)
configureXWindow (mask, &xwc);
}
@@ -2919,10 +3016,21 @@ CompWindow::updateAttributes (CompStackingUpdateMode stackingMode)
if (stackingMode != CompStackingUpdateModeNone)
{
- Bool aboveFs;
+ bool aboveFs;
CompWindow *sibling;
aboveFs = (stackingMode == CompStackingUpdateModeAboveFullscreen);
+ if (priv->type & CompWindowTypeFullscreenMask)
+ {
+ /* put active or soon-to-be-active fullscreen windows over
+ all others in their layer */
+ if (priv->id == screen->activeWindow () ||
+ stackingMode == CompStackingUpdateModeInitialMap)
+ {
+ aboveFs = true;
+ }
+ }
+
sibling = PrivateWindow::findSiblingBelow (this, aboveFs);
if (sibling &&
@@ -2983,9 +3091,9 @@ PrivateWindow::ensureWindowVisibility ()
if (struts || attrib.override_redirect)
return;
- if (type & (CompWindowTypeDockMask |
- CompWindowTypeFullscreenMask |
- CompWindowTypeUnknownMask))
+ if (type & (CompWindowTypeDockMask |
+ CompWindowTypeFullscreenMask |
+ CompWindowTypeUnknownMask))
return;
x1 = screen->workArea ().x - screen->width () * screen->vp ().x ();
@@ -3277,7 +3385,7 @@ CompWindow::show ()
return;
if (priv->minimized || priv->inShowDesktopMode ||
- priv->hidden || !onDesktop)
+ priv->hidden || !onDesktop)
{
/* no longer hidden but not on current desktop */
if (!priv->minimized && !priv->inShowDesktopMode && !priv->hidden)
@@ -3393,7 +3501,7 @@ CompWindow::maximize (unsigned int state)
}
bool
-PrivateWindow::getUserTime (Time *time)
+PrivateWindow::getUserTime (Time& time)
{
Atom actual;
int result, format;
@@ -3414,7 +3522,7 @@ PrivateWindow::getUserTime (Time *time)
memcpy (&value, data, sizeof (CARD32));
retval = true;
- *time = (Time) value;
+ time = (Time) value;
}
XFree ((void *) data);
@@ -3463,14 +3571,14 @@ PrivateWindow::setUserTime (Time time)
)
bool
-PrivateWindow::getUsageTimestamp (Time *timestamp)
+PrivateWindow::getUsageTimestamp (Time& timestamp)
{
if (getUserTime (timestamp))
return true;
if (initialTimestampSet)
{
- *timestamp = initialTimestamp;
+ timestamp = initialTimestamp;
return true;
}
@@ -3501,7 +3609,7 @@ PrivateWindow::isWindowFocusAllowed (Time timestamp)
}
else
{
- gotTimestamp = getUsageTimestamp (&wUserTime);
+ gotTimestamp = getUsageTimestamp (wUserTime);
}
/* if we got no timestamp for the window, try to get at least a timestamp
@@ -3512,8 +3620,7 @@ PrivateWindow::isWindowFocusAllowed (Time timestamp)
parent = screen->findWindow (transientFor);
if (parent)
- gotTimestamp =
- parent->priv->getUsageTimestamp (&wUserTime);
+ gotTimestamp = parent->priv->getUsageTimestamp (wUserTime);
}
if (gotTimestamp && !wUserTime)
@@ -3563,7 +3670,7 @@ PrivateWindow::isWindowFocusAllowed (Time timestamp)
}
/* can't get user time for active window */
- if (!active->priv->getUserTime (&aUserTime))
+ if (!active->priv->getUserTime (aUserTime))
return true;
if (XSERVER_TIME_IS_BEFORE (wUserTime, aUserTime))
@@ -3586,11 +3693,13 @@ PrivateWindow::allowWindowFocus (unsigned int noFocusMask,
return false;
/* window doesn't take focus */
- if (!priv->inputHint && !(priv->protocols & CompWindowProtocolTakeFocusMask))
+ if (!priv->inputHint &&
+ !(priv->protocols & CompWindowProtocolTakeFocusMask))
+ {
return false;
+ }
retval = priv->isWindowFocusAllowed (timestamp);
-
if (!retval)
{
/* add demands attention state if focus was prevented */
@@ -3603,22 +3712,19 @@ PrivateWindow::allowWindowFocus (unsigned int noFocusMask,
CompPoint
CompWindow::defaultViewport ()
{
- int vx, vy;
+ CompPoint viewport;
- if (priv->serverGeometry.x () < (int) screen->width () &&
+ if (priv->serverGeometry.x () < (int) screen->width () &&
priv->serverGeometry.x () + priv->serverGeometry.width () > 0 &&
- priv->serverGeometry.y () < (int) screen->height () &&
+ priv->serverGeometry.y () < (int) screen->height () &&
priv->serverGeometry.y ()+ priv->serverGeometry.height () > 0)
{
- vx = screen->vp ().x ();
- vy = screen->vp ().y ();
- }
- else
- {
- screen->viewportForGeometry (priv->serverGeometry, &vx, &vy);
+ return screen->vp ();
}
- return CompPoint (vx, vy);
+ screen->viewportForGeometry (priv->serverGeometry, viewport);
+
+ return viewport;
}
CompPoint &
@@ -3627,10 +3733,87 @@ CompWindow::initialViewport () const
return priv->initialViewport;
}
+void
+PrivateWindow::readIconHint ()
+{
+ XImage *image, *maskImage = NULL;
+ Display *dpy = screen->dpy ();
+ unsigned int width, height, dummy;
+ int i, j, k, iDummy;
+ Window wDummy;
+ CompIcon *icon;
+ XColor *colors;
+ CARD32 *p;
+
+ if (!XGetGeometry (dpy, hints->icon_pixmap, &wDummy, &iDummy,
+ &iDummy, &width, &height, &dummy, &dummy))
+ return;
+
+ image = XGetImage (dpy, hints->icon_pixmap, 0, 0, width, height,
+ AllPlanes, ZPixmap);
+ if (!image)
+ return;
+
+ colors = new XColor[width * height];
+ if (!colors)
+ {
+ XDestroyImage (image);
+ return;
+ }
+
+ k = 0;
+ for (j = 0; j < height; j++)
+ for (i = 0; i < width; i++)
+ colors[k++].pixel = XGetPixel (image, i, j);
+
+ for (i = 0; i < k; i += 256)
+ XQueryColors (dpy, screen->priv->colormap,
+ &colors[i], MIN (k - i, 256));
+
+ XDestroyImage (image);
+
+ icon = new CompIcon (screen, width, height);
+ if (!icon)
+ {
+ free (colors);
+ return;
+ }
+
+ if (hints->flags & IconMaskHint)
+ maskImage = XGetImage (dpy, hints->icon_mask, 0, 0,
+ width, height, AllPlanes, ZPixmap);
+
+ k = 0;
+ p = (CARD32 *) icon->data ();
+
+ for (j = 0; j < height; j++)
+ {
+ for (i = 0; i < width; i++)
+ {
+ if (maskImage && !XGetPixel (maskImage, i, j))
+ *p++ = 0;
+ else
+ *p++ = 0xff000000 | /* alpha */
+ (((colors[k].red >> 8) & 0xff) << 16) | /* red */
+ (((colors[k].green >> 8) & 0xff) << 8) | /* green */
+ ((colors[k].blue >> 8) & 0xff); /* blue */
+
+ k++;
+ }
+ }
+
+ free (colors);
+ if (maskImage)
+ XDestroyImage (maskImage);
+
+ icons.push_back (icon);
+}
+
/* returns icon with dimensions as close as possible to width and height
but never greater. */
CompIcon *
-CompWindow::getIcon (int width, int height)
+CompWindow::getIcon (int width,
+ int height)
{
CompIcon *icon;
int wh, diff, oldDiff;
@@ -3644,12 +3827,9 @@ CompWindow::getIcon (int width, int height)
unsigned long n, left;
unsigned char *data;
- result = XGetWindowProperty (screen->dpy (), priv->id,
- Atoms::wmIcon,
- 0L, 65536L,
- FALSE, XA_CARDINAL,
- &actual, &format, &n,
- &left, &data);
+ result = XGetWindowProperty (screen->dpy (), priv->id, Atoms::wmIcon,
+ 0L, 65536L, FALSE, XA_CARDINAL,
+ &actual, &format, &n, &left, &data);
if (result == Success && data)
{
@@ -3702,6 +3882,10 @@ CompWindow::getIcon (int width, int height)
XFree (data);
}
+ else if (priv->hints && (priv->hints->flags & IconPixmapHint))
+ {
+ priv->readIconHint ();
+ }
/* don't fetch property again */
if (priv->icons.size() == 0)
@@ -3742,9 +3926,7 @@ void
PrivateWindow::freeIcons ()
{
for (unsigned int i = 0; i < priv->icons.size (); i++)
- {
delete priv->icons[i];
- }
priv->icons.resize (0);
priv->noIcons = false;
@@ -3759,9 +3941,11 @@ CompWindow::outputDevice ()
bool
CompWindow::onCurrentDesktop ()
{
- if (priv->desktop == 0xffffffff || priv->desktop ==
- screen->currentDesktop ())
+ if (priv->desktop == 0xffffffff ||
+ priv->desktop == screen->currentDesktop ())
+ {
return true;
+ }
return false;
}
@@ -3886,7 +4070,7 @@ CompWindow::getMovementForOffset (CompPoint offset)
}
void
-WindowInterface::getOutputExtents (CompWindowExtents *output)
+WindowInterface::getOutputExtents (CompWindowExtents& output)
WRAPABLE_DEF (getOutputExtents, output)
void
@@ -3913,11 +4097,16 @@ WindowInterface::validateResizeRequest (unsigned int &mask,
WRAPABLE_DEF (validateResizeRequest, mask, xwc, source)
void
-WindowInterface::resizeNotify (int dx, int dy, int dwidth, int dheight)
+WindowInterface::resizeNotify (int dx,
+ int dy,
+ int dwidth,
+ int dheight)
WRAPABLE_DEF (resizeNotify, dx, dy, dwidth, dheight)
void
-WindowInterface::moveNotify (int dx, int dy, bool immediate)
+WindowInterface::moveNotify (int dx,
+ int dy,
+ bool immediate)
WRAPABLE_DEF (moveNotify, dx, dy, immediate)
void
@@ -3926,8 +4115,8 @@ WindowInterface::windowNotify (CompWindowNotify n)
void
-WindowInterface::grabNotify (int x,
- int y,
+WindowInterface::grabNotify (int x,
+ int y,
unsigned int state,
unsigned int mask)
WRAPABLE_DEF (grabNotify, x, y, state, mask)
@@ -3996,8 +4185,7 @@ CompWindow::close (Time serverTime)
ev.xclient.data.l[3] = 0;
ev.xclient.data.l[4] = 0;
- XSendEvent (screen->dpy (), priv->id, false,
- NoEventMask, &ev);
+ XSendEvent (screen->dpy (), priv->id, false, NoEventMask, &ev);
}
else
{
@@ -4039,10 +4227,9 @@ PrivateWindow::handlePingTimeout (unsigned int lastPing)
if (priv->closeRequests)
{
- screen->toolkitAction (
- Atoms::toolkitActionForceQuitDialog,
- priv->lastCloseRequestTime,
- priv->id, true, 0, 0);
+ screen->toolkitAction (Atoms::toolkitActionForceQuitDialog,
+ priv->lastCloseRequestTime,
+ priv->id, true, 0, 0);
priv->closeRequests = 0;
}
@@ -4065,10 +4252,9 @@ PrivateWindow::handlePing (int lastPing)
if (priv->lastCloseRequestTime)
{
- screen->toolkitAction (
- Atoms::toolkitActionForceQuitDialog,
- priv->lastCloseRequestTime,
- priv->id, false, 0, 0);
+ screen->toolkitAction (Atoms::toolkitActionForceQuitDialog,
+ priv->lastCloseRequestTime,
+ priv->id, false, 0, 0);
priv->lastCloseRequestTime = 0;
}
@@ -4082,8 +4268,7 @@ PrivateWindow::processMap ()
bool allowFocus;
CompStackingUpdateMode stackingMode;
- priv->initialViewport.setX (screen->vp ().x ());
- priv->initialViewport.setY (screen->vp ().y ());
+ priv->initialViewport = screen->vp ();
priv->initialTimestampSet = false;
@@ -4106,6 +4291,8 @@ PrivateWindow::processMap ()
xwcm = adjustConfigureRequestForGravity (&xwc, CWX | CWY, gravity);
+ window->validateResizeRequest (xwcm, &xwc, ClientTypeApplication);
+
CompPoint pos (xwc.x, xwc.y);
if (window->place (pos))
{
@@ -4114,8 +4301,6 @@ PrivateWindow::processMap ()
xwcm |= CWX | CWY;
}
- window->validateResizeRequest (xwcm, &xwc, ClientTypeApplication);
-
if (xwcm)
window->configureXWindow (xwcm, &xwc);
@@ -4226,12 +4411,13 @@ CompWindow::saveWc ()
}
void
-CompWindow::moveToViewportPosition (int x, int y, bool sync)
+CompWindow::moveToViewportPosition (int x,
+ int y,
+ bool sync)
{
- int tx, vWidth = screen->width () *
- screen->vpSize ().width ();
- int ty, vHeight = screen->height () *
- screen->vpSize ().height ();
+ int tx, ty;
+ int vWidth = screen->width () * screen->vpSize ().width ();
+ int vHeight = screen->height () * screen->vpSize ().height ();
if (screen->vpSize ().width () != 1)
{
@@ -4270,8 +4456,7 @@ CompWindow::moveToViewportPosition (int x, int y, bool sync)
{
m = priv->attrib.x + tx;
- if (m - priv->output.left <
- (int) screen->width () - vWidth)
+ if (m - priv->output.left < (int) screen->width () - vWidth)
wx = tx + vWidth;
else if (m + priv->width + priv->output.right > vWidth)
wx = tx - vWidth;
@@ -4281,8 +4466,7 @@ CompWindow::moveToViewportPosition (int x, int y, bool sync)
{
m = priv->attrib.y + ty;
- if (m - priv->output.top <
- (int) screen->height () - vHeight)
+ if (m - priv->output.top < (int) screen->height () - vHeight)
wy = ty + vHeight;
else if (m + priv->height + priv->output.bottom > vHeight)
wy = ty - vHeight;
@@ -4316,7 +4500,8 @@ PrivateWindow::applyStartupProperties (CompStartupSequence *s)
priv->initialViewport.setY (s->viewportY);
workspace = sn_startup_sequence_get_workspace (s->sequence);
- setDesktop (workspace);
+ if (workspace >= 0)
+ setDesktop (workspace);
priv->initialTimestamp =
sn_startup_sequence_get_timestamp (s->sequence);
@@ -4386,9 +4571,7 @@ CompWindow::sizeHints () const
void
PrivateWindow::updateMwmHints ()
{
- screen->priv->getMwmHints (priv->id, &priv->mwmFunc,
- &priv->mwmDecor);
-
+ screen->priv->getMwmHints (priv->id, &priv->mwmFunc, &priv->mwmDecor);
window->recalcActions ();
}
@@ -4449,9 +4632,9 @@ CompWindow::syncAlarm ()
}
-CompWindow::CompWindow (Window id,
- Window aboveId) :
- CompPrivateStorage (&windowPrivateIndices)
+CompWindow::CompWindow (Window id,
+ Window aboveId) :
+ CompPrivateStorage (windowPrivateIndices)
{
priv = new PrivateWindow (this);
assert (priv);
@@ -4697,6 +4880,7 @@ PrivateWindow::PrivateWindow (CompWindow *window) :
activeNum (0),
transientFor (None),
clientLeader (None),
+ hints (NULL),
inputHint (true),
alpha (false),
width (0),
@@ -4720,6 +4904,8 @@ PrivateWindow::PrivateWindow (CompWindow *window) :
initialTimestamp (0),
initialTimestampSet (false),
+ fullscreenMonitorsSet (false),
+
placed (false),
minimized (false),
inShowDesktopMode (false),
@@ -4772,6 +4958,10 @@ PrivateWindow::PrivateWindow (CompWindow *window) :
output.right = 0;
output.top = 0;
output.bottom = 0;
+
+ syncWaitTimer.setTimes (1000, 1200);
+ syncWaitTimer.setCallback (boost::bind (&PrivateWindow::handleSyncAlarm,
+ this));
}
PrivateWindow::~PrivateWindow ()
@@ -4787,6 +4977,9 @@ PrivateWindow::~PrivateWindow ()
if (struts)
free (struts);
+ if (hints)
+ XFree (hints);
+
if (icons.size ())
freeIcons ();
@@ -4898,7 +5091,7 @@ CompWindow::updateFrameRegion ()
int x, y;
if ((priv->input.left || priv->input.right ||
- priv->input.top || priv->input.bottom) && priv->frame)
+ priv->input.top || priv->input.bottom) && priv->frame)
{
priv->frameRegion = CompRegion ();
@@ -4953,7 +5146,7 @@ CompWindow::setWindowFrameExtents (CompWindowExtents *i)
}
void
-CompWindow::updateFrameRegion (CompRegion & region)
+CompWindow::updateFrameRegion (CompRegion& region)
WRAPABLE_HND_FUNC(12, updateFrameRegion, region)
bool
@@ -4964,7 +5157,6 @@ PrivateWindow::reparent ()
int mask;
XEvent e;
CompWindow::Geometry sg = serverGeometry;
-
Display *dpy = screen->dpy ();
if (frame)
@@ -5028,7 +5220,9 @@ PrivateWindow::reparent ()
XSync (dpy, FALSE);
if (XCheckTypedWindowEvent (dpy, id, FocusIn, &e) ||
screen->activeWindow () == id)
+ {
window->moveInputFocusTo ();
+ }
pendingUnmaps++;
pendingMaps++;
}
@@ -5041,11 +5235,10 @@ PrivateWindow::reparent ()
void
PrivateWindow::unreparent ()
{
- Display *dpy = screen->dpy ();
+ Display *dpy = screen->dpy ();
XEvent e;
XWindowChanges xwc;
-
- bool alive = true;
+ bool alive = true;
if (!frame)
return;
@@ -5085,5 +5278,4 @@ PrivateWindow::unreparent ()
wrapper = None;
frame = None;
- window->windowNotify (CompWindowNotifyUnreparent);
-}
+ window->windowNotify (CompWindowNotifyUnreparent);}
diff --git a/src/windowgeometry.cpp b/src/windowgeometry.cpp
index 5a236f7..ab3546b 100644
--- a/src/windowgeometry.cpp
+++ b/src/windowgeometry.cpp
@@ -33,7 +33,8 @@ CompWindow::Geometry::Geometry () :
{
}
-CompWindow::Geometry::Geometry (int x, int y,
+CompWindow::Geometry::Geometry (int x,
+ int y,
unsigned int width,
unsigned int height,
unsigned int border) :
@@ -56,7 +57,8 @@ CompWindow::Geometry::setBorder (unsigned int border)
}
void
-CompWindow::Geometry::set (int x, int y,
+CompWindow::Geometry::set (int x,
+ int y,
unsigned int width,
unsigned int height,
unsigned int border)
@@ -80,7 +82,6 @@ CompWindow::geometry () const
return priv->geometry;
}
-
int
CompWindow::x () const
{
@@ -118,7 +119,6 @@ CompWindow::size () const
return CompSize (priv->width, priv->height);
}
-
int
CompWindow::serverX () const
{
@@ -141,19 +141,22 @@ CompWindow::serverPos () const
unsigned int
CompWindow::serverWidth () const
{
- return priv->serverGeometry.width () + (2 * priv->serverGeometry.border ());
+ return priv->serverGeometry.width () +
+ 2 * priv->serverGeometry.border ();
}
unsigned int
CompWindow::serverHeight () const
{
- return priv->serverGeometry.height () + (2 * priv->serverGeometry.border ());
+ return priv->serverGeometry.height () +
+ 2 * priv->serverGeometry.border ();
}
const CompSize
CompWindow::serverSize () const
{
- return CompSize (
- priv->serverGeometry.width () + (2 * priv->serverGeometry.border ()),
- priv->serverGeometry.height () + (2 * priv->serverGeometry.border ()));
+ return CompSize (priv->serverGeometry.width () +
+ 2 * priv->serverGeometry.border (),
+ priv->serverGeometry.height () +
+ 2 * priv->serverGeometry.border ());
}