~kokoto-java/kazam/depencie-and-stuff

« back to all changes in this revision

Viewing changes to kazam/frontend/window_select.py

  • Committer: David Klasinc
  • Date: 2012-11-11 19:36:05 UTC
  • mfrom: (193.2.82 unstable)
  • Revision ID: bigwhale@lubica.net-20121111193605-vh3fxglxwfhyh8ne
Merged from unstable branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
        self.window.connect("draw", self.cb_draw)
56
56
        self.window.connect("key-press-event", self.cb_keypress_event)
57
57
        self.window.connect("button-press-event", self.cb_button_press_event)
58
 
        self.window.connect("leave-notify-event", self.cb_motion_notify_event)
59
 
 
60
 
        self.window.set_default_geometry(1, 1)
61
 
        self.window.fullscreen()
 
58
        self.window.connect("leave-notify-event", self.cb_leave_notify_event)
62
59
 
63
60
        self.window.set_border_width(30)
64
61
        self.window.set_app_paintable(True)
72
69
        self.visual = self.screen.get_rgba_visual()
73
70
        self.recording = False
74
71
 
 
72
        self.disp = GdkX11.X11Display.get_default()
 
73
        self.dm = Gdk.Display.get_device_manager(self.disp)
 
74
        self.pntr_device = self.dm.get_client_pointer()
 
75
 
75
76
        if self.visual is not None and self.screen.is_composited():
76
77
            logger.debug("Compositing window manager detected.")
77
78
            self.window.set_visual(self.visual)
79
80
        else:
80
81
            self.compositing = False
81
82
 
82
 
    def cb_motion_notify_event(self, widget, event):
83
 
        time.sleep(0.01) # Facepalm
84
 
        disp = GdkX11.X11Display.get_default()
85
 
        dm = Gdk.Display.get_device_manager(disp)
86
 
        pntr_device = dm.get_client_pointer()
87
 
        (scr, x, y) = pntr_device.get_position()
88
 
        self.window.unfullscreen()
89
 
        self.window.move(x, y)
 
83
        (scr, x, y) = self.pntr_device.get_position()
 
84
        cur = scr.get_monitor_at_point(x, y)
 
85
        self.window.unfullscreen()
 
86
        self.window.move(HW.screens[cur]['x'],
 
87
                         HW.screens[cur]['y'])
 
88
        self.window.fullscreen()
 
89
        crosshair_cursor = Gdk.Cursor(Gdk.CursorType.CROSSHAIR)
 
90
        self.last_cursor = Gdk.Cursor(Gdk.CursorType.LEFT_PTR)
 
91
        self.gdk_win = self.window.get_root_window()
 
92
        self.gdk_win.set_cursor(crosshair_cursor)
 
93
 
 
94
    def cb_leave_notify_event(self, widget, event):
 
95
        (scr, x, y) = self.pntr_device.get_position()
 
96
        cur = scr.get_monitor_at_point(x, y)
 
97
        self.window.unfullscreen()
 
98
        logger.debug("Move to X: {0} Y: {1}".format(HW.screens[cur]['x'], HW.screens[cur]['y']))
 
99
        self.window.move(HW.screens[cur]['x'],
 
100
                         HW.screens[cur]['y'])
90
101
        self.window.fullscreen()
91
102
 
92
103
    def cb_button_press_event(self, widget, event):
110
121
                        if geometry[0] <= event.x_root <= (geometry[0] + geometry[2]) and geometry[1] <= event.y_root <= (geometry[1] + geometry[3]):
111
122
                            self.xid = win.get_xid()
112
123
                            break
 
124
            self.gdk_win.set_cursor(self.last_cursor)
113
125
            self.window.hide()
114
126
            if self.xid:
115
127
                self.emit("window-selected")
119
131
    def cb_keypress_event(self, widget, event):
120
132
        (op, keycode) = event.get_keycode()
121
133
        if keycode == 36 or keycode == 104 or keycode == 9: # Enter or Escape
 
134
            self.gdk_win.set_cursor(self.last_cursor)
122
135
            self.window.hide()
123
136
            self.emit("window-canceled")
124
137