| Summary: | Set text editor background to black, mouse cursor becomes invisible | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Chamee Leon <christianchua> | ||||||
| Component: | SWT | Assignee: | Lakshmi P Shanmugam <lshanmug> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | Silenio Quarti <Silenio_Quarti> | ||||||
| Severity: | major | ||||||||
| Priority: | P3 | CC: | carolynmacleod4, eclipse.felipe, lshanmug, macocha, Mike_Wilson, remy.suen, Silenio_Quarti, starrynight197, thechamaeleon | ||||||
| Version: | 4.2 | ||||||||
| Target Milestone: | 3.8 M6 | ||||||||
| Hardware: | Macintosh | ||||||||
| OS: | Mac OS X | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
|
Description
Chamee Leon
isn't this (again) a general problem on the mac ? don't you have this problem on other application (xcode, textmate, etc) ? I have XCode 4.1. Set the background to pure black. I-Beam is visible. Also set "Terminal"'s background to pure black. I-Beam is also visible. Are you saying that you do not see the problem on your setup? (In reply to comment #2) > Are you saying that you do not see the problem on your setup? Sorry, I'm just doing a quick bug triage (and I don't really have the time to test every bug). Lakshmi, please get to the bottom of it, if XCode and terminal work, then so should SWT. Thank you. This seems like the default behavior/limitation in Cocoa. It doesn't happen in Carbon. I couldn't find a way to have the mouse cursor(IBeam) automatically change color based on the background. I can see the same problem in other Apple apps such as TextEdit and Mail. Terminal.app uses its own IBeam cursor, so it doesn't happpen there. I'm not sure if the Xcode editor too does the same to get around the problem. It does not happen in Carbon *IF* you are using Snow Leopard (10.6) and below. But now I am forced to use Lion, and even using Carbon will have this "invisible I-Beam" issue. This the link to the Carbon-Eclipse I am using for this bug: http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/galileo/SR2/eclipse-jee-galileo-SR2-macosx-carbon.tar.gz So what should we do now ? Carbon is not available in Eclipse 3.6 and above, right ? Are you saying Eclipse users who need a black text background because of eye problems should revert to Snow Leopard ? and only use Eclipse 3.5 and below ? If Terminal.app can use its own I-Beam, why not Eclipse ? Yes, eclipse can provide it's one I-beam cursor that can handle darker backgrounds. But the right solution here is for Apple to make the systemwide I-beam cursor handle dark backgrounds, so that all applications take advantage of this fix (including TextEdit.app and Mail.app). A radar bug should be open for this. Quick Question: Do the SWT owners plan to fix this ? If yes, is there an estimated date of completion ? So users can plan accordingly -- whether or not to do research on alternative IDEs. I don't think Apple is going to fix an issue found in Eclipse. XCode 4 does not have this problem. Also see bug 309660 and bug 357248. *** Bug 357248 has been marked as a duplicate of this bug. *** This is an accessibility issue. We should fix it. Lakshimi, let us work on a workaround for the problem. Some googling shows that we could try the carbon call SetThemeCursor(). I am not sure this is the right approach. It probably would not work on 64 bit. Please open a radar bug as well, since this is not a bug in Eclipse only. Here is a snippet that gets the system I-beam image and replaces black pixels with white. The results are not that great and we would have to detect the background of the widget on the fly (only possible for widgets with solid background). Since reserve screen is not support in cocoa, we need to have an "embossed" cursor (white and black) to work in both light and dark backgrounds. The good thing about this approach is that we keep the system I-beam shape if it ever changes in the future.
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.cocoa.NSImage;
import org.eclipse.swt.internal.cocoa.NSPoint;
import org.eclipse.swt.internal.cocoa.OS;
import org.eclipse.swt.layout.FillLayout;
public class DisposedTest {
public static void main(String [] args) {
Display display = new Display();
Shell shell = new Shell(display);
FillLayout layout = new FillLayout();
layout.marginHeight = layout.marginWidth = 300;
shell.setLayout(layout);
shell.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
Cursor cursor = new Cursor(display, SWT.CURSOR_IBEAM);
shell.setCursor(cursor);
Label label = new Label(shell, SWT.NONE);
NSImage nsimage = new NSImage(OS.objc_msgSend(cursor.handle.id, OS.sel_image));
Image image = Image.cocoa_new(display, SWT.BITMAP, nsimage);
ImageData data = image.getImageData();
for (int y = 0; y < data.height; y++) {
for (int x = 0; x < data.height; x++) {
int pixel = data.getPixel(x, y);
if (pixel == 0) {
data.setPixel(x, y, 0xFFFFFFFF);
}
}
}
NSPoint pt = new NSPoint();
OS.objc_msgSend_stret(pt, cursor.handle.id, OS.sel_registerName("hotSpot"));
System.out.println(pt);
Cursor newCursor = new Cursor(display, data, (int)pt.x, (int)pt.y);
shell.setCursor(newCursor);
Image image1 = new Image(display, data);
label.setImage(image1);
label.setBackground(display.getSystemColor(SWT.COLOR_RED));
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
}
}
Does this mean the problem will be gone in the next release of Eclipse ? It should be (In reply to comment #13) > Does this mean the problem will be gone in the next release of Eclipse ? Do you mean 3.7.2? We would have to see whether we are confident about the fix or not. Note that we do not have a fix still, but we should be able to just have a custom cursor. If does not go into 3.7.2, it will be done for 3.8/4.2. (In reply to comment #11) > Lakshimi, let us work on a workaround for the problem. Some googling shows that > we could try the carbon call SetThemeCursor(). I am not sure this is the right > approach. It probably would not work on 64 bit. > > Please open a radar bug as well, since this is not a bug in Eclipse only. Hi Silenio, I have opened a bug with apple, Problem ID: 10265347. Should we fix this in StyledText and Text widget? or in Eclipse by using a custom cursor (may be similar to the Shadowed IBeam cursor used by the Terminal.app)? Bug 309660 too is opened for the same problem. The patch in the bug (https://bugs.eclipse.org/bugs/attachment.cgi?id=165481) tries to fix this by using a custom cursor and color preference in eclipse. We should fix both StyledText and Text. I believe in Cursor(Device, int), we can create our own i-beam instead of using NSCursor.IBeamCursor(). This would take care of StyledText and other custom widgets. In order to fix Text, we need to re-implement Control.findCursor() and return display.getSystemCursor(SWT.CURSOR_IBEAM) (only when the widget cursor is null) so that our custom cursor create above is used. I do not think our custom cursor should take the approach of the https://bugs.eclipse.org/bugs/attachment.cgi?id=165481 because it would be dependent on the background of the widget to be good. It should look like the Terminal and Xcode I-beam which is black with a white shadow to left side. This way it can work in light and dark backgrounds. Created attachment 208112 [details]
workspace patch
The patch creates a custom Shadowed IBeam cursor similar to IBeam used by Terminal app. It fixes the cursor for StyledText, Text, Spinner, Combo.
Silenio, could you please review?
Car, please could you review this patch? I will not be able to review until I am back in the office (no Mac). By just looking at the patch it seems fine. I can confirm that the code looks ok, and that it works fine on SSQ's Mac with Lion. (Also works fine on my old PPC with Leopard, FYI). However, I cannot confirm that the problem exists. I could always see the mouse cursor (and the text cursor) very easily on SSQ's Lion, even before applying the patch. I looked at cursors all over the place - Text, StyledText, Combo, Spinner, Browser, etc, etc. I also ran a bunch of cursor-related snippets: Snippet130, Snippet44, Snippet119, and Snippet242, and all cursors showed up as expected. They show up bright and white, and there is no doubt that they are there. So I am really sorry, but I can't be of further help here. Lakshmi, are you running on Lion? Do you have access to another Lion machine? There may be something special about SSQ's Lion. We should first figure out what that is, so that we can put the patch code in as a special case only, for Macs that have this problem. How are you setting the background to black? I used System Settings, Universal Access, Seeing, White on Black. Sorry "System Preferences" not "Settings" In case it's helpful, SSQ's Mac has the following specs: Hardware Overview: Model Name: iMac Model Identifier: iMac8,1 Processor Name: Intel Core 2 Duo Processor Speed: 2.66 GHz Number of Processors: 1 Total Number of Cores: 2 L2 Cache: 6 MB Memory: 2 GB Bus Speed: 1.07 GHz Boot ROM Version: IM81.00C1.B00 SMC Version (system): 1.29f1 Software Mac OS X Lion 10.7.2 (11C74) To reproduce the problem : Install this on OSX Lion 10.7.2 Eclipse IDE for Java Developers Version: Indigo Service Release 1 Build id: 20110916-0149 http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/indigo/SR1/eclipse-java-indigo-SR1-macosx-cocoa-x86_64.tar.gz Create a new Java project. Then change the background color in Eclipse (This is NOT an OSX setting). Eclipse_Preferences -> General -> Editors -> Text Editors -> Appearance Color Options -> Background Color -> Select Black Move the I-beam cursor to the editor area. Compare the color of the cursor to the cursor in Terminal.app (Terminal.app that has been set to a 100% black background) Created attachment 208902 [details]
test snippet
Hi Carolyn,
I have attached a snippet that shows the bug. Without the patch applied, when I set the background color to black the IBeam cursor is not visible in the text box, combo, spinner. With the patch, a shadowed IBeam is shown and is visible against the black background.
(In reply to comment #20) > Lakshmi, are you running on Lion? Do you have access to another Lion machine? > There may be something special about SSQ's Lion. > We should first figure out what that is, so that we can put the patch code in > as a special case only, for Macs that have this problem. > > How are you setting the background to black? I used System Settings, Universal > Access, Seeing, White on Black. Hi Carolyn, thanks for the review! I'm running Lion and able to reproduce the bug on it using the above snippets. The only difference from what you mentioned above is that I'm setting the black background color on the controls using SWT and not using the System Preferences. OK, the patch is good, then. I guess it's for changing only one or two parts of Eclipse at a time. For accessibility, however, users would probably prefer to use the OS: System Preferences, Universal Access, Seeing, White on Black. "Universal Access, Seeing, White on Black." is not a good approach. It makes the icons on the bar looking terribly. The attached patch is a wonderful work around. For Christ's sake, when will this patch be applied? There's no need to be nasty - such words are unnecessary and unappreciated. The go-ahead to put this in was only given on Friday and it is now just Monday. The reason we took some time to ok the patch is that this is really an Apple bug, and as such, we were reluctant to work around it. We were making sure that we felt it was important enough to work around, and we decided that it was, so we will go ahead. If Apple radar 10265347 is ever fixed, we should back out this patch. Thanks Carolyn & Silenio! Fixed in 3.8 stream > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=2a6c4451d9a0891362f45912ce416ce64990a08b |