Пример #1
0
    def show_at_position(self, x, y):
        width, height = self.__window.get_size()
        self.move_calendar_inside(width, height, x, y)
        self.__window.show()
        # some window managers ignore move before you show a window. (which
        # ones? question by invernizzi)
        self.move_calendar_inside(width, height, x, y)
        self.__window.grab_add()
        # We grab the pointer in the calendar
        gdk.pointer_grab(self.__window.window, True,
                         gdk.BUTTON1_MASK | gdk.MOD2_MASK)

        self.__window.connect('button-press-event', self.__focus_out)
        #self.__window.connect('button-release-event', self.__maybe_close_calendar)

        self.__sigid = self.__calendar.connect("day-selected",
                                               self.__day_selected, "RealDate")
        self.__sigid_month = self.__calendar.connect("month-changed",
                                                     self.__month_changed)
        # Problem: gtk.Calendar does not tell you directly if the
        #         "day-selected" signal was caused by the user clicking on
        #         a date, or just browsing the calendar.
        # Solution: we track that in a variable
        self.__is_user_just_browsing_the_calendar = False
        self.__mark_today_in_bold()
Пример #2
0
 def window_grab(self, window):
     mask = gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK | gdk.POINTER_MOTION_MASK | gdk.POINTER_MOTION_HINT_MASK | gdk.ENTER_NOTIFY_MASK | gdk.LEAVE_NOTIFY_MASK
     gdk.pointer_grab(window.get_window(),
                      owner_events=True,
                      event_mask=mask)
     #also grab the keyboard so the user won't Alt-Tab away:
     gdk.keyboard_grab(window.get_window(), owner_events=False)
Пример #3
0
 def grab_start(self):
   self.grabbing = True
   gdk.pointer_grab(
       self.window,
       owner_events=False,
       event_mask=gdk.POINTER_MOTION_MASK | gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK,
       confine_to=None,
       cursor=self.cursors.get('magnify'),
       time=0L)
   self.grab_add()
Пример #4
0
 def grab_start(self):
     self.grabbing = True
     gdk.pointer_grab(self.window,
                      owner_events=False,
                      event_mask=gdk.POINTER_MOTION_MASK
                      | gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK,
                      confine_to=None,
                      cursor=self.cursors.get('magnify'),
                      time=0L)
     self.grab_add()
Пример #5
0
 def grab_start(self):
     self.grabbing = True
     gdk.pointer_grab(
         self.window,
         False,
         gdk.POINTER_MOTION_MASK | gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK,
         None,
         self.cursors["magnify"],
         0L,
     )
     self.grab_add()
Пример #6
0
    def popup(self):
        self.show_all()

        # grab pointer
        self.grab_add()
        gdk.pointer_grab(self.window,
                         True,
                         gdk.BUTTON_PRESS_MASK|
                         gdk.BUTTON_RELEASE_MASK|
                         gdk.POINTER_MOTION_MASK,
                         None, None, 
                         gtk.get_current_event_time())
Пример #7
0
 def show_at_position(self, pos_x, pos_y):
     """Displays the window at a specific point on the screen"""
     if not self.loaded:
         self.__load_icon()
     self.move(pos_x, pos_y)
     self.show_all()
     # some window managers ignore move before you show a window. (which
     # ones? question by invernizzi)
     self.move(pos_x, pos_y)
     self.grab_add()
     # We grab the pointer in the calendar
     gdk.pointer_grab(self.window, True, gdk.BUTTON1_MASK | gdk.MOD2_MASK)
     self.connect('button-press-event', self.__focus_out)
Пример #8
0
 def show_at_position(self, pos_x, pos_y):
     """Displays the window at a specific point on the screen"""
     if not self.loaded:
         self.__load_icon()
     self.move(pos_x, pos_y)
     self.show_all()
     # some window managers ignore move before you show a window. (which
     # ones? question by invernizzi)
     self.move(pos_x, pos_y)
     self.grab_add()
     # We grab the pointer in the calendar
     gdk.pointer_grab(self.window, True,
                      gdk.BUTTON1_MASK | gdk.MOD2_MASK)
     self.connect('button-press-event', self.__focus_out)
Пример #9
0
 def __begin_color_pick(self):
     mgr = self.get_color_manager()
     cursor = mgr.get_picker_cursor()
     window = self.get_window()
     result = gdk.pointer_grab(window, False, self.__grab_mask, None, cursor, gdk.CURRENT_TIME)
     if result == gdk.GRAB_SUCCESS:
         self.__picking = True
