unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* visible-bell patch for Mac OS X
@ 2010-01-30 13:34 Filipe Cabecinhas
  2010-01-31  3:34 ` Chong Yidong
  0 siblings, 1 reply; 25+ messages in thread
From: Filipe Cabecinhas @ 2010-01-30 13:34 UTC (permalink / raw)
  To: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 692 bytes --]

Hi,

I've made a patch to remove that ugly black rectangle from ns_ring_bell,
when visible-bell is 't.
The patch makes Emacs behave like the X version, inverting the colors of the
top and bottom lines, and bounces the Dock icon once if Emacs is not the
frontmost app (which can be extended to when visible-bell is 'nil, if
desired (just hoist it outside the if).

There is one difference in behaviour to the X version. When we have
horizontally-split frames, the scrollbars between frames also get inverted.
If we want to invert all the scrollbars, we just need to change the CGRect
calculations to not take the scrollbar into account.

Patch made against revision 99416.

Regards,

  Filipe

[-- Attachment #1.2: Type: text/html, Size: 858 bytes --]

[-- Attachment #2: cocoa-visible-bell.patch --]
[-- Type: application/octet-stream, Size: 5680 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: filcab@gmail.com-20100130133139-qc9k267jlc69f99n
# target_branch: http://bzr.savannah.gnu.org/r/emacs/trunk
# testament_sha1: 27c8026494ef46e68ad79f8263f479ed22874804
# timestamp: 2010-01-30 13:33:01 +0000
# base_revision_id: cyd@stupidchicken.com-20100129191426-\
#   0m0lt5sbqqqhuufz
# 
# Begin patch
=== modified file 'src/nsterm.m'
--- src/nsterm.m	2010-01-15 01:46:53 +0000
+++ src/nsterm.m	2010-01-30 13:31:39 +0000
@@ -808,23 +808,58 @@
       view = FRAME_NS_VIEW (frame);
       if (view != nil)
         {
-          NSRect r, surr;
-          NSPoint dim = NSMakePoint (128, 128);
-
-          r = [view bounds];
-          r.origin.x += (r.size.width - dim.x) / 2;
-          r.origin.y += (r.size.height - dim.y) / 2;
-          r.size.width = dim.x;
-          r.size.height = dim.y;
-          surr = NSInsetRect (r, -2, -2);
-          ns_focus (frame, &surr, 1);
-          [[view window] cacheImageInRect: [view convertRect: surr toView:nil]];
-          [ns_lookup_indexed_color (NS_FACE_FOREGROUND
-                                      (FRAME_DEFAULT_FACE (frame)), frame) set];
-          NSRectFill (r);
+          /* Get the bounds of our NSView */
+          NSRect viewBounds = [view bounds];
+
+          /* Height of each line to flash.  */
+          int flash_height = FRAME_LINE_HEIGHT (frame);
+          int width = FRAME_PIXEL_WIDTH (frame)
+                    - NS_SCROLL_BAR_WIDTH (frame);
+
+          /* Get the GraphicsContext */
+          CGContextRef ctxt = [[NSGraphicsContext currentContext] graphicsPort];
+          CGRect lowerLine, upperLine;
+          lowerLine =
+          CGRectMake(viewBounds.origin.x, viewBounds.origin.y,
+                     width + NS_SCROLL_BAR_WIDTH(frame),
+                     flash_height + FRAME_INTERNAL_BORDER_WIDTH (frame));
+          upperLine =
+          CGRectMake(viewBounds.origin.x,
+                     viewBounds.origin.y + viewBounds.size.height
+                     - (flash_height + FRAME_INTERNAL_BORDER_WIDTH (frame)),
+                     width,
+                     flash_height + FRAME_INTERNAL_BORDER_WIDTH (frame));
+
+          /* Invert the colors using a difference blend.  */
+          CGContextSetBlendMode(ctxt, kCGBlendModeDifference);
+          CGContextSetGrayFillColor(ctxt, 1, 1);
+
+          /* If window is tall, flash top and bottom line.  */
+          if (viewBounds.size.height > 3 * FRAME_LINE_HEIGHT (frame))
+            {
+              CGContextFillRect(ctxt, upperLine);
+              CGContextFillRect(ctxt, lowerLine);
+            }
+          else
+            /* If it is short, flash it all.  */
+            CGContextFillRect(ctxt, NSRectToCGRect([view bounds]));
+
+          /* Bounce Dock icon. Maybe we can allow some configuration here.  */
+          [NSApp requestUserAttention: NSInformationalRequest];
+
           [[view window] flushWindow];
           ns_timeout (150000);
-          [[view window] restoreCachedImage];
+
+          /* If window is tall, flash top and bottom line.  */
+          if (viewBounds.size.height > 3 * FRAME_LINE_HEIGHT (frame))
+            {
+              CGContextFillRect(ctxt, upperLine);
+              CGContextFillRect(ctxt, lowerLine);
+            }
+          else
+            /* If it is short, flash it all.  */
+            CGContextFillRect(ctxt, NSRectToCGRect([view bounds]));
+
           [[view window] flushWindow];
           ns_unfocus (frame);
         }

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWfDfJK8AAp9/gAFQYABQf///
f+ffyr////pQBh52i3A53eu6rb07iEumgkkTVPNU9IzSn6aUbap+p6ptqh6m0n6po9Ro0aeptQPU
00epoDIpqemEGjSPSpmk9IMhkNqBkZAAAMQJEgU0yJjQjJNqn6Em1PRNqGIAyNHqGh6jTQMqhtQa
ZADTIAABoBoAAANACSQmRU/TI0BNMT00oyaG1PU0bUBoaDQGgaTJJcKLGMOokdefrJssxpYMxQWj
jtGT17hxkHh2juzhRYaoXYwqQcUcD7HXQhrkhADhCJJa+beMHb2mc0Xe9ihd/w6/00sbOj9i08OU
ns4dJSVaRC28d3GT4mexok3Nyp5cMPYVfNjJfDNTE/E6f+zB2DVplZX3RLMHlp4eHH+LZp4SsYHK
YGEf2QU6nurtnqZM1ZYJFlfa8yqtI2XWni8Dt5+Tjw19e9Q0XGlmDDxpdjUhnlIzNbxqSeEQNh56
jAYltn8OiLXo4DRdX06r13U1AnHn7Ywyz4r0FFt0yhQTZpnA9KC4VMlIHKg6A3jLghVO70ac8UmZ
hG5Cvg5hZBRzZCKxzJpnyF5VQlu1nc0nxnrZIPCFUGHHYCNu4JW1xvMxEh/E58GAZOxqBcUBmC8+
saazWG1jkjtsZLLPy6hxsNJ3l5x8WdeiyApmQaGjK9KGyYLKhUVkoE8+Cm668UcCpuBUgQ6WVA34
bzgFGrLXWcggncVzQhWF8WGIjN7DrCdgQWFesCTHXQSEus8J2mLTi8ygGX4bGsBycDTF5kkhEuS3
RALhs1vghsEm6i4GiVUo0KFGjNb6kV4E76YaTGrrRQLXF+OZSDIq7Zy0CvKVwNAsukWAtnTfyZlk
vvyQG2bdTVBaE7OZkCuR93nTabxZGT2jCrknw957HF6JS3MlANq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ToVYbb6phrvQyrm4lrxDvVfSfbBA+cDB
MCDNIIo2z5/Ip7F0mTFsBoUc7ZnNQPeto26+4P/F3JFOFCQ8N8krwA==

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2010-02-13 14:26 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-30 13:34 visible-bell patch for Mac OS X Filipe Cabecinhas
2010-01-31  3:34 ` Chong Yidong
2010-02-01  0:41   ` YAMAMOTO Mitsuharu
2010-02-01 15:56     ` Chong Yidong
2010-02-01 23:33       ` YAMAMOTO Mitsuharu
2010-02-02  1:40         ` YAMAMOTO Mitsuharu
2010-02-02  1:45           ` YAMAMOTO Mitsuharu
2010-02-02  8:47           ` Leo
2010-02-13  1:30         ` YAMAMOTO Mitsuharu
2010-02-13  1:51           ` David De La Harpe Golden
2010-02-13  3:54             ` Native scrollbars? [was: visible-bell patch for Mac OS X] Stephen J. Turnbull
2010-02-13  5:45               ` David De La Harpe Golden
2010-02-13  6:45                 ` David De La Harpe Golden
2010-02-13  7:32                   ` YAMAMOTO Mitsuharu
2010-02-13 13:32                   ` Jan Djärv
2010-02-13  9:00               ` Native scrollbars? David Kastrup
2010-02-13 10:02                 ` Eli Zaretskii
2010-02-13 12:23                 ` Jan Djärv
2010-02-13 12:46                   ` David Kastrup
2010-02-13 13:40                     ` Jan Djärv
2010-02-13 14:26                       ` David Kastrup
2010-02-13 13:50                     ` Stephen J. Turnbull
2010-02-13  6:45             ` visible-bell patch for Mac OS X YAMAMOTO Mitsuharu
2010-02-13  7:01               ` David De La Harpe Golden
2010-02-13  7:54               ` Jan Djärv

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).