/*
 * This file is autogenerated with bcop:
 * The Compiz option code generator
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */


#include <core/core.h>

#include "workarounds_options.h"

WorkaroundsOptions::WorkaroundsOptions (bool init /* = true */) :
    mOptions (WorkaroundsOptions::OptionNum),
    mNotify (WorkaroundsOptions::OptionNum)
{
    if (init)
        initOptions ();
}

void
WorkaroundsOptions::initOptions ()
{

    // keep_minimized_windows
    mOptions[WorkaroundsOptions::KeepMinimizedWindows].setName ("keep_minimized_windows", CompOption::TypeBool);
    mOptions[WorkaroundsOptions::KeepMinimizedWindows].value().set(false);

    // legacy_fullscreen
    mOptions[WorkaroundsOptions::LegacyFullscreen].setName ("legacy_fullscreen", CompOption::TypeBool);
    mOptions[WorkaroundsOptions::LegacyFullscreen].value().set(false);

    // firefox_menu_fix
    mOptions[WorkaroundsOptions::FirefoxMenuFix].setName ("firefox_menu_fix", CompOption::TypeBool);
    mOptions[WorkaroundsOptions::FirefoxMenuFix].value().set(false);

    // ooo_menu_fix
    mOptions[WorkaroundsOptions::OooMenuFix].setName ("ooo_menu_fix", CompOption::TypeBool);
    mOptions[WorkaroundsOptions::OooMenuFix].value().set(true);

    // notification_daemon_fix
    mOptions[WorkaroundsOptions::NotificationDaemonFix].setName ("notification_daemon_fix", CompOption::TypeBool);
    mOptions[WorkaroundsOptions::NotificationDaemonFix].value().set(false);

    // java_fix
    mOptions[WorkaroundsOptions::JavaFix].setName ("java_fix", CompOption::TypeBool);
    mOptions[WorkaroundsOptions::JavaFix].value().set(true);

    // java_taskbar_fix
    mOptions[WorkaroundsOptions::JavaTaskbarFix].setName ("java_taskbar_fix", CompOption::TypeBool);
    mOptions[WorkaroundsOptions::JavaTaskbarFix].value().set(true);

    // qt_fix
    mOptions[WorkaroundsOptions::QtFix].setName ("qt_fix", CompOption::TypeBool);
    mOptions[WorkaroundsOptions::QtFix].value().set(false);

    // convert_urgency
    mOptions[WorkaroundsOptions::ConvertUrgency].setName ("convert_urgency", CompOption::TypeBool);
    mOptions[WorkaroundsOptions::ConvertUrgency].value().set(false);

    // aiglx_fragment_fix
    mOptions[WorkaroundsOptions::AiglxFragmentFix].setName ("aiglx_fragment_fix", CompOption::TypeBool);
    mOptions[WorkaroundsOptions::AiglxFragmentFix].value().set(true);

    // fglrx_xgl_fix
    mOptions[WorkaroundsOptions::FglrxXglFix].setName ("fglrx_xgl_fix", CompOption::TypeBool);
    mOptions[WorkaroundsOptions::FglrxXglFix].value().set(false);

    // force_glx_sync
    mOptions[WorkaroundsOptions::ForceGlxSync].setName ("force_glx_sync", CompOption::TypeBool);
    mOptions[WorkaroundsOptions::ForceGlxSync].value().set(false);

    // no_wait_for_video_sync
    mOptions[WorkaroundsOptions::NoWaitForVideoSync].setName ("no_wait_for_video_sync", CompOption::TypeBool);
    mOptions[WorkaroundsOptions::NoWaitForVideoSync].value().set(false);

    // initial_damage_complete_redraw
    mOptions[WorkaroundsOptions::InitialDamageCompleteRedraw].setName ("initial_damage_complete_redraw", CompOption::TypeBool);
    mOptions[WorkaroundsOptions::InitialDamageCompleteRedraw].value().set(true);

    // force_swap_buffers
    mOptions[WorkaroundsOptions::ForceSwapBuffers].setName ("force_swap_buffers", CompOption::TypeBool);
    mOptions[WorkaroundsOptions::ForceSwapBuffers].value().set(false);

    // sticky_alldesktops
    mOptions[WorkaroundsOptions::StickyAlldesktops].setName ("sticky_alldesktops", CompOption::TypeBool);
    mOptions[WorkaroundsOptions::StickyAlldesktops].value().set(false);

    // alldesktop_sticky_match
    mOptions[WorkaroundsOptions::AlldesktopStickyMatch].setName ("alldesktop_sticky_match", CompOption::TypeMatch);
    mOptions[WorkaroundsOptions::AlldesktopStickyMatch].value().set(CompMatch ("any"));
    mOptions[WorkaroundsOptions::AlldesktopStickyMatch].value().match ().update ();

}

WorkaroundsOptions::~WorkaroundsOptions ()
{
}


CompOption::Vector &
WorkaroundsOptions::getOptions ()
{
    return mOptions;
}

