File: DaliClockWindow.m

package info (click to toggle)
xdaliclock 2.48-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 17,328 kB
  • sloc: ansic: 8,377; sh: 3,522; objc: 2,029; makefile: 1,220; java: 1,044; javascript: 802; asm: 419; xml: 337; perl: 269; ruby: 5
file content (74 lines) | stat: -rw-r--r-- 2,189 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* xdaliclock - a melting digital clock
* Copyright (c) 1991-2006 Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation.  No representations are made about the suitability of this
* software for any purpose.  It is provided "as is" without express or
* implied warranty.
*/

#import "DaliClockWindow.h"

@implementation DaliClockWindow

/* Normally borderless windows don't accept keyboard input.
   The only reason this subclass exists is to change this.
 */
- (BOOL)canBecomeKeyWindow
{
  return YES;
}


/* Called when a menu is popped down or when a keyboard equivalent is
   typed to determine whether that menu item is runnable.  We override
   this to make Close/Zoom/Minimize be enabled even when the window
   doesn't have those controls in the title bar because it is borderless.
 */
- (BOOL)validateMenuItem:(id)item
{
  SEL action = [item action];
  const char *name = sel_getName(action);
  if (!strcmp(name, "performClose:") ||         // handled here
      !strcmp(name, "performZoom:") ||          // handled here
      !strcmp(name, "performMiniaturize:")) {   // handled in AppController
    return YES;
  } else {
    return [super validateMenuItem:item];
  }
}


/* "Window / Close".
  We must implement this ourselves because the NSWindow version beeps
  when the window is borderless (and therefore has no "minimize" button).
 */
- (void)performClose:(id)sender
{
  [self close];
}

#if 0
/* "Window / Zoom", via FirstResponder.
  We must implement this ourselves because the NSWindow version beeps
  when the window is borderless (and therefore has no "minimize" button).
 */
- (void)performZoom:(id)sender
{
  printf("ZOOOM\n");
  [self zoom:sender];       // #### does nothing when borderless
}
#endif


/* This doesn't make the "Zoom" menu item be enabled for borderless windows...
 */
- (BOOL)windowShouldZoom:(NSWindow *)sender toFrame:(NSRect)newFrame
{
  return YES;
}

@end