* Patch to make Emacs.app for OSX visible bell like Carbon Emacs
@ 2009-03-23 16:49 Philip Kime
2009-03-24 1:06 ` YAMAMOTO Mitsuharu
0 siblings, 1 reply; 5+ messages in thread
From: Philip Kime @ 2009-03-23 16:49 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 172 bytes --]
Patch attached to nsterm.m (1.67) to make the visible bell behaviour
nicer and like Carbon emacs. I also neatened it to stop the flashing
across the fringe/scrollbar.
[-- Attachment #2: nsterm.diff --]
[-- Type: application/octet-stream, Size: 3134 bytes --]
Index: src/nsterm.m
===================================================================
RCS file: /sources/emacs/emacs/src/nsterm.m,v
retrieving revision 1.67
diff -u -p -r1.67 nsterm.m
--- src/nsterm.m 14 Mar 2009 21:20:09 -0000 1.67
+++ src/nsterm.m 20 Mar 2009 15:26:16 -0000
@@ -809,12 +809,88 @@ ns_clip_to_row (struct window *w, struct
static void
ns_ring_bell ()
/* --------------------------------------------------------------------------
- "Beep" routine
+ "Beep" routine
-------------------------------------------------------------------------- */
{
NSTRACE (ns_ring_bell);
if (visible_bell)
- {
+ {
+#ifdef NS_IMPL_COCOA
+ NSAutoreleasePool *pool;
+ struct frame *frame = SELECTED_FRAME ();
+ NSView *view;
+ /* Get the height not including a menu bar widget. */
+ int height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (frame, FRAME_LINES (frame));
+ /* Height of each line to flash. */
+ int flash_height = FRAME_LINE_HEIGHT (frame);
+ /* Left and right margins of the rectangles. */
+ int flash_left = FRAME_INTERNAL_BORDER_WIDTH (frame);
+ int flash_right = FRAME_PIXEL_WIDTH (frame) - FRAME_INTERNAL_BORDER_WIDTH (frame);
+
+ int width;
+
+ /* Don't flash over the scroll bar, it's ugly */
+ switch (FRAME_VERTICAL_SCROLL_BAR_TYPE (frame))
+ {
+ case vertical_scroll_bar_left:
+ flash_left += NS_SCROLL_BAR_WIDTH (frame);
+ break;
+
+ case vertical_scroll_bar_right:
+ flash_right -= NS_SCROLL_BAR_WIDTH (frame);
+ break;
+
+ default:
+ break;
+ }
+
+ /* Don't flash over the fringe, it's ugly */
+ if (FRAME_TOTAL_FRINGE_WIDTH (frame))
+ {
+ flash_left += FRAME_LEFT_FRINGE_WIDTH (frame);
+ flash_right -= FRAME_RIGHT_FRINGE_WIDTH (frame);
+ }
+
+ width = flash_right - flash_left;
+
+ BLOCK_INPUT;
+ pool = [[NSAutoreleasePool alloc] init];
+
+ view = FRAME_NS_VIEW (frame);
+ if (view != nil)
+ {
+ CGRect r[2];
+
+ r[0].origin.x = flash_left;
+ r[0].origin.y = (FRAME_INTERNAL_BORDER_WIDTH (frame)
+ + FRAME_TOOL_BAR_LINES (frame) * FRAME_LINE_HEIGHT (frame));
+ r[0].size.width = width;
+ r[0].size.height = flash_height;
+
+ r[1].origin.x = flash_left;
+ r[1].origin.y = (height - flash_height);
+ r[1].size.width = width;
+ r[1].size.height = flash_height;
+
+ CGContextRef ctxt = [[NSGraphicsContext currentContext] graphicsPort];
+ CGContextSetBlendMode(ctxt, kCGBlendModeDifference);
+
+ CGContextSetGrayFillColor(ctxt, 1, 1);
+ CGContextFillRects(ctxt, r, 2);
+
+ [[view window] flushWindow];
+ ns_timeout (150000);
+
+ CGContextSetGrayFillColor(ctxt, 1, 1);
+ CGContextFillRects(ctxt, r, 2);
+
+ [[view window] flushWindow];
+
+ ns_unfocus (frame);
+ }
+ [pool release];
+ UNBLOCK_INPUT;
+#else
NSAutoreleasePool *pool;
struct frame *frame = SELECTED_FRAME ();
NSView *view;
@@ -847,6 +923,7 @@ ns_ring_bell ()
}
[pool release];
UNBLOCK_INPUT;
+#endif
}
else
{
[-- Attachment #3: Type: text/plain, Size: 29 bytes --]
PK
--
Dr Philip Kime
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Patch to make Emacs.app for OSX visible bell like Carbon Emacs
2009-03-23 16:49 Patch to make Emacs.app for OSX visible bell like Carbon Emacs Philip Kime
@ 2009-03-24 1:06 ` YAMAMOTO Mitsuharu
2009-03-24 1:38 ` YAMAMOTO Mitsuharu
0 siblings, 1 reply; 5+ messages in thread
From: YAMAMOTO Mitsuharu @ 2009-03-24 1:06 UTC (permalink / raw)
To: Philip Kime; +Cc: emacs-devel
>>>>> On Mon, 23 Mar 2009 17:49:57 +0100, Philip Kime <Philip@kime.org.uk> said:
> Patch attached to nsterm.m (1.67) to make the visible bell behaviour
> nicer and like Carbon emacs. I also neatened it to stop the flashing
> across the fringe/scrollbar.
It flashes fringes/scrollbars that separate vertically-split windows
(C-x 3). Also, CGContextSetBlendMode is available only in Mac OS X
10.4 and later.
YAMAMOTO Mitsuharu
mituharu@math.s.chiba-u.ac.jp
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Patch to make Emacs.app for OSX visible bell like Carbon Emacs
2009-03-24 1:06 ` YAMAMOTO Mitsuharu
@ 2009-03-24 1:38 ` YAMAMOTO Mitsuharu
2009-03-25 0:20 ` YAMAMOTO Mitsuharu
0 siblings, 1 reply; 5+ messages in thread
From: YAMAMOTO Mitsuharu @ 2009-03-24 1:38 UTC (permalink / raw)
To: Philip Kime; +Cc: emacs-devel
>>>>> On Tue, 24 Mar 2009 10:06:41 +0900, YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> said:
>> Patch attached to nsterm.m (1.67) to make the visible bell
>> behaviour nicer and like Carbon emacs. I also neatened it to stop
>> the flashing across the fringe/scrollbar.
> It flashes fringes/scrollbars that separate vertically-split windows
> (C-x 3).
And it looks so strange when there's a header line at the top (e.g.,
M-x info RET).
YAMAMOTO Mitsuharu
mituharu@math.s.chiba-u.ac.jp
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Patch to make Emacs.app for OSX visible bell like Carbon Emacs
2009-03-24 1:38 ` YAMAMOTO Mitsuharu
@ 2009-03-25 0:20 ` YAMAMOTO Mitsuharu
2009-03-25 16:01 ` Stefan Monnier
0 siblings, 1 reply; 5+ messages in thread
From: YAMAMOTO Mitsuharu @ 2009-03-25 0:20 UTC (permalink / raw)
To: Philip Kime; +Cc: emacs-devel
>>>>> On Tue, 24 Mar 2009 10:38:08 +0900, YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> said:
>>> Patch attached to nsterm.m (1.67) to make the visible bell
>>> behaviour nicer and like Carbon emacs. I also neatened it to stop
>>> the flashing across the fringe/scrollbar.
>> It flashes fringes/scrollbars that separate vertically-split
>> windows (C-x 3).
> And it looks so strange when there's a header line at the top (e.g.,
> M-x info RET).
Another strange-looking case is when there are marginal areas (e.g.,
M-: (set-window-margins nil 5 5) RET) with fringes-outside-margins
nil, which is the default.
YAMAMOTO Mitsuharu
mituharu@math.s.chiba-u.ac.jp
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Patch to make Emacs.app for OSX visible bell like Carbon Emacs
2009-03-25 0:20 ` YAMAMOTO Mitsuharu
@ 2009-03-25 16:01 ` Stefan Monnier
0 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2009-03-25 16:01 UTC (permalink / raw)
To: YAMAMOTO Mitsuharu; +Cc: Philip Kime, emacs-devel
>>>> Patch attached to nsterm.m (1.67) to make the visible bell
>>>> behaviour nicer and like Carbon emacs. I also neatened it to stop
>>>> the flashing across the fringe/scrollbar.
>>> It flashes fringes/scrollbars that separate vertically-split
>>> windows (C-x 3).
>> And it looks so strange when there's a header line at the top (e.g.,
>> M-x info RET).
> Another strange-looking case is when there are marginal areas (e.g.,
> M-: (set-window-margins nil 5 5) RET) with fringes-outside-margins
> nil, which is the default.
I wonder about one thing: why isn't the visible bell implemented in the
same way for all GUIs? Or even why it's in the GUI-specific part of the
code rather than in the generic part of it?
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-03-25 16:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-23 16:49 Patch to make Emacs.app for OSX visible bell like Carbon Emacs Philip Kime
2009-03-24 1:06 ` YAMAMOTO Mitsuharu
2009-03-24 1:38 ` YAMAMOTO Mitsuharu
2009-03-25 0:20 ` YAMAMOTO Mitsuharu
2009-03-25 16:01 ` Stefan Monnier
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).