Move plugin: Code needs cleanup

Bug #1167204 reported by MC Return
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Compiz
Fix Released
Medium
MC Return

Bug Description

Examples:
There are a ton of

if (a)
    if (b)
        if (c)
        {
            do ()
        }

combinations, or things like:

 if (s->otherGrabExist ("move", NULL))
     return false;

 if (ms->w)
     return false;

 if (w->type () & (CompWindowTypeDesktopMask |
         CompWindowTypeDockMask |
         CompWindowTypeFullscreenMask))
     return false;

 if (w->overrideRedirect ())
     return false;

which can be better written as:

 if (s->otherGrabExist ("move", NULL) ||
     ms->w ||
     w->overrideRedirect () ||
     w->type () & (CompWindowTypeDesktopMask |
     CompWindowTypeDockMask |
     CompWindowTypeFullscreenMask))
     return false;

also this block above comes after these lines:

 unsigned int mods = CompOption::getIntOptionNamed (options, "modifiers", 0);

 int x = CompOption::getIntOptionNamed (options, "x", w->geometry ().x () +
            (w->size ().width () / 2));
 int y = CompOption::getIntOptionNamed (options, "y", w->geometry ().y () +
            (w->size ().height () / 2));

 int button = CompOption::getIntOptionNamed (options, "button", -1);

but all those calculations of local variables do not need to happen if we return false, so
those should be calculated after the return false check...

MC Return (mc-return)
Changed in compiz:
assignee: nobody → MC Return (mc-return)
status: New → In Progress
MC Return (mc-return)
Changed in compiz:
status: In Progress → Fix Committed
MC Return (mc-return)
Changed in compiz:
importance: Undecided → Medium
milestone: none → 0.9.10.0
Revision history for this message
Stephen M. Webb (bregma) wrote :

Fix Released in Compiz Compiz 0.9.10.0.

Changed in compiz:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.