Пример #10
0
  def run(self):
    global mouse_clicked
    global pointer_position

    self.display = self.get_display()
    cursor = gtk.gdk.Cursor(self.display, gtk.gdk.CROSSHAIR)
    
    main_context = gobject.main_context_default()

    self.mouse_clicked = False
    self.pointer_position = {}
      
    if (gdk.pointer_grab(self.window, True, gdk.BUTTON_RELEASE_MASK,
                         None, self.cursors['search'], 0L) == gtk.gdk.GRAB_SUCCESS):
      self.connect("button_release_event", self.button_release_event_cb)
      self.grabbed = True

      # Process events until clicked is set by button_release_event_cb.
      # We pass in may_block=True since we want to wait if there
      # are no events currently.
      #
      while self.mouse_clicked is False:
        gtk.main_iteration(False) #main_context.iteration(True)
    self.destroy()
    gtk.gdk.flush()     # Really release the grab
          
    toplevel = self.find_window_at_position(self.pointer_position)
    if (toplevel == self):
      toplevel = None;
    return toplevel
    def _begin_drag_child(self, child, x, y, time, action):
        if self._moving_child != None:
            raise AssertionError(
                'attempt to move two children at the same time')

        self._action_type = action

        mask = (gdk.BUTTON_PRESS_MASK
                | gdk.BUTTON_RELEASE_MASK
                | gdk.POINTER_MOTION_MASK)
        grab = gdk.pointer_grab(self.window, False, mask, None, None,
                                long(time))
        if grab != gdk.GRAB_SUCCESS:
            raise AssertionError("grab failed")

        self._children.remove(child)
        self._children.append(child)

        alloc = child.get_allocation()
        self._moving_child = child
        self._moving_start_w = alloc.width
        self._moving_start_h = alloc.height
        self._moving_start_x_pointer = x
        self._moving_start_y_pointer = y
        self._moving_start_x_position = child.x
        self._moving_start_y_position = child.y
Пример #12
0
    def _begin_drag_child(self, child, x, y, time, action):
        if self._moving_child != None:
            raise AssertionError('attempt to move two children at the same time')

        self._action_type = action

        mask = (gdk.BUTTON_PRESS_MASK
              | gdk.BUTTON_RELEASE_MASK
              | gdk.POINTER_MOTION_MASK)
        grab = gdk.pointer_grab(self.window,
                                False,
                                mask,
                                None,
                                None,
                                long(time))
        if grab != gdk.GRAB_SUCCESS:
            raise AssertionError("grab failed")

        self._children.remove(child)
        self._children.append(child)

        alloc = child.get_allocation()
        self._moving_child            = child
        self._moving_start_w          = alloc.width
        self._moving_start_h          = alloc.height
        self._moving_start_x_pointer  = x
        self._moving_start_y_pointer  = y
        self._moving_start_x_position = child.x
        self._moving_start_y_position = child.y
Пример #13
0
 def __begin_color_pick(self):
     mgr = self.get_color_manager()
     cursor = mgr.get_picker_cursor()
     window = self.get_window()
     result = gdk.pointer_grab(window, False, self.__grab_mask, None,
                               cursor, gdk.CURRENT_TIME)
     if result == gdk.GRAB_SUCCESS:
         self.__picking = True
Пример #14
0
    def grab(self):
       """Grab pointer"""
       if pointer_grab(self.window.window, True, GRAB_MASK) == GRAB_SUCCESS:
            self.grabbing = True
            self.grab_btn.set_label('Ungrab')

            e = [ ('motion_notify_event', self.motion_notify_event),
                  ('button_press_event',  self.button_press_event) ]
            self.events = [ self.window.connect(n, h) for n, h in e ]
Пример #15
0
 def popup_grab_on_window(self, window, activate_time):
     if gdk.pointer_grab(
             window, True, gdk.BUTTON_PRESS_MASK
             | gdk.BUTTON_RELEASE_MASK
             | gdk.POINTER_MOTION_MASK, None, None, activate_time) == 0:
         if gdk.keyboard_grab(window, True, activate_time) == 0:
             return True
         else:
             gdk.pointer_ungrab(activate_time)
             return False
     return False
Пример #16
0
 def popup_grab_on_window(self, window, activate_time):
     if gdk.pointer_grab(window, True, gdk.BUTTON_PRESS_MASK 
                                       | gdk.BUTTON_RELEASE_MASK
                                       | gdk.POINTER_MOTION_MASK, 
                         None, None, activate_time) == 0:
             if gdk.keyboard_grab (window, True, activate_time) == 0:
                 return True
             else:
                 gdk.pointer_ungrab(activate_time)
                 return False
     return False
