python-wnck set focus to window -


i'm trying set focus window using python-wnck.
docs find related library https://developer.gnome.org/libwnck/stable/wnckwindow.html

using code found on question here @ so, able search windows using window title, i'm not sure how window focus.
from above docs found function:

wnck_window_activate(wnckwindow *window, guint32 timestamp); 


so in python tried using function "window.activate(0)", appears fail, icon on taskbar flashed doesn't focus.
in terminal message:

 (windowtest.py:17485): wnck-warning: received timestamp of 0; window activation may not function 

so think may need put in valid timestamp not sure how this.

this code im using sofar:

import pygtk pygtk.require('2.0') import gtk import wnck import re import sys  screen = wnck.screen_get_default() while gtk.events_pending():     gtk.main_iteration()  titlepattern = re.compile('.*geany.*')  windows = screen.get_windows() w in windows:   if titlepattern.match(w.get_name()):     print w.get_name()     w.activate(0) 

to away wnck-warning, need send valid timestamp w.activate() function. way found use:

now = gtk.gdk.x11_get_server_time(gtk.gdk.get_default_root_window())

w.activate(now)

there should easier way this, or wnck should allow timestamp of 0 mean now of gtk libraries use.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -