~smspillaz/compiz-core/compiz-core.fix_953839

« back to all changes in this revision

Viewing changes to src/screen.cpp

  • Committer: Daniel van Vugt
  • Author(s): Alan Griffiths
  • Date: 2012-03-12 07:58:01 UTC
  • mfrom: (3048.2.2 arg-tmp1)
  • Revision ID: daniel.van.vugt@canonical.com-20120312075801-abx9liy1n9p6q8il
Decouple GrabManager from rest of what was PrivateScreen

Show diffs side-by-side

added added

removed removed

Lines of Context:
2975
2975
    XChangeActivePointerGrab (priv->dpy, POINTER_GRAB_MASK,
2976
2976
                              cursor, CurrentTime);
2977
2977
 
2978
 
    ((cps::Grab *) handle)->cursor = cursor;
 
2978
    handle->cursor = cursor;
2979
2979
}
2980
2980
 
2981
2981
void
3077
3077
}
3078
3078
 
3079
3079
void
3080
 
PrivateScreen::grabUngrabOneKey (unsigned int modifiers,
 
3080
cps::GrabManager::grabUngrabOneKey (unsigned int modifiers,
3081
3081
                                 int          keycode,
3082
3082
                                 bool         grab)
3083
3083
{
3087
3087
         * Always grab the keyboard Sync-ronously. This is so that we can
3088
3088
         * choose to ReplayKeyboard in alwaysHandleEvent if need be.
3089
3089
         */
3090
 
        XGrabKey (dpy,
 
3090
        XGrabKey (screen->dpy(),
3091
3091
                  keycode,
3092
3092
                  modifiers,
3093
 
                  root,
 
3093
                  screen->root(),
3094
3094
                  true,
3095
3095
                  GrabModeAsync,
3096
3096
                  GrabModeSync);
3097
3097
    }
3098
3098
    else
3099
3099
    {
3100
 
        XUngrabKey (dpy,
 
3100
        XUngrabKey (screen->dpy(),
3101
3101
                    keycode,
3102
3102
                    modifiers,
3103
 
                    root);
 
3103
                    screen->root());
3104
3104
    }
3105
3105
}
3106
3106
 
3107
3107
bool
3108
 
PrivateScreen::grabUngrabKeys (unsigned int modifiers,
 
3108
cps::GrabManager::grabUngrabKeys (unsigned int modifiers,
3109
3109
                               int          keycode,
3110
3110
                               bool         grab)
3111
3111
{
3112
3112
    int             mod, k;
3113
3113
    unsigned int    ignore;
3114
3114
 
3115
 
    CompScreen::checkForError (dpy);
 
3115
    CompScreen::checkForError (screen->dpy());
3116
3116
 
3117
3117
    for (ignore = 0; ignore <= modHandler->ignoredModMask (); ignore++)
3118
3118
    {
3154
3154
             * keys, and know to cancel the tap if <modifier>+k is pressed.
3155
3155
             */
3156
3156
            int minCode, maxCode;
3157
 
            XDisplayKeycodes (dpy, &minCode, &maxCode);
 
3157
            XDisplayKeycodes (screen->dpy(), &minCode, &maxCode);
3158
3158
            for (k = minCode; k <= maxCode; k++)
3159
3159
                grabUngrabOneKey (modifiers | ignore, k, grab);
3160
3160
        }
3161
3161
 
3162
 
        if (CompScreen::checkForError (dpy))
 
3162
        if (CompScreen::checkForError (screen->dpy()))
3163
3163
            return false;
3164
3164
    }
3165
3165
 
3228
3228
}
3229
3229
 
3230
3230
void
3231
 
PrivateScreen::updatePassiveKeyGrabs ()
 
3231
cps::GrabManager::updatePassiveKeyGrabs ()
3232
3232
{
3233
3233
    std::list<cps::KeyGrab>::iterator it;
3234
3234
 
3235
 
    XUngrabKey (dpy, AnyKey, AnyModifier, root);
 
3235
    XUngrabKey (screen->dpy(), AnyKey, AnyModifier, screen->root());
3236
3236
 
3237
3237
    for (it = keyGrabs.begin (); it != keyGrabs.end (); it++)
3238
3238
    {
3272
3272
    return true;
3273
3273
}
3274
3274
 
 
3275
void cps::GrabManager::updatePassiveButtonGrabs(Window serverFrame)
 
3276
{
 
3277
    /* Grab only we have bindings on */
 
3278
    foreach (ButtonGrab &bind, buttonGrabs)
 
3279
    {
 
3280
        unsigned int mods = modHandler->virtualToRealModMask (bind.modifiers);
 
3281
 
 
3282
        if (mods & CompNoMask)
 
3283
            continue;
 
3284
 
 
3285
        for (unsigned int ignore = 0;
 
3286
                 ignore <= modHandler->ignoredModMask (); ignore++)
 
3287
        {
 
3288
            if (ignore & ~modHandler->ignoredModMask ())
 
3289
                continue;
 
3290
 
 
3291
            XGrabButton (screen->dpy(),
 
3292
                         bind.button,
 
3293
                         mods | ignore,
 
3294
                         serverFrame,
 
3295
                         false,
 
3296
                         ButtonPressMask | ButtonReleaseMask |
 
3297
                            ButtonMotionMask,
 
3298
                         GrabModeSync,
 
3299
                         GrabModeAsync,
 
3300
                         None,
 
3301
                         None);
 
3302
        }
 
3303
    }
 
3304
}
 
3305
 
3275
3306
void
3276
3307
cps::GrabManager::removePassiveButtonGrab (CompAction::ButtonBinding &button)
3277
3308
{