Пример #17
0
 def _popup_grab_window(self):
     activate_time = 0L
     if gdk.pointer_grab(self._entry.window, True,
                         (gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK
                          | gdk.POINTER_MOTION_MASK), None, None,
                         activate_time) == 0:
         if gdk.keyboard_grab(self._entry.window, True, activate_time) == 0:
             return True
         else:
             self._entry.window.get_display().pointer_ungrab(activate_time)
             return False
     return False
 def popup_grab_window(self):
     activate_time = 0L
     if gdk.pointer_grab(self.popup_window.window, True,
                         (gdk.BUTTON_PRESS_MASK |
                          gdk.BUTTON_RELEASE_MASK |
                          gdk.POINTER_MOTION_MASK),
                          None, None, activate_time) == 0:
         if gdk.keyboard_grab(self.popup_window.window, True, activate_time) == 0:
             return True
         else:
             self.popup_window.window.get_display().pointer_ungrab(activate_time);
             return False
     return False
Пример #19
0
 def _popup_grab_window(self):
     activate_time = 0L
     window = self.get_window()
     if gdk.pointer_grab(window, True,
                         (gdk.BUTTON_PRESS_MASK |
                          gdk.BUTTON_RELEASE_MASK |
                          gdk.POINTER_MOTION_MASK),
                         None, None, activate_time) == 0:
         if gdk.keyboard_grab(window, True, activate_time) == 0:
             return True
         else:
             window.pointer_ungrab(activate_time)
             return False
     return False
Пример #20
0
 def show_at_position(self, x, y):
     width, height = self.__window.get_size()
     self.__window.move(x - width, y - height)
     self.__window.show()
     ##some window managers ignore move before you show a window. (which
     # ones? question by invernizzi)
     self.__window.move(x - width, y - height)
     self.__window.grab_add()
     #We grab the pointer in the calendar
     gdk.pointer_grab(self.__window.window, True,
                      gdk.BUTTON1_MASK | gdk.MOD2_MASK)
     self.__window.connect('button-press-event', self.__focus_out)
     self.__sigid = self.__calendar.connect("day-selected",
                                            self.__day_selected,
                                           "RealDate")
     self.__sigid_month = self.__calendar.connect("month-changed",
                                                  self.__month_changed)
     #Problem: gtk.Calendar does not tell you directly if the "day-selected"
     #         signal was caused by the user clicking on a date, or just
     #         browsing the calendar.
     #Solution: we track that in a variable
     self.__is_user_just_browsing_the_calendar = False
     self.__mark_today_in_bold()
Пример #21
0
    def _begin_move_field(self, field, x, y, time):
        if self._moving_field is not None:
            raise AssertionError("can't move two fields at once")

        mask = (gdk.BUTTON_RELEASE_MASK | gdk.BUTTON_RELEASE_MASK |
                gdk.POINTER_MOTION_MASK)
        grab = gdk.pointer_grab(self.window, False, mask, None, None,
                                long(time))
        if grab != gdk.GRAB_SUCCESS:
            raise AssertionError("grab failed")

        self._moving_field = field
        self._moving_start_x_pointer = x
        self._moving_start_y_pointer = y
        self._moving_start_x_position = field.x
        self._moving_start_y_position = field.y
        self._moving_start_width = field.width
        self._moving_start_height = field.height
        w, h = field.widget.get_size_request()
        self._moving_start_w, self._moving_start_h = w, h
Пример #22
0
    def _begin_move_field(self, field, x, y, time):
        if self._moving_field is not None:
            raise AssertionError("can't move two fields at once")

        mask = (gdk.BUTTON_RELEASE_MASK | gdk.BUTTON_RELEASE_MASK
                | gdk.POINTER_MOTION_MASK)
        grab = gdk.pointer_grab(self.window, False, mask, None, None,
                                long(time))
        if grab != gdk.GRAB_SUCCESS:
            raise AssertionError("grab failed")

        self._moving_field = field
        self._moving_start_x_pointer = x
        self._moving_start_y_pointer = y
        self._moving_start_x_position = field.x
        self._moving_start_y_position = field.y
        self._moving_start_width = field.width
        self._moving_start_height = field.height
        w, h = field.widget.get_size_request()
        self._moving_start_w, self._moving_start_h = w, h
