Community
Participate
Working Groups
Build Identifier: R3_7_1 When building SWT with GTK+ 3.x It gives warnings on deprecated methods gdk_color_white and gdk_gc_set_foreground that are used in Tracker - drawRectangles (..) method Reproducible: Always Steps to Reproduce: 1. Uncomment GDK_DISABLE_DEPRECATED in org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h 2. Build SWT
Cairo implementation for tracker widget drawRectangles() method. Fixes incompatibility of Tracker with GTK 3.x by omitting use of gdk_color_white and gdk_set_foreground deprecated methods. commit/patch: http://fedorapeople.org/gitweb?p=aspektor/public_git/eclipse.platform.swt.git;a=commit;h=7eb39505fe0ea4da84d8b917779e7cdc43b38cc9
This patch does not work for me when the Tracker is created on a display. Nothing is drawn on the screen. Try this snippet. Does it work for you? package org.eclipse.swt.snippets; /* * Tracker example snippet: create a tracker (drag on mouse down) * * For a list of all SWT example snippets see * http://www.eclipse.org/swt/snippets/ */ import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.widgets.*; public class Snippet23 { public static void main (String [] args) { final Display display = new Display (); final Shell shell = new Shell (display); shell.open (); shell.addListener (SWT.MouseDown, new Listener () { public void handleEvent (Event e) { Tracker tracker = new Tracker (display, SWT.NONE); tracker.setRectangles (new Rectangle [] { new Rectangle (e.x, e.y, 100, 100), }); tracker.open (); } }); while (!shell.isDisposed()) { if (!display.readAndDispatch ()) display.sleep (); } display.dispose (); } }
Hello Silenio, Thank you for pointing that out. I have been trying to make it work when "display" is passed for couple of weeks now, but no luck. The problem is that when display is passed - parent is null so Root window is used as drawing surface. I am sure you are aware that it is considered a bad practice to draw on the root window (this is the way GDK does it now). In fact Cairo is not able to draw on such surface,and it is my mine concern. When cairo tries to draw on root - drawing is clipped by inferiors. The best solution I could think of would be to create transparent gtk window, move it when new rectangle need to be drawn. However there are couple of problems with this as well. I have written a blog post regarding my findings and issues I have faced with Tracker Widget. So if you want to get more info please visit this link: http://myprogrammingblog.com/2012/07/17/swt-migration-to-gtk-3-x-tracker-dilliemma/ Thank you for your time. Any help is highly appreciated. Regards, Anatoly
Yes, drawing directly to the screen is something from the past. All toolkits advise against it now a days. I believe you are on the right track. We have already moved our implementation on Windows and Mac to use an overlay transparent window that fills the whole screen. The window is only opaque where the rectangles are drawn. Since the window fills the whole screen, you would not have to open/close it as the mouse moves. You just have to redraw the old and new areas of the rectangles and draw the rectangles when the expose event happens. I was going to suggest to draw the rectangles during the "expose-event" signal (instead of "draw" signal), but I just realized this signal is not available in GTK 3. I think we have a bigger problem to solve since SWT uses the expose-event signal heavily to implement SWT.Paint events. We need to open a separate bug to handle this conversion from "expose-event" to "draw" signal. Anyways, for now I think you should use the "expose-event" signal to draw the rectangles so that you can test your implementation against GTK 2. Please take a look at the Windows and Cocoa implementation to have an idea of how to proceed.
Created attachment 223133 [details] work in progress
Fixed http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=b09edce9791823c67c1356847c83053f4c27bd85