emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/macterm.c


From: Steven Tamm
Subject: [Emacs-diffs] Changes to emacs/src/macterm.c
Date: Wed, 29 Dec 2004 13:05:20 -0500

Index: emacs/src/macterm.c
diff -c emacs/src/macterm.c:1.86 emacs/src/macterm.c:1.87
*** emacs/src/macterm.c:1.86    Mon Dec 27 17:27:30 2004
--- emacs/src/macterm.c Wed Dec 29 17:25:02 2004
***************
*** 511,533 ****
  }
  
  
- /* XBM bits seem to be backward within bytes compared with how
-    Mac does things.  */
- static unsigned char
- reflect_byte (orig)
-      unsigned char orig;
- {
-   int i;
-   unsigned char reflected = 0x00;
-   for (i = 0; i < 8; i++)
-     {
-       if (orig & (0x01 << i))
-       reflected |= 0x80 >> i;
-     }
-   return reflected;
- }
- 
- 
  /* Mac replacement for XCreateBitmapFromBitmapData.  */
  
  static void
--- 511,516 ----
***************
*** 536,541 ****
--- 519,529 ----
       char *bits;
       int w, h;
  {
+   static unsigned char swap_nibble[16]
+     = { 0x0, 0x8, 0x4, 0xc,    /* 0000 1000 0100 1100 */
+       0x2, 0xa, 0x6, 0xe,    /* 0010 1010 0110 1110 */
+       0x1, 0x9, 0x5, 0xd,    /* 0001 1001 0101 1101 */
+       0x3, 0xb, 0x7, 0xf };  /* 0011 1011 0111 1111 */
    int i, j, w1;
    char *p;
  
***************
*** 547,553 ****
      {
        p = bitmap->baseAddr + i * bitmap->rowBytes;
        for (j = 0; j < w1; j++)
!         *p++ = reflect_byte (*bits++);
      }
  
    SetRect (&(bitmap->bounds), 0, 0, w, h);
--- 535,546 ----
      {
        p = bitmap->baseAddr + i * bitmap->rowBytes;
        for (j = 0; j < w1; j++)
!       {
!         /* Bitswap XBM bytes to match how Mac does things.  */
!         unsigned char c = *bits++;
!         *p++ = (unsigned char)((swap_nibble[c & 0xf] << 4)
!                                | (swap_nibble[(c>>4) & 0xf]));;
!       }
      }
  
    SetRect (&(bitmap->bounds), 0, 0, w, h);
***************
*** 6256,6262 ****
    char *ptr;
    int scl_val[XLFD_SCL_LAST], *field, *val;
    char *longest_start, *cur_start, *nonspecial;
!   int longest_len, cur_len, exact;
  
    if (font_name_table == NULL)  /* Initialize when first used.  */
      init_font_name_table ();
--- 6249,6255 ----
    char *ptr;
    int scl_val[XLFD_SCL_LAST], *field, *val;
    char *longest_start, *cur_start, *nonspecial;
!   int longest_len, exact;
  
    if (font_name_table == NULL)  /* Initialize when first used.  */
      init_font_name_table ();
***************
*** 6318,6324 ****
    *ptr++ = '^';
  
    longest_start = cur_start = ptr;
!   longest_len = cur_len = 0;
    exact = 1;
  
    /* Turn pattern into a regexp and do a regexp match.  Also find the
--- 6311,6317 ----
    *ptr++ = '^';
  
    longest_start = cur_start = ptr;
!   longest_len = 0;
    exact = 1;
  
    /* Turn pattern into a regexp and do a regexp match.  Also find the
***************
*** 6327,6338 ****
      {
        if (*pattern == '?' || *pattern == '*')
        {
!         if (cur_len > longest_len)
            {
              longest_start = cur_start;
!             longest_len = cur_len;
            }
-         cur_len = 0;
          exact = 0;
  
          if (*pattern == '?')
--- 6320,6330 ----
      {
        if (*pattern == '?' || *pattern == '*')
        {
!         if (ptr - cur_start > longest_len)
            {
              longest_start = cur_start;
!             longest_len = ptr - cur_start;
            }
          exact = 0;
  
          if (*pattern == '?')
***************
*** 6342,6362 ****
              *ptr++ = '.';
              *ptr++ = '*';
            }
        }
        else
!       {
!         if (cur_len == 0)
!           cur_start = ptr;
!         cur_len++;
! 
!         *ptr++ = tolower (*pattern);
!       }
      }
  
!   if (cur_len > longest_len)
      {
        longest_start = cur_start;
!       longest_len = cur_len;
      }
  
    *ptr = '$';
--- 6334,6349 ----
              *ptr++ = '.';
              *ptr++ = '*';
            }
+         cur_start = ptr;
        }
        else
!       *ptr++ = tolower (*pattern);
      }
  
!   if (ptr - cur_start > longest_len)
      {
        longest_start = cur_start;
!       longest_len = ptr - cur_start;
      }
  
    *ptr = '$';
***************
*** 7086,7092 ****
  
  #if TARGET_API_MAC_CARBON
  /* Drag and Drop */
! static OSErr init_mac_drag_n_drop ();
  static pascal OSErr mac_do_receive_drag (WindowPtr, void*, DragReference);
  #endif
  
--- 7073,7079 ----
  
  #if TARGET_API_MAC_CARBON
  /* Drag and Drop */
! static pascal OSErr mac_do_track_drag (DragTrackingMessage, WindowPtr, void*, 
DragReference);
  static pascal OSErr mac_do_receive_drag (WindowPtr, void*, DragReference);
  #endif
  
***************
*** 7098,7104 ****
  static pascal OSStatus mac_handle_window_event (EventHandlerCallRef,
                                                EventRef, void *);
  #endif
! void install_window_handler (WindowPtr);
  
  extern void init_emacs_passwd_dir ();
  extern int emacs_main (int, char **, char **);
--- 7085,7091 ----
  static pascal OSStatus mac_handle_window_event (EventHandlerCallRef,
                                                EventRef, void *);
  #endif
! OSErr install_window_handler (WindowPtr);
  
  extern void init_emacs_passwd_dir ();
  extern int emacs_main (int, char **, char **);
***************
*** 7659,7674 ****
    x_real_positions (f, &f->left_pos, &f->top_pos);
  }
  
