[Deskbar] [PATCH] Monitor detection by davyd



Davyd did some preliminary foot work for Xinerama support last night. I
attached his patch. It does not Xinerama-enable deskbar (yet), but it
doesn't break anything either :)

Cheers
Mikkel
? deskbar/beagle/Makefile
? deskbar/beagle/Makefile.in
? deskbar/beagle/_beagle.c
? deskbar/ui/cuemiac/.Cuemiac.py.swp
? deskbar/ui/cuemiac/.CuemiacAlignedWindow.py.swp
Index: deskbar/ui/cuemiac/Cuemiac.py
===================================================================
RCS file: /cvs/gnome/deskbar-applet/deskbar/ui/cuemiac/Cuemiac.py,v
retrieving revision 1.40
diff -u -p -r1.40 Cuemiac.py
--- deskbar/ui/cuemiac/Cuemiac.py	2 Feb 2006 23:44:15 -0000	1.40
+++ deskbar/ui/cuemiac/Cuemiac.py	3 Feb 2006 01:47:42 -0000
@@ -616,12 +616,12 @@ class CuemiacUI (DeskbarUI):
 		self.deskbar_button.connect ("toggled-main", lambda x,y: self.show_entry())
 		self.deskbar_button.connect ("toggled-arrow", lambda x,y: self.show_history())
 
-		self.popup = CuemiacAlignedWindow (self.deskbar_button.button_main, applet.get_orient())
+		self.popup = CuemiacAlignedWindow (self.deskbar_button.button_main, applet)
 		self.icon_entry = deskbar.iconentry.IconEntry ()
 		self.entry = self.icon_entry.get_entry ()
 		self.entry_icon = gtk.Image ()
 		self.history = get_deskbar_history ()
-		self.history_popup = CuemiacHistoryPopup (self.history, self.deskbar_button.button_arrow, applet.get_orient ())
+		self.history_popup = CuemiacHistoryPopup (self.history, self.deskbar_button.button_arrow, applet)
 		self.model = CuemiacModel ()
 		self.cview = CuemiacTreeView (self.model)
 		self.scroll_win = gtk.ScrolledWindow ()
@@ -846,6 +846,7 @@ class CuemiacUI (DeskbarUI):
 		w = min (w, self.max_window_width)
 		if w > 0 and h > 0:
 			self.popup.resize (w, h)
+			# self.popup.update_position ()
 		else:
 			print "Deskbar Warning: tried to set window size to (%s, %s)" % (w, h)
 		
Index: deskbar/ui/cuemiac/CuemiacAlignedWindow.py
===================================================================
RCS file: /cvs/gnome/deskbar-applet/deskbar/ui/cuemiac/CuemiacAlignedWindow.py,v
retrieving revision 1.4
diff -u -p -r1.4 CuemiacAlignedWindow.py
--- deskbar/ui/cuemiac/CuemiacAlignedWindow.py	31 Jan 2006 21:27:50 -0000	1.4
+++ deskbar/ui/cuemiac/CuemiacAlignedWindow.py	3 Feb 2006 01:47:43 -0000
@@ -5,7 +5,7 @@ class CuemiacAlignedWindow (gtk.Window):
 	Borderless window aligning itself to a given widget.
 	Use CuemiacWindow.update_position() to align it.
 	"""
-	def __init__(self, widgetToAlignWith, alignment):
+	def __init__(self, widgetToAlignWith, applet):
 		"""
 		alignment should be one of
 			gnomeapplet.ORIENT_{DOWN,UP,LEFT,RIGHT}
@@ -15,6 +15,7 @@ class CuemiacAlignedWindow (gtk.Window):
 		gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
 		self.set_decorated (False)
 
+		print applet, type (applet)
 		# Skip the taskbar, and the pager, stick and stay on top
 		self.stick()
 		self.set_keep_above(True)
@@ -22,7 +23,8 @@ class CuemiacAlignedWindow (gtk.Window):
 		self.set_skip_taskbar_hint(True)
 		
 		self.widgetToAlignWith = widgetToAlignWith
-		self.alignment = alignment
+		self.applet = applet
+		self.alignment = applet.get_orient ()
 
 		self.is_realized = False
 		self.connect ("realize", lambda win : self.__register_realize ())
@@ -48,20 +50,14 @@ class CuemiacAlignedWindow (gtk.Window):
 		target_h = self.widgetToAlignWith.allocation.height
 
 		screen = self.get_screen()
-
-		found_monitor = False
-		n = screen.get_n_monitors()
-		for i in range(0, n):
-				monitor = screen.get_monitor_geometry(i)
-				if (x >= monitor.x and x <= monitor.x + monitor.width and \
-					y >= monitor.y and y <= monitor.y + monitor.height):
-						found_monitor = True
-						break
-		
-		if not found_monitor:
-				monitor = gtk.gdk.Rectangle(0, 0, screen.get_width(), screen.get_width())
+		# XXX: FIXME: we should get the monitor that the applet is on,
+		# not the realised window
+		monitor = screen.get_monitor_geometry (screen.get_monitor_at_window (self.applet.window))
+		print "monitor %i" % screen.get_monitor_at_window (self.applet.window)
 		
-		self.alignment
+		print "x = %i, y = %i, w = %i, h = %i" % (x, y, target_w, target_h)
+		print "monitor: x = %i, y = %i, w = %i, h = %i" % (
+			monitor.x, monitor.y, monitor.width, monitor.height)
 		if self.alignment == gnomeapplet.ORIENT_RIGHT:
 				x += target_w
 
@@ -83,10 +79,12 @@ class CuemiacAlignedWindow (gtk.Window):
 				else:
 						gravity = gtk.gdk.GRAVITY_NORTH_EAST
 		elif self.alignment == gnomeapplet.ORIENT_DOWN:
+				print "got alignment:DOWN"
 				y += target_h
 
-				if ((x + w) > monitor.x + monitor.width):
-						x -= (x + w) - (monitor.x + monitor.width)
+				if ((x + target_w) > (monitor.x + monitor.width)):
+					print "will exceed monitor"
+					x -= (x + w) - (monitor.x + monitor.width)
 
 				gravity = gtk.gdk.GRAVITY_NORTH_WEST
 		elif self.alignment == gnomeapplet.ORIENT_UP:
Index: deskbar/ui/cuemiac/CuemiacHistory.py
===================================================================
RCS file: /cvs/gnome/deskbar-applet/deskbar/ui/cuemiac/CuemiacHistory.py,v
retrieving revision 1.2
diff -u -p -r1.2 CuemiacHistory.py
--- deskbar/ui/cuemiac/CuemiacHistory.py	25 Jan 2006 18:12:52 -0000	1.2
+++ deskbar/ui/cuemiac/CuemiacHistory.py	3 Feb 2006 01:47:43 -0000
@@ -69,8 +69,8 @@ class CuemiacHistoryPopup (CuemiacAligne
 		"match-selected" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [gobject.TYPE_PYOBJECT]),
 	}
 	
-	def __init__ (self, deskbar_history, widget_to_align_with, alignment):
-		CuemiacAlignedWindow.__init__ (self, widget_to_align_with, alignment)
+	def __init__ (self, deskbar_history, widget_to_align_with, applet):
+		CuemiacAlignedWindow.__init__ (self, widget_to_align_with, applet)
 		view = CuemaicHistoryView (deskbar_history)
 		self.add (view)
 		


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]