bool
WorkaroundsOptions::setOption (const CompString &name, CompOption::Value &value)
{
    CompOption   *o;
    unsigned int index;

    o = CompOption::findOption (mOptions, name, &index);

    if (!o)
        return false;

    switch (index)
    {
        case WorkaroundsOptions::KeepMinimizedWindows:
            if (o->set (value))
            {
                if (!mNotify[WorkaroundsOptions::KeepMinimizedWindows].empty ())
                    mNotify[WorkaroundsOptions::KeepMinimizedWindows] (o, WorkaroundsOptions::KeepMinimizedWindows);
                return true;
            }
            break;
        case WorkaroundsOptions::LegacyFullscreen:
            if (o->set (value))
            {
                if (!mNotify[WorkaroundsOptions::LegacyFullscreen].empty ())
                    mNotify[WorkaroundsOptions::LegacyFullscreen] (o, WorkaroundsOptions::LegacyFullscreen);
                return true;
            }
            break;
        case WorkaroundsOptions::FirefoxMenuFix:
            if (o->set (value))
            {
                if (!mNotify[WorkaroundsOptions::FirefoxMenuFix].empty ())
                    mNotify[WorkaroundsOptions::FirefoxMenuFix] (o, WorkaroundsOptions::FirefoxMenuFix);
                return true;
            }
            break;
        case WorkaroundsOptions::OooMenuFix:
            if (o->set (value))
            {
                if (!mNotify[WorkaroundsOptions::OooMenuFix].empty ())
                    mNotify[WorkaroundsOptions::OooMenuFix] (o, WorkaroundsOptions::OooMenuFix);
                return true;
            }
            break;
        case WorkaroundsOptions::NotificationDaemonFix:
            if (o->set (value))
            {
                if (!mNotify[WorkaroundsOptions::NotificationDaemonFix].empty ())
                    mNotify[WorkaroundsOptions::NotificationDaemonFix] (o, WorkaroundsOptions::NotificationDaemonFix);
                return true;
            }
            break;
        case WorkaroundsOptions::JavaFix:
            if (o->set (value))
            {
                if (!mNotify[WorkaroundsOptions::JavaFix].empty ())
                    mNotify[WorkaroundsOptions::JavaFix] (o, WorkaroundsOptions::JavaFix);
                return true;
            }
            break;
        case WorkaroundsOptions::JavaTaskbarFix:
            if (o->set (value))
            {
                if (!mNotify[WorkaroundsOptions::JavaTaskbarFix].empty ())
                    mNotify[WorkaroundsOptions::JavaTaskbarFix] (o, WorkaroundsOptions::JavaTaskbarFix);
                return true;
            }
            break;
        case WorkaroundsOptions::QtFix:
            if (o->set (value))
            {
                if (!mNotify[WorkaroundsOptions::QtFix].empty ())
                    mNotify[WorkaroundsOptions::QtFix] (o, WorkaroundsOptions::QtFix);
                return true;
            }
            break;
        case WorkaroundsOptions::ConvertUrgency:
            if (o->set (value))
            {
                if (!mNotify[WorkaroundsOptions::ConvertUrgency].empty ())
                    mNotify[WorkaroundsOptions::ConvertUrgency] (o, WorkaroundsOptions::ConvertUrgency);
                return true;
            }
            break;
        case WorkaroundsOptions::AiglxFragmentFix:
            if (o->set (value))
            {
                if (!mNotify[WorkaroundsOptions::AiglxFragmentFix].empty ())
                    mNotify[WorkaroundsOptions::AiglxFragmentFix] (o, WorkaroundsOptions::AiglxFragmentFix);
                return true;
            }
            break;
        case WorkaroundsOptions::FglrxXglFix:
            if (o->set (value))
            {
                if (!mNotify[WorkaroundsOptions::FglrxXglFix].empty ())
                    mNotify[WorkaroundsOptions::FglrxXglFix] (o, WorkaroundsOptions::FglrxXglFix);
                return true;
            }
            break;
        case WorkaroundsOptions::ForceGlxSync:
            if (o->set (value))
            {
                if (!mNotify[WorkaroundsOptions::ForceGlxSync].empty ())
                    mNotify[WorkaroundsOptions::ForceGlxSync] (o, WorkaroundsOptions::ForceGlxSync);
                return true;
            }
            break;
        case WorkaroundsOptions::NoWaitForVideoSync:
            if (o->set (value))
            {
                if (!mNotify[WorkaroundsOptions::NoWaitForVideoSync].empty ())
                    mNotify[WorkaroundsOptions::NoWaitForVideoSync] (o, WorkaroundsOptions::NoWaitForVideoSync);
                return true;
            }
            break;
        case WorkaroundsOptions::InitialDamageCompleteRedraw:
            if (o->set (value))
            {
                if (!mNotify[WorkaroundsOptions::InitialDamageCompleteRedraw].empty ())
                    mNotify[WorkaroundsOptions::InitialDamageCompleteRedraw] (o, WorkaroundsOptions::InitialDamageCompleteRedraw);
                return true;
            }
            break;
        case WorkaroundsOptions::ForceSwapBuffers:
            if (o->set (value))
            {
                if (!mNotify[WorkaroundsOptions::ForceSwapBuffers].empty ())
                    mNotify[WorkaroundsOptions::ForceSwapBuffers] (o, WorkaroundsOptions::ForceSwapBuffers);
                return true;
            }
            break;
        case WorkaroundsOptions::StickyAlldesktops:
            if (o->set (value))
            {
                if (!mNotify[WorkaroundsOptions::StickyAlldesktops].empty ())
                    mNotify[WorkaroundsOptions::StickyAlldesktops] (o, WorkaroundsOptions::StickyAlldesktops);
                return true;
            }
            break;
        case WorkaroundsOptions::AlldesktopStickyMatch:
            if (o->set (value))
            {
                if (!mNotify[WorkaroundsOptions::AlldesktopStickyMatch].empty ())
                    mNotify[WorkaroundsOptions::AlldesktopStickyMatch] (o, WorkaroundsOptions::AlldesktopStickyMatch);
                return true;
            }
            break;
        default:
            break;
    }
    return false;

}

