about summary refs log tree commit diff stats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile26
1 files changed, 10 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index ccb9af7..74ef9ed 100644
--- a/Makefile
+++ b/Makefile
@@ -3,14 +3,12 @@
 
 include config.mk
 
-WMSRC = bar.c client.c draw.c event.c kb.c mouse.c util.c wm.c
-WMOBJ = ${WMSRC:.c=.o}
-MENSRC = menu.c draw.c util.c
-MENOBJ = ${MENSRC:.c=.o}
-MAN1 = gridwm.1 gridmenu.1
-BIN = gridwm gridmenu
-
-all: config gridwm gridmenu
+SRC = client.c draw.c event.c kb.c mouse.c util.c wm.c
+OBJ = ${SRC:.c=.o}
+MAN1 = gridwm.1 
+BIN = gridwm
+
+all: config gridwm
 	@echo finished
 
 config:
@@ -24,18 +22,14 @@ config:
 	@echo CC $<
 	@${CC} -c ${CFLAGS} $<
 
-${WMOBJ}: wm.h draw.h config.h util.h
-
-gridmenu: ${MENOBJ}
-	@echo LD $@
-	@${CC} -o $@ ${MENOBJ} ${LDFLAGS}
+${OBJ}: wm.h
 
-gridwm: ${WMOBJ}
+gridwm: ${OBJ}
 	@echo LD $@
-	@${CC} -o $@ ${WMOBJ} ${LDFLAGS}
+	@${CC} -o $@ ${OBJ} ${LDFLAGS}
 
 clean:
-	rm -f gridwm gridmenu *.o core
+	rm -f gridwm *.o core
 
 dist: clean
 	mkdir -p gridwm-${VERSION}
22-05-22 18:27:48 -0700 committer Kartik K. Agaram <vc@akkartik.com> 2022-05-22 18:29:52 -0700 basic test-enabled framework' href='/akkartik/view.love/commit/keychord.lua?id=f421e1daa52a52956f40b3ee6d8b527ba1c30d5a'>f421e1d ^
9df1c3f ^




4aa2003 ^
3b4daca ^
4aa2003 ^

3b4daca ^
4aa2003 ^

3b4daca ^
f4235a1 ^

3b4daca ^
f4235a1 ^
4aa2003 ^



0fab1b4 ^
1326914 ^
3b4daca ^
a6ab7a2 ^

d441f8a ^
9e17337 ^
d441f8a ^


9e17337 ^
d441f8a ^


9e17337 ^
d441f8a ^

3b4daca ^
9e17337 ^
d441f8a ^

84875f3 ^



9df1c3f ^































a6ab7a2 ^


e1c5a42 ^










a6ab7a2 ^












0fab1b4 ^
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120

                  

                                                                                  
                                                
                                    
                                              
          

                                                            
                                                     

   
                                   




                                                                  
                   
                         

                         
                        

                         
                          

                                                                       
                        
                         



                      
 
                                
                                                                                

   
                        
                                                       


                       
                                                     


                         
                                                         

   
                       
                                                     

   



                                                                                              































                                                                                     


                              










                                  












                           
   
-- Keyboard driver

Modifiers = {'lctrl', 'rctrl', 'lalt', 'ralt', 'lshift', 'rshift', 'lgui', 'rgui'}

function App.keypressed(key, scancode, isrepeat)
  if array.find(Modifiers, key) then
    -- do nothing when the modifier is pressed
    return
  end
  -- include the modifier(s) when the non-modifer is pressed
  App.keychord_press(App.combine_modifiers(key), key)
end

function App.combine_modifiers(key)
  if love.keyboard.isModifierActive then  -- waiting for LÖVE v12
    if key:match('^kp') then
      key = App.translate_numlock(key)
    end
  end
  local result = ''
  if App.ctrl_down() then
    result = result..'C-'
  end
  if App.alt_down() then
    result = result..'M-'
  end
  if App.shift_down() then
    result = result..'S-'  -- don't try to use this with letters/digits
  end
  if App.cmd_down() then
    result = result..'s-'
  end
  result = result..key
  return result
end

function App.any_modifier_down()
  return App.ctrl_down() or App.alt_down() or App.shift_down() or App.cmd_down()
end

function App.ctrl_down()
  return App.key_down('lctrl') or App.key_down('rctrl')
end

function App.alt_down()
  return App.key_down('lalt') or App.key_down('ralt')
end

function App.shift_down()
  return App.key_down('lshift') or App.key_down('rshift')
end

function App.cmd_down()
  return App.key_down('lgui') or App.key_down('rgui')
end

function App.is_cursor_movement(key)
  return array.find({'left', 'right', 'up', 'down', 'home', 'end', 'pageup', 'pagedown'}, key)
end

-- mappings only to non-printable keys; leave out mappings that textinput will handle
Numlock_off = {
  kp0='insert',
  kp1='end',
  kp2='down',
  kp3='pagedown',
  kp4='left',
  -- numpad 5 translates to nothing
  kp6='right',
  kp7='home',
  kp8='up',
  kp9='pageup',
  ['kp.']='delete',
  -- LÖVE handles keypad operators in textinput
  -- what's with the `kp=` and `kp,` keys? None of my keyboards have one.
  -- Hopefully LÖVE handles them as well in textinput.
  kpenter='enter',
  kpdel='delete',
}
Numlock_on = {
  kpenter='enter',
  kpdel='delete',
}
function App.translate_numlock(key)
  if love.keyboard.isModifierActive('numlock') then
    return Numlock_on[key] or key
  else
    return Numlock_off[key] or key
  end
  return key
end

array = {}

function array.find(arr, elem)
  if type(elem) == 'function' then
    for i,x in ipairs(arr) do
      if elem(x) then
        return i
      end
    end
  else
    for i,x in ipairs(arr) do
      if x == elem then
        return i
      end
    end
  end
  return nil
end

function array.any(arr, f)
  for i,x in ipairs(arr) do
    local result = f(x)
    if result then
      return result
    end
  end
  return false
end