* Re: mouse cursor on MS-Windows. (revisited)
@ 2002-12-04 12:06 David PONCE
0 siblings, 0 replies; 5+ messages in thread
From: David PONCE @ 2002-12-04 12:06 UTC (permalink / raw)
Cc: emacs-devel
Hi Richard,
> The patch is big enough to need legal papers. How many lines did you
> write, and how many are left from kobayays@otsukakj.co.jp?
KOBAYASHI gave the original implementation idea (thanks!). I had to
change most of his code to improve it (I hope it is ;-)
Probably the main part of his original patch I left untouched
correspond to the following diff from w32term.c:
6587a6589
> Cursor cursor = 0;
6643c6645
< #if 0 /* TODO: mouse cursor */
---
>
6645c6647
< cursor = f->output_data.x->horizontal_drag_cursor;
---
> cursor = f->output_data.w32->horizontal_drag_cursor;
6647,6648c6649,6650
< cursor = f->output_data.x->text_cursor;
< #endif
---
> cursor = f->output_data.w32->text_cursor;
>
6676c6678
< /* TODO: mouse cursor */
---
> cursor = f->output_data.w32->nontext_cursor;
6731,6732c6733,6734
< /* TODO: if (same_region)
< mouse cursor */
---
> if (same_region)
> cursor = 0;
6762,6763c6764,6765
< clear_mouse_face (dpyinfo);
< /* TODO: mouse cursor changes. */
---
> if (clear_mouse_face (dpyinfo))
> cursor = 0;
6801c6803
< /* TODO: mouse cursor changes. */
---
> cursor = 0;
6844c6846
< /* TODO: mouse cursor changes. */
---
> cursor = 0;
6876c6878
< /* TODO: mouse cursor changes. */
---
> cursor = 0;
6924c6926
< /* TODO: mouse cursor changes. */
---
> cursor = 0;
7004,7005c7006,7007
< /* TODO: mouse cursor changes. */
< ;
---
^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <3DD3EB7600A9C1CF@mel-rta9.wanadoo.fr>]
* mouse cursor on MS-Windows. (revisited)
@ 2002-12-05 3:39 KOBAYASHI Yasuhiro
0 siblings, 0 replies; 5+ messages in thread
From: KOBAYASHI Yasuhiro @ 2002-12-05 3:39 UTC (permalink / raw)
> The patch is big enough to need legal papers. How many lines did you
> write, and how many are left from kobayays@otsukakj.co.jp
If you need the papers I could send them.
--
KOBAYASHI Yasuhiro <kobayays@otsukakj.co.jp>
^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <3DEB71B90009B5B2@mel-rta6.wanadoo.fr>]
* Re: mouse cursor on MS-Windows. (revisited)
@ 2002-12-03 13:43 David PONCE
0 siblings, 0 replies; 5+ messages in thread
From: David PONCE @ 2002-12-03 13:43 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 2238 bytes --]
Hi All,
I submit you the attached patch to NT Emacs (HEAD) to display
different cursors, depending on mouse position.
This is a revisited patch from the original version posted by
"KOBAYASHI Yasuhiro" <kobayays@otsukakj.co.jp>. See message:
<http://mail.gnu.org/pipermail/emacs-devel/2002-September/012390.html>
The main differences are:
- Cursors are loaded only at frame creation in Fx_create_frame instead
of each time the cursor change. The Cursor type is actually a
cursor handle instead of a resource identifier. I think it is more
consistent.
- Cursors are loaded via the new function `w32_load_cursor' that try
first to load from application resources (defined in emacs.rc), then
from global shared predefined one. Thus it is possible to use
cursors specifically built for Emacs ;-) More important that allows
to provide a "hand" cursor for Windows 95 and NT for which a
predefined one does not exists. I added a sample hand.cur file in
the nt/icons directory (maybe using a nt/cursor directory would be
better?). Notice that I got this hand.cur from winhelp.exe.
Probably, for license reason, a specific version will be needed?
The patch includes some minor fixes too. You will find a change log
at end.
Hope it helps.
Sincerely,
David
------- Change log
* src/w32term.c (w32_encode_char): For DIM=1 charset, set
ccl->reg[2] to -1 before calling ccl_driver. (Sync. with xterm.c
x_encode_char change by Kenichi Handa <handa@m17n.org> on
2002-09-30.
(w32_draw_relief_rect): Declare all args.
(w32_define_cursor): New.
(note_mode_line_highlight)
(note_mouse_highlight)
(show_mouse_face)
(w32_initialize_display_info): Handle mouse cursor change.
* src/w32term.h (w32_output): Added `hand_cursor' member.
(WM_EMACS_SETCURSOR): New message.
* src/w32fns.c (Vx_hand_shape): New.
(w32_load_cursor): New.
(w32_init_class): Use it.
(w32_wnd_proc): Handle mouse cursor change message.
(Fx_create_frame): Initialize frame cursors.
(x_put_x_image): Declare all args.
* src/w32menu.c (digest_single_submenu): Declare all args.
* nt/emacs.rc (32649): Declare hand cursor resource.
* nt/icons/hand.cur: Hand cursor.
[-- Attachment #2: hand.cur --]
[-- Type: image/x-icon, Size: 376 bytes --]
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: w32cursor.patch --]
[-- Type: text/x-patch; name="w32cursor.patch", Size: 14769 bytes --]
*** src/w32term.c.orig Sat Nov 16 14:11:32 2002
--- src/w32term.c Sat Nov 16 15:26:23 2002
***************
*** 189,194 ****
--- 189,195 ----
extern void free_frame_menubar ();
extern int w32_codepage_for_font (char *fontname);
+ extern Cursor w32_load_cursor (LPCTSTR name);
extern glyph_metric *w32_BDF_TextMetric(bdffont *fontp,
unsigned char *text, int dim);
***************
*** 367,372 ****
--- 368,374 ----
enum draw_glyphs_face));
static int cursor_in_mouse_face_p P_ ((struct window *));
static int clear_mouse_face P_ ((struct w32_display_info *));
+ void w32_define_cursor P_ ((Window, Cursor));
void x_lower_frame P_ ((struct frame *));
void x_scroll_bar_clear P_ ((struct frame *));
***************
*** 1426,1431 ****
--- 1428,1434 ----
{
ccl->reg[0] = charset;
ccl->reg[1] = BYTE2 (*char2b);
+ ccl->reg[2] = -1;
}
else
{
***************
*** 3724,3730 ****
w32_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
raised_p, left_p, right_p, clip_rect)
struct frame *f;
! int left_x, top_y, right_x, bottom_y, left_p, right_p, raised_p;
RECT *clip_rect;
{
int i;
--- 3727,3733 ----
w32_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
raised_p, left_p, right_p, clip_rect)
struct frame *f;
! int left_x, top_y, right_x, bottom_y, width, left_p, right_p, raised_p;
RECT *clip_rect;
{
int i;
***************
*** 6565,6573 ****
}
}
}
! #if 0 /* TODO: mouse cursor */
! XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), cursor);
! #endif
}
--- 6568,6574 ----
}
}
}
! w32_define_cursor (FRAME_W32_WINDOW (f), cursor);
}
***************
*** 6585,6590 ****
--- 6586,6592 ----
int portion;
Lisp_Object window;
struct window *w;
+ Cursor cursor = 0;
struct buffer *b;
/* When a menu is active, don't highlight because this looks odd. */
***************
*** 6640,6651 ****
note_mode_line_highlight (w, x, portion == 1);
return;
}
! #if 0 /* TODO: mouse cursor */
if (portion == 2)
! cursor = f->output_data.x->horizontal_drag_cursor;
else
! cursor = f->output_data.x->text_cursor;
! #endif
/* Are we in a window whose display is up to date?
And verify the buffer's text has not changed. */
b = XBUFFER (w->buffer);
--- 6642,6653 ----
note_mode_line_highlight (w, x, portion == 1);
return;
}
!
if (portion == 2)
! cursor = f->output_data.w32->horizontal_drag_cursor;
else
! cursor = f->output_data.w32->text_cursor;
!
/* Are we in a window whose display is up to date?
And verify the buffer's text has not changed. */
b = XBUFFER (w->buffer);
***************
*** 6673,6679 ****
|| !MATRIX_ROW (w->current_matrix, vpos)->displays_text_p)
{
clear_mouse_face (dpyinfo);
! /* TODO: mouse cursor */
goto set_cursor;
}
--- 6675,6681 ----
|| !MATRIX_ROW (w->current_matrix, vpos)->displays_text_p)
{
clear_mouse_face (dpyinfo);
! cursor = f->output_data.w32->nontext_cursor;
goto set_cursor;
}
***************
*** 6728,6735 ****
|| hpos < dpyinfo->mouse_face_end_col
|| dpyinfo->mouse_face_past_end));
! /* TODO: if (same_region)
! mouse cursor */
/* Check mouse-face highlighting. */
if (! same_region
--- 6730,6737 ----
|| hpos < dpyinfo->mouse_face_end_col
|| dpyinfo->mouse_face_past_end));
! if (same_region)
! cursor = 0;
/* Check mouse-face highlighting. */
if (! same_region
***************
*** 6759,6766 ****
dpyinfo->mouse_face_overlay = overlay;
/* Clear the display of the old active region, if any. */
! clear_mouse_face (dpyinfo);
! /* TODO: mouse cursor changes. */
/* If no overlay applies, get a text property. */
if (NILP (overlay))
--- 6761,6768 ----
dpyinfo->mouse_face_overlay = overlay;
/* Clear the display of the old active region, if any. */
! if (clear_mouse_face (dpyinfo))
! cursor = 0;
/* If no overlay applies, get a text property. */
if (NILP (overlay))
***************
*** 6798,6804 ****
/* Display it as active. */
show_mouse_face (dpyinfo, DRAW_MOUSE_FACE);
! /* TODO: mouse cursor changes. */
}
/* Handle the text property case. */
else if (! NILP (mouse_face) && BUFFERP (object))
--- 6800,6806 ----
/* Display it as active. */
show_mouse_face (dpyinfo, DRAW_MOUSE_FACE);
! cursor = 0;
}
/* Handle the text property case. */
else if (! NILP (mouse_face) && BUFFERP (object))
***************
*** 6841,6847 ****
/* Display it as active. */
show_mouse_face (dpyinfo, DRAW_MOUSE_FACE);
! /* TODO: mouse cursor changes. */
}
else if (!NILP (mouse_face) && STRINGP (object))
{
--- 6843,6849 ----
/* Display it as active. */
show_mouse_face (dpyinfo, DRAW_MOUSE_FACE);
! cursor = 0;
}
else if (!NILP (mouse_face) && STRINGP (object))
{
***************
*** 6873,6879 ****
= face_at_string_position (w, object, pos, 0, 0, 0, &ignore,
glyph->face_id, 1);
show_mouse_face (dpyinfo, DRAW_MOUSE_FACE);
! /* TODO: mouse cursor changes. */
}
else if (STRINGP (object) && NILP (mouse_face))
{
--- 6875,6881 ----
= face_at_string_position (w, object, pos, 0, 0, 0, &ignore,
glyph->face_id, 1);
show_mouse_face (dpyinfo, DRAW_MOUSE_FACE);
! cursor = 0;
}
else if (STRINGP (object) && NILP (mouse_face))
{
***************
*** 6921,6927 ****
/* Display it as active. */
show_mouse_face (dpyinfo, DRAW_MOUSE_FACE);
! /* TODO: mouse cursor changes. */
}
}
}
--- 6923,6929 ----
/* Display it as active. */
show_mouse_face (dpyinfo, DRAW_MOUSE_FACE);
! cursor = 0;
}
}
}
***************
*** 7001,7008 ****
}
set_cursor:
! /* TODO: mouse cursor changes. */
! ;
}
static void
--- 7003,7010 ----
}
set_cursor:
! if (cursor)
! w32_define_cursor (FRAME_W32_WINDOW (f), cursor);
}
static void
***************
*** 7015,7020 ****
--- 7017,7029 ----
HIWORD (last_mouse_motion_event.lParam));
}
+ void
+ w32_define_cursor (window, cursor)
+ Window window;
+ Cursor cursor;
+ {
+ PostMessage (window, WM_EMACS_SETCURSOR, (WPARAM) cursor, 0);
+ }
\f
/***********************************************************************
***************
*** 7555,7572 ****
w->phys_cursor.x, w->phys_cursor.y);
}
- #if 0 /* TODO: mouse cursor */
/* Change the mouse cursor. */
if (draw == DRAW_NORMAL_TEXT)
! XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
! f->output_data.x->text_cursor);
else if (draw == DRAW_MOUSE_FACE)
! XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
! f->output_data.x->cross_cursor);
else
! XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
! f->output_data.x->nontext_cursor);
! #endif
}
/* Clear out the mouse-highlighted active region.
--- 7564,7580 ----
w->phys_cursor.x, w->phys_cursor.y);
}
/* Change the mouse cursor. */
if (draw == DRAW_NORMAL_TEXT)
! w32_define_cursor (FRAME_W32_WINDOW (f),
! f->output_data.w32->text_cursor);
else if (draw == DRAW_MOUSE_FACE)
! w32_define_cursor (FRAME_W32_WINDOW (f),
! f->output_data.w32->hand_cursor);
else
! w32_define_cursor (FRAME_W32_WINDOW (f),
! f->output_data.w32->nontext_cursor);
!
}
/* Clear out the mouse-highlighted active region.
***************
*** 11044,11049 ****
--- 11052,11059 ----
dpyinfo->mouse_face_window = Qnil;
dpyinfo->mouse_face_overlay = Qnil;
dpyinfo->mouse_face_hidden = 0;
+
+ dpyinfo->vertical_scroll_bar_cursor = w32_load_cursor (IDC_ARROW);
/* TODO: dpyinfo->gray */
}
*** src/w32term.h.orig Fri Aug 30 15:20:36 2002
--- src/w32term.h Tue Dec 3 13:38:19 2002
***************
*** 350,355 ****
--- 350,356 ----
Cursor cross_cursor;
Cursor hourglass_cursor;
Cursor horizontal_drag_cursor;
+ Cursor hand_cursor;
/* Window whose cursor is hourglass_cursor. This window is
temporarily mapped to display an hourglass cursor. */
***************
*** 735,741 ****
#define WM_EMACS_DESTROY_CARET (WM_EMACS_START + 16)
#define WM_EMACS_SHOW_CARET (WM_EMACS_START + 17)
#define WM_EMACS_HIDE_CARET (WM_EMACS_START + 18)
! #define WM_EMACS_END (WM_EMACS_START + 19)
#define WND_FONTWIDTH_INDEX (0)
#define WND_LINEHEIGHT_INDEX (4)
--- 736,743 ----
#define WM_EMACS_DESTROY_CARET (WM_EMACS_START + 16)
#define WM_EMACS_SHOW_CARET (WM_EMACS_START + 17)
#define WM_EMACS_HIDE_CARET (WM_EMACS_START + 18)
! #define WM_EMACS_SETCURSOR (WM_EMACS_START + 19)
! #define WM_EMACS_END (WM_EMACS_START + 20)
#define WND_FONTWIDTH_INDEX (0)
#define WND_LINEHEIGHT_INDEX (4)
*** src/w32fns.c.orig Thu Nov 21 09:01:42 2002
--- src/w32fns.c Thu Nov 21 09:47:41 2002
***************
*** 152,158 ****
over text or in the modeline. */
Lisp_Object Vx_pointer_shape, Vx_nontext_pointer_shape, Vx_mode_pointer_shape;
! Lisp_Object Vx_hourglass_pointer_shape, Vx_window_horizontal_drag_shape;
/* The shape when over mouse-sensitive text. */
--- 152,158 ----
over text or in the modeline. */
Lisp_Object Vx_pointer_shape, Vx_nontext_pointer_shape, Vx_mode_pointer_shape;
! Lisp_Object Vx_hourglass_pointer_shape, Vx_window_horizontal_drag_shape, Vx_hand_shape;
/* The shape when over mouse-sensitive text. */
***************
*** 2193,2198 ****
--- 2193,2199 ----
else
horizontal_drag_cursor
= XCreateFontCursor (FRAME_X_DISPLAY (f), XC_sb_h_double_arrow);
+ /* TODO: hand_cursor */
/* Check and report errors with the above calls. */
x_check_errors (FRAME_W32_DISPLAY (f), "can't set cursor shape: %s");
***************
*** 2221,2226 ****
--- 2222,2228 ----
&fore_color, &back_color);
XRecolorCursor (FRAME_W32_DISPLAY (f), hourglass_cursor,
&fore_color, &back_color);
+ /* TODO: hand_cursor */
}
if (FRAME_W32_WINDOW (f) != 0)
***************
*** 2249,2254 ****
--- 2251,2257 ----
&& f->output_data.w32->cross_cursor != 0)
XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->cross_cursor);
f->output_data.w32->cross_cursor = cross_cursor;
+ /* TODO: hand_cursor */
XFlush (FRAME_W32_DISPLAY (f));
UNBLOCK_INPUT;
***************
*** 3417,3422 ****
--- 3420,3440 ----
}
\f
+ Cursor
+ w32_load_cursor (LPCTSTR name)
+ {
+ /* Try first to load cursor from application resource. */
+ Cursor cursor = LoadImage ((HINSTANCE) GetModuleHandle(NULL),
+ name, IMAGE_CURSOR, 0, 0,
+ LR_DEFAULTCOLOR | LR_DEFAULTSIZE | LR_SHARED);
+ if (!cursor)
+ {
+ /* Then try to load a shared predefined cursor. */
+ cursor = LoadImage (NULL, name, IMAGE_CURSOR, 0, 0,
+ LR_DEFAULTCOLOR | LR_DEFAULTSIZE | LR_SHARED);
+ }
+ return cursor;
+ }
extern LRESULT CALLBACK w32_wnd_proc ();
***************
*** 3432,3438 ****
wc.cbWndExtra = WND_EXTRA_BYTES;
wc.hInstance = hinst;
wc.hIcon = LoadIcon (hinst, EMACS_CLASS);
! wc.hCursor = LoadCursor (NULL, IDC_ARROW);
wc.hbrBackground = NULL; /* GetStockObject (WHITE_BRUSH); */
wc.lpszMenuName = NULL;
wc.lpszClassName = EMACS_CLASS;
--- 3450,3456 ----
wc.cbWndExtra = WND_EXTRA_BYTES;
wc.hInstance = hinst;
wc.hIcon = LoadIcon (hinst, EMACS_CLASS);
! wc.hCursor = w32_load_cursor (IDC_ARROW);
wc.hbrBackground = NULL; /* GetStockObject (WHITE_BRUSH); */
wc.lpszMenuName = NULL;
wc.lpszClassName = EMACS_CLASS;
***************
*** 5084,5089 ****
--- 5102,5121 ----
((LPMINMAXINFO) lParam)->ptMaxTrackSize.y = 32767;
return 0;
+ case WM_SETCURSOR:
+ if (LOWORD (lParam) == HTCLIENT)
+ return 0;
+
+ goto dflt;
+
+ case WM_EMACS_SETCURSOR:
+ {
+ Cursor cursor = (Cursor) wParam;
+ if (cursor)
+ SetCursor (cursor);
+ return 0;
+ }
+
case WM_EMACS_CREATESCROLLBAR:
return (LRESULT) w32_createscrollbar ((struct frame *) wParam,
(struct scroll_bar *) lParam);
***************
*** 5674,5679 ****
--- 5706,5719 ----
f->output_data.w32->dwStyle = WS_OVERLAPPEDWINDOW;
f->output_data.w32->parent_desc = FRAME_W32_DISPLAY_INFO (f)->root_window;
+ f->output_data.w32->text_cursor = w32_load_cursor (IDC_IBEAM);
+ f->output_data.w32->nontext_cursor = w32_load_cursor (IDC_ARROW);
+ f->output_data.w32->modeline_cursor = w32_load_cursor (IDC_ARROW);
+ f->output_data.w32->cross_cursor = w32_load_cursor (IDC_CROSS);
+ f->output_data.w32->hourglass_cursor = w32_load_cursor (IDC_WAIT);
+ f->output_data.w32->horizontal_drag_cursor = w32_load_cursor (IDC_SIZEWE);
+ f->output_data.w32->hand_cursor = w32_load_cursor (IDC_HAND);
+
/* Add the tool-bar height to the initial frame height so that the
user gets a text display area of the size he specified with -g or
via .Xdefaults. Later changes of the tool-bar height don't
***************
*** 9441,9446 ****
--- 9481,9487 ----
struct frame *f;
XImage *ximg;
Pixmap pixmap;
+ int width, height;
{
#if 0 /* I don't think this is necessary looking at where it is used. */
HDC hdc = get_frame_dc (f);
*** src/w32menu.c.orig Mon Nov 18 09:23:57 2002
--- src/w32menu.c Mon Nov 18 09:55:53 2002
***************
*** 1175,1181 ****
static widget_value *
digest_single_submenu (start, end, top_level_items)
! int start, end;
{
widget_value *wv, *prev_wv, *save_wv, *first_wv;
int i;
--- 1175,1181 ----
static widget_value *
digest_single_submenu (start, end, top_level_items)
! int start, end, top_level_items;
{
widget_value *wv, *prev_wv, *save_wv, *first_wv;
int i;
*** nt/emacs.rc.orig Tue Sep 3 09:50:51 2002
--- nt/emacs.rc Thu Sep 12 16:50:28 2002
***************
*** 1,4 ****
! Emacs ICON icons\gnu2a32t.ico
#ifndef VS_VERSION_INFO
#define VS_VERSION_INFO 1
--- 1,5 ----
! Emacs ICON icons\gnu2a32t.ico
! 32649 CURSOR icons\hand.cur
#ifndef VS_VERSION_INFO
#define VS_VERSION_INFO 1
-----------------------------41184676334--
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-12-06 13:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-04 12:06 mouse cursor on MS-Windows. (revisited) David PONCE
[not found] <3DD3EB7600A9C1CF@mel-rta9.wanadoo.fr>
2002-12-06 13:30 ` Richard Stallman
-- strict thread matches above, loose matches on Subject: below --
2002-12-05 3:39 KOBAYASHI Yasuhiro
[not found] <3DEB71B90009B5B2@mel-rta6.wanadoo.fr>
2002-12-04 11:07 ` Richard Stallman
2002-12-03 13:43 David PONCE
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.