Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 26 additions & 15 deletions cairoEng.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import pygtk
pygtk.require('2.0')
import gtk, gobject, cairo
import gtk, gobject, cairo, os
from time import time, sleep
import threading

Expand All @@ -52,10 +52,13 @@ def mkMatrix(p0, p1, p2, size):
x0 , y0 )

def toShapeMap(surface):
width = surface.get_width()
height = surface.get_height()

bitmap = gtk.gdk.Pixmap(None, width, height, 1)
if not os.name=="nt":
#surface.getwidth() doesn't work on windows
width = surface.get_width()
height = surface.get_height()
bitmap = gtk.gdk.Pixmap(None, width, height, 1)
else:
bitmap = gtk.gdk.Pixmap(None, 200, 200, 1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this one need to be 200x200 on Windows?

bmpCr = bitmap.cairo_create()

patt = cairo.SurfacePattern(surface)
Expand Down Expand Up @@ -83,13 +86,16 @@ def __init__(self, animation, texture, getFrameRect, offset):

# Handle the expose-event by drawing
def do_expose_event(self, event):
if not hasattr(self, 'bg') :
if self.is_composited():
print("Composite! \o/")
self.bg = None
else:
self.bg = capt_screen(self)

if not hasattr(self, 'bg'):
if self.is_composited():
print("Composite! \o/")
self.bg = None
else:
#capt_screen doesn't work properly on windows and only slows everything down
if os.name=="nt":
self.bg = None
else:
self.bg = capt_screen(self)
# Create the cairo context
cr = self.window.cairo_create()

Expand Down Expand Up @@ -206,9 +212,14 @@ def on_size_allocate(wind, rect):
window.set_skip_pager_hint(True)
window.set_keep_above(True)
window.stick()
window.set_default_size(*size)

colormap = window.get_screen().get_rgba_colormap()
window.set_default_size(*size)

#the other function doesn't work on windows
#which sadly means that transparency doesn't work on windows
if os.name=="nt":
colormap = gtk.gdk.colormap_get_system()
else:
colormap = window.get_screen().get_rgba_colormap()
gtk.widget_set_default_colormap(colormap)

window.present()
Expand Down
8 changes: 7 additions & 1 deletion cairoFidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@

import fidget
import cairoEng
import os

if __name__ == "__main__":
cairoEng.run(fidget.Fidget(), "fidget-sprites.png", fidget.getFrameRect, (171, 151), (-28, -2))
spritefilename = 'fidget-sprites.png'
#if user is running windows then make sure python knows the exact folder where the sprite file is
#which by default is the script's folder, otherwise python can't see the file in windows
if os.name=="nt":
spritefilename = os.path.dirname(__file__) + "\\" + 'fidget-sprites.png'
cairoEng.run(fidget.Fidget(), spritefilename, fidget.getFrameRect, (171, 151), (-28, -2))