- #if TARGET_API_MAC_CARBON
- /* Initialize Drag And Drop to allow files to be dropped onto emacs frames */
- static OSErr
- init_mac_drag_n_drop ()
- {
-   OSErr result = InstallReceiveHandler (mac_do_receive_drag, 0L, NULL);
-   return result;
- }
- #endif
- 
  /* Intialize AppleEvent dispatcher table for the required events.  */
  void
  init_required_apple_events ()
--- 7646,7651 ----
***************
*** 7909,7918 ****
  #endif        /* USE_CARBON_EVENTS */
  
  
! void
  install_window_handler (window)
       WindowPtr window;
  {
  #if USE_CARBON_EVENTS
    EventTypeSpec specs[] = {{kEventClassWindow, kEventWindowBoundsChanging}};
    static EventHandlerUPP handle_window_event_UPP = NULL;
--- 7886,7896 ----
  #endif        /* USE_CARBON_EVENTS */
  
  
! OSErr
  install_window_handler (window)
       WindowPtr window;
  {
+   OSErr err = noErr;
  #if USE_CARBON_EVENTS
    EventTypeSpec specs[] = {{kEventClassWindow, kEventWindowBoundsChanging}};
    static EventHandlerUPP handle_window_event_UPP = NULL;
***************
*** 7920,7928 ****
    if (handle_window_event_UPP == NULL)
      handle_window_event_UPP = NewEventHandlerUPP (mac_handle_window_event);
  
!   InstallWindowEventHandler (window, handle_window_event_UPP,
!                            GetEventTypeCount (specs), specs, NULL, NULL);
  #endif
  }
  
  
--- 7898,7914 ----
    if (handle_window_event_UPP == NULL)
      handle_window_event_UPP = NewEventHandlerUPP (mac_handle_window_event);
  
!   err = InstallWindowEventHandler (window, handle_window_event_UPP,
!                                  GetEventTypeCount (specs), specs,
!                                  NULL, NULL);
! #endif
! #if TARGET_API_MAC_CARBON
!   if (err == noErr)
!     err = InstallTrackingHandler (mac_do_track_drag, window, NULL);
!   if (err == noErr)
!     err = InstallReceiveHandler (mac_do_receive_drag, window, NULL);
  #endif
+   return err;
  }
  
  
***************
*** 8004,8011 ****
                                        fs.name) &&
                mac_to_posix_pathname (path_name, unix_path_name, 255))
  #endif
!             drag_and_drop_file_list = Fcons (build_string (unix_path_name),
!                                              drag_and_drop_file_list);
          }
        }
    }
--- 7990,8000 ----
                                        fs.name) &&
                mac_to_posix_pathname (path_name, unix_path_name, 255))
  #endif
!             /* x-dnd functions expect undecoded filenames.  */
!             drag_and_drop_file_list =
!               Fcons (make_unibyte_string (unix_path_name,
!                                           strlen (unix_path_name)),
!                      drag_and_drop_file_list);
          }
        }
    }
