xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #201: focus-OK-with-jdk6.patch

File focus-OK-with-jdk6.patch, 4.0 KB (added by Antoine Martin, 8 years ago)

with this patch - focus works with JDK6

  • src/wimpiggy/window.py

    ### Eclipse Workspace Patch 1.0
    #P Xpra
     
    10381038    def give_client_focus(self):
    10391039        """The focus manager has decided that our client should recieve X
    10401040        focus.  See world_window.py for details."""
    1041         log("Giving focus to client")
     1041        protocols = self.get_property("protocols")
     1042        log.info("Giving focus to client, protocols=%s, input_field=%s, can-focus=%s", protocols, self._input_field, self.get_property("can-focus"))
    10421043        # Have to fetch the time, not just use CurrentTime, both because ICCCM
    10431044        # says that WM_TAKE_FOCUS must use a real time and because there are
    10441045        # genuine race conditions here (e.g. suppose the client does not
    10451046        # actually get around to requesting the focus until after we have
    10461047        # already changed our mind and decided to give it to someone else).
    1047         now = gtk.gdk.x11_get_server_time(self.corral_window)
    10481048        # ICCCM 4.1.7 *claims* to describe how we are supposed to give focus
    10491049        # to a window, but it is completely opaque.  From reading the
    10501050        # metacity, kwin, gtk+, and qt code, it appears that the actual rules
     
    10581058        # XSetInputFocus well, while Qt apps ignore (!!!) WM_TAKE_FOCUS
    10591059        # (unless they have a modal window), and just expect to get focus from
    10601060        # the WM's XSetInputFocus.
    1061         success = True
    1062         if self._input_field:
    1063             log("... using XSetInputFocus")
    1064             if not trap.swallow(XSetInputFocus, self.client_window, now):
    1065                 log("XSetInputFocus failed...")
    1066                 success = False
    1067         if "WM_TAKE_FOCUS" in self.get_property("protocols"):
    1068             log("... using WM_TAKE_FOCUS")
    1069             if not trap.swallow(send_wm_take_focus, self.client_window, now):
    1070                 log("WM_TAKE_FOCUS failed...")
    1071                 success = False
    1072         return success
     1061        def wm_take_focus(now):
     1062            log.info("... using WM_TAKE_FOCUS")
     1063            send_wm_take_focus(self.client_window, now)
     1064        def x11_set_focus(now):
     1065            log.info("... using XSetInputFocus")
     1066            XSetInputFocus(self.client_window, now)
    10731067
     1068        def give_focus():
     1069            now = gtk.gdk.x11_get_server_time(self.corral_window)
     1070            if self._input_field:
     1071                x11_set_focus(now)
     1072            if "WM_TAKE_FOCUS" in protocols:
     1073                wm_take_focus(now)
     1074
     1075        def call_focus():
     1076            trap.swallow(give_focus)
     1077
     1078        gobject.idle_add(call_focus)
     1079        #call_focus()
     1080
     1081
    10741082    ################################
    10751083    # Killing clients:
    10761084    ################################
  • src/xpra/server.py

     
    604604        unpress_all_keys(gtk.gdk.display_get_default())
    605605
    606606    def _focus(self, server_source, wid, modifiers):
    607         log("_focus(%s,%s) has_focus=%s", wid, modifiers, self._has_focus)
     607        log.info("_focus(%s,%s) has_focus=%s", wid, modifiers, self._has_focus)
    608608        if self._has_focus != wid:
    609609            def reset_focus():
    610610                self._clear_keys_pressed()
     
    617617            window = self._id_to_window.get(wid)
    618618            if not window:
    619619                return reset_focus()
    620             #no idea why we can't call this straight away!
    621             #but with win32 clients, it would often fail!???
    622             def give_focus():
    623                 window.give_client_focus()
    624                 return False
    625             gobject.idle_add(give_focus)
    626620            if server_source and modifiers is not None:
    627621                server_source.make_keymask_match(modifiers)
    628622            self._has_focus = wid
     623            window.give_client_focus()
    629624
    630625    def _move_pointer(self, pos):
    631626        (x, y) = pos