~canonical-dx-team/unity/unity.fix-ql-losing-focus

« back to all changes in this revision

Viewing changes to targets/mutter/maximus.vala

  • Committer: Neil Jagdish Patel
  • Date: 2010-11-11 18:51:08 UTC
  • mfrom: (572.1.58 unity-3.0)
  • Revision ID: neil.patel@canonical.com-20101111185108-71923a90txzvxbit
[merge] Unity 3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2009 Canonical Ltd
3
 
 *
4
 
 * This program is free software: you can redistribute it and/or modify
5
 
 * it under the terms of the GNU General Public License version 3 as
6
 
 * published by the Free Software Foundation.
7
 
 *
8
 
 * This program is distributed in the hope that it will be useful,
9
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
 * GNU General Public License for more details.
12
 
 *
13
 
 * You should have received a copy of the GNU General Public License
14
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 
 *
16
 
 * Authored by Jason Smith <jason.smith@canonical.com>
17
 
 *
18
 
 */
19
 
 
20
 
namespace Unity
21
 
{
22
 
  public class Maximus : Object
23
 
  {
24
 
    public static string user_unmaximize_hint = "maximus-user-unmaximize";
25
 
 
26
 
    static string[] default_exclude_classes =
27
 
    {
28
 
      "Apport-gtk",
29
 
      "Bluetooth-properties",
30
 
      "Bluetooth-wizard",
31
 
      "Download", /* Firefox Download Window */
32
 
      "Ekiga",
33
 
      "Extension", /* Firefox Add-Ons/Extension Window */
34
 
      "Gimp",
35
 
      "Global", /* Firefox Error Console Window */
36
 
      "Gnome-nettool",
37
 
      "Kiten",
38
 
      "Kmplot",
39
 
      "Nm-editor",
40
 
      "Pidgin",
41
 
      "Polkit-gnome-authorization",
42
 
      "Update-manager",
43
 
      "Skype",
44
 
      "Toplevel", /* Firefox "Clear Private Data" Window */
45
 
      "Transmission"
46
 
    };
47
 
 
48
 
    public Maximus ()
49
 
    {
50
 
    }
51
 
 
52
 
    construct
53
 
    {
54
 
    }
55
 
 
56
 
    bool window_is_excluded (Mutter.Window window)
57
 
    {
58
 
      Mutter.MetaCompWindowType type = window.get_window_type ();
59
 
 
60
 
      if (type != Mutter.MetaCompWindowType.NORMAL)
61
 
        return true;
62
 
 
63
 
      unowned Mutter.MetaWindow meta = window.get_meta_window ();
64
 
 
65
 
      if (Mutter.MetaWindow.is_maximized (meta) ||
66
 
          !Mutter.MetaWindow.allows_resize (meta))
67
 
        return true;
68
 
 
69
 
      unowned string res_class = Mutter.MetaWindow.get_wm_class (meta);
70
 
      foreach (string s in default_exclude_classes)
71
 
        if (res_class.contains (s))
72
 
          return true;
73
 
 
74
 
      void *hint = window.get_data (user_unmaximize_hint);
75
 
      if (hint != null)
76
 
        return true;
77
 
 
78
 
      {
79
 
        Clutter.Actor stage = Clutter.Stage.get_default ();
80
 
 
81
 
        if (window.width < stage.width * 0.6 || window.width > stage.width ||
82
 
            window.height < stage.height * 0.6 || window.height > stage.height ||
83
 
            window.width / window.height < 0.6 ||
84
 
            window.width / window.height > 2.0)
85
 
          {
86
 
            return true;
87
 
          }
88
 
 
89
 
      }
90
 
 
91
 
      return false;
92
 
    }
93
 
 
94
 
    public bool process_window (Mutter.Window window)
95
 
    {
96
 
      if (window_is_excluded (window))
97
 
        return true;
98
 
 
99
 
      Mutter.MetaWindow.maximize (window.get_meta_window (), Mutter.MetaMaximizeFlags.HORIZONTAL | Mutter.MetaMaximizeFlags.VERTICAL);
100
 
 
101
 
      return true;
102
 
    }
103
 
  }
104
 
}