Пример #23
0
    def establish_grab(self, t=0):
        # Grab, permitting normal interaction with the app (i.e. with the widgets
        # in the panel).
        mask = gdk.BUTTON_PRESS_MASK
        grab_result = gdk.pointer_grab(self.window, True, mask, None, None, t)
        if grab_result != gdk.GRAB_SUCCESS:
            print "pointer grab failed:", grab_result
            return False

        # Keyboard grab too, to prevent workspace switching.
        grab_result = gdk.keyboard_grab(self.window, False, t)
        if grab_result != gdk.GRAB_SUCCESS:
            print "keyboard grab failed:", grab_result
            gdk.pointer_ungrab()
            return False

        # But limit events to just the panel for neatness and a hint of modality.
        self.grab_add()
        self._grabbed = True
        return True
Пример #24
0
    def establish_grab(self, t=0):
        # Grab, permitting normal interaction with the app (i.e. with the widgets
        # in the panel).
        mask = gdk.BUTTON_PRESS_MASK
        gdk_window = self.get_window()
        grab_result = gdk.pointer_grab(gdk_window, True, mask, None, None, t)
        if grab_result != gdk.GRAB_SUCCESS:
            logger.warning("pointer grab failed: %r", grab_result)
            return False

        # Keyboard grab too, to prevent workspace switching.
        grab_result = gdk.keyboard_grab(gdk_window, False, t)
        if grab_result != gdk.GRAB_SUCCESS:
            logger.warning("keyboard grab failed: %r", grab_result)
            gdk.pointer_ungrab(gdk.CURRENT_TIME)
            return False

        # But limit events to just the panel for neatness and a hint of modality.
        self.grab_add()
        self._grabbed = True
        return True
Пример #25
0
    def _begin_move_child(self, child, x, y, time):
        if self._moving_child != None:
            raise AssertionError("can't move two children at once")

        mask = (gdk.BUTTON_RELEASE_MASK | gdk.BUTTON_RELEASE_MASK |
                gdk.POINTER_MOTION_MASK)
        grab = gdk.pointer_grab(self.window, False, mask, None, None,
                                long(time))
        if grab != gdk.GRAB_SUCCESS:
            raise AssertionError("grab failed")

        self._children.remove(child)
        self._children.append(child)

        self._moving_child = child
        self._moving_start_x_pointer = x
        self._moving_start_y_pointer = y
        self._moving_start_x_position = child.x
        self._moving_start_y_position = child.y
        w, h = child.widget.get_size_request()
        self._moving_start_w, self._moving_start_h = w, h
Пример #26
0
    def _start_drag(self, tdw, event):
        # Attempt to start a new drag, calling drag_start_cb() if successful.
        if self.in_drag:
            return
        if hasattr(event, "x"):
            self.start_x = event.x
            self.start_y = event.y
        else:
            #last_x, last_y = tdw.get_pointer()
            last_t, last_x, last_y = self.doc.get_last_event_info(tdw)
            self.start_x = last_x
            self.start_y = last_y
        tdw_window = tdw.get_window()
        event_mask = (gdk.BUTTON_PRESS_MASK |
                      gdk.BUTTON_RELEASE_MASK |
                      gdk.POINTER_MOTION_MASK)
        cursor = self.active_cursor
        if cursor is None:
            cursor = self.inactive_cursor

        # Grab the pointer
        grab_status = gdk.pointer_grab(tdw_window, False, event_mask, None,
                                       cursor, event.time)
        if grab_status != gdk.GRAB_SUCCESS:
            logger.warning("pointer grab failed: %r", grab_status)
            logger.debug("gdk_pointer_is_grabbed(): %r",
                         gdk.pointer_is_grabbed())
            # There seems to be a race condition between this grab under
            # PyGTK/GTK2 and some other grab - possibly just the implicit grabs
            # on colour selectors: https://gna.org/bugs/?20068 Only pointer
            # events are affected, and PyGI+GTK3 is unaffected.
            #
            # It's probably safest to exit the mode and not start the drag.
            # This condition should be rare enough for this to be a valid
            # approach: the irritation of having to click again to do something
            # should be far less than that of getting "stuck" in a drag.
            if self is self.doc.modes.top:
                logger.debug("Exiting mode")
                self.doc.modes.pop()

            # Sometimes a pointer ungrab is needed even though the grab
            # apparently failed to avoid the UI partially "locking up" with the
            # stylus (and only the stylus). Happens when WMs like Xfwm
            # intercept an <Alt>Button combination for window management
            # purposes. Results in gdk.GRAB_ALREADY_GRABBED, but this line is
            # necessary to avoid the rest of the UI becoming unresponsive even
            # though the canvas can be drawn on with the stylus. Are we
            # cancelling an implicit grab here, and why is it device specific?
            gdk.pointer_ungrab(event.time)
            return

        # We managed to establish a grab, so watch for it being broken.
        # This signal is disconnected when the mode leaves.
        connid = tdw.connect("grab-broken-event", self.tdw_grab_broken_cb)
        self._grab_broken_conninfo = (tdw, connid)

        # Grab the keyboard too, to be certain of getting the key release event
        # for a spacebar drag.
        grab_status = gdk.keyboard_grab(tdw_window, False, event.time)
        if grab_status != gdk.GRAB_SUCCESS:
            logger.warning("Keyboard grab failed: %r", grab_status)
            gdk.pointer_ungrab(event.time)
            if self is self.doc.modes.top:
                logger.debug("Exiting mode")
                self.doc.modes.pop()
            return

        # GTK too...
        tdw.grab_add()
        self._grab_widget = tdw

        # Drag has started, perform whatever action the mode needs.
        self.drag_start_cb(tdw, event)