***************
*** 8022,8027 ****
--- 8011,8077 ----
  
  #if TARGET_API_MAC_CARBON
  static pascal OSErr
+ mac_do_track_drag (DragTrackingMessage message, WindowPtr window,
+                  void *handlerRefCon, DragReference theDrag)
+ {
+   static int can_accept;
+   short items;
+   short index;
+   ItemReference theItem;
+   FlavorFlags theFlags;
+   OSErr result;
+ 
+   switch (message)
+     {
+     case kDragTrackingEnterHandler:
+       CountDragItems (theDrag, &items);
+       can_accept = 1;
+       for (index = 1; index <= items; index++)
+       {
+         GetDragItemReferenceNumber (theDrag, index, &theItem);
+         result = GetFlavorFlags (theDrag, theItem, flavorTypeHFS, &theFlags);
+         if (result != noErr)
+           {
+             can_accept = 0;
+             break;
+           }
+       }
+       break;
+ 
+     case kDragTrackingEnterWindow:
+       if (can_accept)
+       {
+         RgnHandle hilite_rgn = NewRgn ();
+         Rect r;
+ 
+         GetWindowPortBounds (window, &r);
+         OffsetRect (&r, -r.left, -r.top);
+         RectRgn (hilite_rgn, &r);
+         ShowDragHilite (theDrag, hilite_rgn, true);
+         DisposeRgn (hilite_rgn);
+         SetThemeCursor (kThemeCopyArrowCursor);
+       }
+       break;
+ 
+     case kDragTrackingInWindow:
+       break;
+ 
+     case kDragTrackingLeaveWindow:
+       if (can_accept)
+       {
+         HideDragHilite (theDrag);
+         SetThemeCursor (kThemeArrowCursor);
+       }
+       break;
+ 
+     case kDragTrackingLeaveHandler:
+       break;
+     }
+ 
+   return noErr;
+ }
+ 
+ static pascal OSErr
  mac_do_receive_drag (WindowPtr window, void *handlerRefCon,
                     DragReference theDrag)
  {
***************
*** 8062,8072 ****
                                      data.fileSpec.parID, data.fileSpec.name) 
&&
              mac_to_posix_pathname (path_name, unix_path_name, 255))
  #endif
!             drag_and_drop_file_list = Fcons (build_string (unix_path_name),
!                                            drag_and_drop_file_list);
        }
        else
!       return;
      }
    /* If there are items in the list, construct an event and post it to
       the queue like an interrupt using kbd_buffer_store_event.  */
--- 8112,8125 ----
                                      data.fileSpec.parID, data.fileSpec.name) 
&&
              mac_to_posix_pathname (path_name, unix_path_name, 255))
  #endif
!           /* x-dnd functions expect undecoded filenames.  */
!             drag_and_drop_file_list =
!             Fcons (make_unibyte_string (unix_path_name,
!                                         strlen (unix_path_name)),
!                    drag_and_drop_file_list);
        }
        else
!       continue;
      }
    /* If there are items in the list, construct an event and post it to
       the queue like an interrupt using kbd_buffer_store_event.  */
***************
*** 8075,8086 ****
        struct input_event event;
        Lisp_Object frame;
        struct frame *f = mac_window_to_frame (window);
!       SetPortWindowPort (window);
        GlobalToLocal (&mouse);
  
        event.kind = DRAG_N_DROP_EVENT;
        event.code = 0;
!       event.modifiers = 0;
        event.timestamp = TickCount () * (1000 / 60);
        XSETINT (event.x, mouse.h);
        XSETINT (event.y, mouse.v);
--- 8128,8141 ----
        struct input_event event;
        Lisp_Object frame;
        struct frame *f = mac_window_to_frame (window);
!       SInt16 modifiers;
! 
        GlobalToLocal (&mouse);
+       GetDragModifiers (theDrag, NULL, NULL, &modifiers);
  
        event.kind = DRAG_N_DROP_EVENT;
        event.code = 0;
!       event.modifiers = mac_to_emacs_modifiers (modifiers);
        event.timestamp = TickCount () * (1000 / 60);
        XSETINT (event.x, mouse.h);
        XSETINT (event.y, mouse.v);
***************
*** 8095,8101 ****
--- 8150,8160 ----
        GetCurrentProcess (&psn);
        SetFrontProcess (&psn);
        }
+ 
+       return noErr;
      }
+   else
+     return dragNotAcceptedErr;
  }
  #endif
  
***************
*** 9580,9587 ****
  #if TARGET_API_MAC_CARBON
    init_required_apple_events ();
  
-   init_mac_drag_n_drop ();
- 
  #if USE_CARBON_EVENTS
    init_service_handler ();
  
--- 9639,9644 ----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]