Migrating the DnD overlay code in an expose event
as this seems to be the only way to have an overlay dran with no flicker
This commit is contained in:
parent
735ae78341
commit
18e58148a4
|
@ -123,7 +123,7 @@ class TerminatorTerm (gtk.VBox):
|
||||||
self._vte.connect ("key-press-event", self.on_vte_key_press)
|
self._vte.connect ("key-press-event", self.on_vte_key_press)
|
||||||
self._vte.connect ("button-press-event", self.on_vte_button_press)
|
self._vte.connect ("button-press-event", self.on_vte_button_press)
|
||||||
self._vte.connect ("popup-menu", self.on_vte_popup_menu)
|
self._vte.connect ("popup-menu", self.on_vte_popup_menu)
|
||||||
|
self._vte._expose_data = None
|
||||||
"""drag and drop"""
|
"""drag and drop"""
|
||||||
srcvtetargets = [ ( "vte", gtk.TARGET_SAME_APP, self.TARGET_TYPE_VTE ) ]
|
srcvtetargets = [ ( "vte", gtk.TARGET_SAME_APP, self.TARGET_TYPE_VTE ) ]
|
||||||
dsttargets = [ ( "vte", gtk.TARGET_SAME_APP, self.TARGET_TYPE_VTE ), ('text/plain', 0, 0) , ("STRING", 0, 0), ("COMPOUND_TEXT", 0, 0)]
|
dsttargets = [ ( "vte", gtk.TARGET_SAME_APP, self.TARGET_TYPE_VTE ), ('text/plain', 0, 0) , ("STRING", 0, 0), ("COMPOUND_TEXT", 0, 0)]
|
||||||
|
@ -148,6 +148,8 @@ class TerminatorTerm (gtk.VBox):
|
||||||
self._vte.connect ("focus-out-event", self.on_vte_focus_out)
|
self._vte.connect ("focus-out-event", self.on_vte_focus_out)
|
||||||
self._vte.connect ("focus-in-event", self.on_vte_focus_in)
|
self._vte.connect ("focus-in-event", self.on_vte_focus_in)
|
||||||
|
|
||||||
|
self._vte.connect('expose-event', self.on_expose_event)
|
||||||
|
|
||||||
|
|
||||||
exit_action = self.conf.exit_action
|
exit_action = self.conf.exit_action
|
||||||
if exit_action == "restart":
|
if exit_action == "restart":
|
||||||
|
@ -193,6 +195,29 @@ class TerminatorTerm (gtk.VBox):
|
||||||
dbg ("Drag data get")
|
dbg ("Drag data get")
|
||||||
selection_data.set("vte",info, str(data.terminator.term_list.index (self)))
|
selection_data.set("vte",info, str(data.terminator.term_list.index (self)))
|
||||||
|
|
||||||
|
|
||||||
|
def on_expose_event(self, widget, event):
|
||||||
|
if widget._expose_data is None:
|
||||||
|
return False
|
||||||
|
|
||||||
|
color = widget._expose_data['color']
|
||||||
|
coord = widget._expose_data['coord']
|
||||||
|
|
||||||
|
context = widget.window.cairo_create()
|
||||||
|
#leaving those xxx_group as they could be usefull
|
||||||
|
##http://macslow.thepimp.net/?p=153
|
||||||
|
#context.push_group()
|
||||||
|
context.set_source_rgba(color.red, color.green, color.blue, 0.5)
|
||||||
|
if len(coord) > 0 :
|
||||||
|
context.move_to(coord[len(coord)-1][0],coord[len(coord)-1][1])
|
||||||
|
for i in coord:
|
||||||
|
context.line_to(i[0],i[1])
|
||||||
|
|
||||||
|
context.fill()
|
||||||
|
#context.pop_group_to_source()
|
||||||
|
#context.paint()
|
||||||
|
return False
|
||||||
|
|
||||||
def on_drag_motion(self, widget, drag_context, x, y, time, data):
|
def on_drag_motion(self, widget, drag_context, x, y, time, data):
|
||||||
dbg ("Drag Motion on ")
|
dbg ("Drag Motion on ")
|
||||||
"""
|
"""
|
||||||
|
@ -217,8 +242,7 @@ text/plain
|
||||||
|
|
||||||
alloc = widget.allocation
|
alloc = widget.allocation
|
||||||
rect = gtk.gdk.Rectangle(0, 0, alloc.width, alloc.height)
|
rect = gtk.gdk.Rectangle(0, 0, alloc.width, alloc.height)
|
||||||
widget.window.invalidate_rect(rect, True)
|
|
||||||
widget.window.process_updates(True)
|
|
||||||
if self.conf.use_theme_colors:
|
if self.conf.use_theme_colors:
|
||||||
color = self._vte.get_style ().text[gtk.STATE_NORMAL]
|
color = self._vte.get_style ().text[gtk.STATE_NORMAL]
|
||||||
else:
|
else:
|
||||||
|
@ -246,19 +270,13 @@ text/plain
|
||||||
coord = (bottomleft, bottomright, middleright , middleleft)
|
coord = (bottomleft, bottomright, middleright , middleleft)
|
||||||
|
|
||||||
|
|
||||||
|
#here, we define some widget internal values
|
||||||
|
widget._expose_data = { 'color': color, 'coord' : coord }
|
||||||
context = widget.window.cairo_create()
|
#redraw by forcing an event
|
||||||
context.push_group()
|
widget.window.invalidate_rect(rect, True)
|
||||||
context.set_source_rgba(color.red, color.green, color.blue, 0.5)
|
widget.window.process_updates(True)
|
||||||
if len(coord) > 0 :
|
#finaly reset the values
|
||||||
context.move_to(coord[len(coord)-1][0],coord[len(coord)-1][1])
|
widget._expose_data = None
|
||||||
for i in coord:
|
|
||||||
context.line_to(i[0],i[1])
|
|
||||||
|
|
||||||
context.fill()
|
|
||||||
context.pop_group_to_source()
|
|
||||||
context.paint()
|
|
||||||
|
|
||||||
|
|
||||||
def on_drag_drop(self, widget, drag_context, x, y, time):
|
def on_drag_drop(self, widget, drag_context, x, y, time):
|
||||||
|
|
Loading…
Reference in New Issue