Пример #27
0
 def lock(self):
     pointer_grab(self.window.window, True)
     keyboard_grab(self.window.window, True)
Пример #28
0
 def pick_start(self):
   self.picking = True
   gdk.pointer_grab(self.window, False, gdk.POINTER_MOTION_MASK | gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK, None, self.cursor, 0L)
   self.grab_add()
Пример #29
0
    def _start_drag(self, tdw, event):
        # Attempt to start a new drag, calling drag_start_cb() if successful.
        if self.in_drag:
            return
        if hasattr(event, "x"):
            self.start_x = event.x
            self.start_y = event.y
        else:
            #last_x, last_y = tdw.get_pointer()
            last_t, last_x, last_y = self.doc.get_last_event_info(tdw)
            self.start_x = last_x
            self.start_y = last_y
        tdw_window = tdw.get_window()
        event_mask = (gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK
                      | gdk.POINTER_MOTION_MASK)
        cursor = self.active_cursor
        if cursor is None:
            cursor = self.inactive_cursor

        # Grab the pointer
        grab_status = gdk.pointer_grab(tdw_window, False, event_mask, None,
                                       cursor, event.time)
        if grab_status != gdk.GRAB_SUCCESS:
            logger.warning("pointer grab failed: %r", grab_status)
            logger.debug("gdk_pointer_is_grabbed(): %r",
                         gdk.pointer_is_grabbed())
            # There seems to be a race condition between this grab under
            # PyGTK/GTK2 and some other grab - possibly just the implicit grabs
            # on color selectors: https://gna.org/bugs/?20068 Only pointer
            # events are affected, and PyGI+GTK3 is unaffected.
            #
            # It's probably safest to exit the mode and not start the drag.
            # This condition should be rare enough for this to be a valid
            # approach: the irritation of having to click again to do something
            # should be far less than that of getting "stuck" in a drag.
            if self is self.doc.modes.top:
                logger.debug("Exiting mode")
                self.doc.modes.pop()

            # Sometimes a pointer ungrab is needed even though the grab
            # apparently failed to avoid the UI partially "locking up" with the
            # stylus (and only the stylus). Happens when WMs like Xfwm
            # intercept an <Alt>Button combination for window management
            # purposes. Results in gdk.GRAB_ALREADY_GRABBED, but this line is
            # necessary to avoid the rest of the UI becoming unresponsive even
            # though the canvas can be drawn on with the stylus. Are we
            # cancelling an implicit grab here, and why is it device specific?
            gdk.pointer_ungrab(event.time)
            return

        # We managed to establish a grab, so watch for it being broken.
        # This signal is disconnected when the mode leaves.
        connid = tdw.connect("grab-broken-event", self.tdw_grab_broken_cb)
        self._grab_broken_conninfo = (tdw, connid)

        # Grab the keyboard too, to be certain of getting the key release event
        # for a spacebar drag.
        grab_status = gdk.keyboard_grab(tdw_window, False, event.time)
        if grab_status != gdk.GRAB_SUCCESS:
            logger.warning("Keyboard grab failed: %r", grab_status)
            gdk.pointer_ungrab(event.time)
            if self is self.doc.modes.top:
                logger.debug("Exiting mode")
                self.doc.modes.pop()
            return

        # GTK too...
        tdw.grab_add()
        self._grab_widget = tdw

        # Drag has started, perform whatever action the mode needs.
        self.drag_start_cb(tdw, event)