~vanvugt/compiz-plugins-main/fix-915236

« back to all changes in this revision

Viewing changes to vpswitch/src/vpswitch.h

  • Committer: Sam Spilsbury
  • Date: 2011-08-04 16:31:54 UTC
  • Revision ID: sam.spilsbury@canonical.com-20110804163154-ys9vvppcvh3k8ay7
Sync in changes from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Compiz vpswitch plugin
 
3
 *
 
4
 * vpswitch.cpp
 
5
 *
 
6
 * Copyright (c) 2007 Dennis Kasprzyk <onestone@opencompositing.org>
 
7
 *
 
8
 * Go-to-numbered-viewport functionality by
 
9
 * 
 
10
 * Copyright (c) 2007 Robert Carr <racarr@opencompositing.org>
 
11
 *           (c) 2007 Danny Baumann <maniac@opencompositing.org>
 
12
 *
 
13
 * Go-to-specific-viewport functionality by
 
14
 *
 
15
 * Copyright (c) 2007 Michael Vogt <mvo@ubuntu.com>
 
16
 *
 
17
 * This program is free software; you can redistribute it and/or
 
18
 * modify it under the terms of the GNU General Public License
 
19
 * as published by the Free Software Foundation; either version 2
 
20
 * of the License, or (at your option) any later version.
 
21
 *
 
22
 * This program is distributed in the hope that it will be useful,
 
23
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
24
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
25
 * GNU General Public License for more details.
 
26
 *
 
27
 */
 
28
 
 
29
#include <core/core.h>
 
30
#include <core/pluginclasshandler.h>
 
31
#include <core/atoms.h>
 
32
 
 
33
#include "vpswitch_options.h"
 
34
 
 
35
/* Helper macro to obtain necesary action data */
 
36
 
 
37
/* ??? xid = screen->grabWindow () else xid = screen->below () */
 
38
 
 
39
#define GET_DATA \
 
40
    CompWindow *w;\
 
41
    Window     xid; \
 
42
    if (screen->otherGrabExist ("rotate", "wall", "plane", 0)) \
 
43
        return false; \
 
44
    xid = CompOption::getIntOptionNamed (options, "window"); \
 
45
    w = screen->findWindow (xid); \
 
46
    if ((!w || (w->type () & CompWindowTypeDesktopMask) == 0) && \
 
47
        xid != screen->root ()) \
 
48
        return false;
 
49
 
 
50
/* number-to-keysym mapping */
 
51
static const KeySym numberKeySyms[3][10] = {
 
52
    /* number key row */
 
53
    { XK_0, XK_1, XK_2, XK_3, XK_4, XK_5, XK_6, XK_7, XK_8, XK_9 },
 
54
    /* number keypad with activated NumLock */
 
55
    { XK_KP_0, XK_KP_1, XK_KP_2, XK_KP_3, XK_KP_4,
 
56
      XK_KP_5, XK_KP_6, XK_KP_7, XK_KP_8, XK_KP_9 },
 
57
    /* number keypad without NumLock */
 
58
    { XK_KP_Insert, XK_KP_End, XK_KP_Down, XK_KP_Next, XK_KP_Left,
 
59
      XK_KP_Begin, XK_KP_Right, XK_KP_Home, XK_KP_Up, XK_KP_Prior }
 
60
};
 
61
 
 
62
class VPSwitchScreen :
 
63
    public PluginClassHandler <VPSwitchScreen, CompScreen>,
 
64
    public VpswitchOptions,
 
65
    public ScreenInterface
 
66
{
 
67
    public:
 
68
 
 
69
        VPSwitchScreen (CompScreen *);
 
70
 
 
71
        int destination;
 
72
        bool numberedActive;
 
73
 
 
74
        /* Wrappable functions */
 
75
        void
 
76
        handleEvent (XEvent *);
 
77
 
 
78
        /* Actions */
 
79
        bool
 
80
        movevp (CompAction         *action,
 
81
                CompAction::State  state,
 
82
                CompOption::Vector &options,
 
83
                unsigned int dx, unsigned int dy);
 
84
 
 
85
        bool
 
86
        switchto (CompAction         *action,
 
87
                  CompAction::State  state,
 
88
                  CompOption::Vector &options,
 
89
                  int num);
 
90
 
 
91
        bool
 
92
        initiateNumbered (CompAction         *action,
 
93
                          CompAction::State  state,
 
94
                          CompOption::Vector &options);
 
95
 
 
96
        bool
 
97
        terminateNumbered (CompAction         *action,
 
98
                           CompAction::State  state,
 
99
                           CompOption::Vector &options);
 
100
 
 
101
        bool
 
102
        prev (CompAction         *action,
 
103
              CompAction::State  state,
 
104
              CompOption::Vector &options);
 
105
 
 
106
        bool
 
107
        next (CompAction         *action,
 
108
              CompAction::State  state,
 
109
              CompOption::Vector &options);
 
110
 
 
111
        bool
 
112
        initPluginAction (CompAction         *action,
 
113
                          CompAction::State  state,
 
114
                          CompOption::Vector &options);
 
115
 
 
116
        bool
 
117
        termPluginAction (CompAction         *action,
 
118
                          CompAction::State  state,
 
119
                          CompOption::Vector &options);
 
120
 
 
121
        /* General Functions */
 
122
 
 
123
        void
 
124
        gotovp (int x, int y);
 
125
};
 
126
        
 
127
#define VPSWITCH_SCREEN(s)                                                     \
 
128
    VPSwitchScreen *vs = VPSwitchScreen::get (s);
 
129
 
 
130
class VPSwitchPluginVTable :
 
131
    public CompPlugin::VTableForScreen <VPSwitchScreen>
 
132
{
 
133
    public:
 
134
 
 
135
        bool init ();
 
136
};