Skip to content

Commit 2a2ff3a

Browse files
committed
vwatch doesn't work with it :(
1 parent 406afbf commit 2a2ff3a

File tree

4 files changed

+67
-20
lines changed

4 files changed

+67
-20
lines changed

.gitignore

+21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
11
wm
22
wm.exe
3+
34
global
45
global.exe
6+
7+
untitled
8+
untitled.exe
9+
10+
wm.vwatch.bas
11+
wm.vwatch
12+
wm.vwatch.exe
13+
14+
global.vwatch.bas
15+
global.vwatch
16+
global.vwatch.exe
17+
18+
direntry.h
19+
timers.h
20+
vwatch
21+
vwatch.bas
22+
23+
qb64
24+
internal/
25+
source/

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# qb-wm
2+
23
A (very basic <sup><small>no pun intended</small></sup>) window manager, written in [QB64](https://qb64.org)
34

4-
![gif of it doin stuff](https://raw.githubusercontent.com/all-other-usernames-were-taken/all-other-usernames-were-taken/main/files/qb-wm.gif)
5+
<img src="https://raw.githubusercontent.com/all-other-usernames-were-taken/all-other-usernames-were-taken/main/files/qb-wm.gif" alt="gif of it doin stuff" data-align="center">
56

67
Due to QB64 restrictions, it does not currently support X/Wayland/etc. However, I do intend to make a *thing* that can interface to programs using QB64's TCP functionality, but that would be in the far future. As it stands now, it's merely a proof-of-concept, and not practical by any means.
78

@@ -10,6 +11,7 @@ If you want to contribute, I will happily allow it. I don't have alot of time on
1011
---
1112

1213
## Usage
14+
1315
Simply open `wm.bas` in the [QB64 IDE](https://github.com/QB64Team/qb64/releases/), and press <kbd>F5</kbd> to compile and run!
1416

1517
<br />
@@ -25,11 +27,12 @@ Controls are:
2527
- Click and drag to move a window,
2628
- click a window's titlebar to get it's focus,
2729
- right click and drag to resize,
28-
- when the log window is in focus, pressing <kbd>Shift</kbd>+<kbd>=</kpd> spawns a new window,
30+
- when the log window is in focus, pressing <kbd>Shift</kbd>+<kbd>=</kbd> spawns a new window,
2931
- pressing <kbd>Space</kbd> while left-clicking the title bar opens a context menu, that when clicked, closes the selected window, and
3032
- the "Text editor" window is a simple text editor, as the name implies.
3133

3234
---
3335

3436
## Compiling
37+
3538
It requires using at least version 1.4 of [QB64](https://qb64.org) to compile, because `$NOPREFIX` is not available in versions earlier than that.

global.bh

+20-6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Type winType 'Window type definition. QB64 is not object-oriented, so we have to
1515

1616
End Type
1717

18+
'Constants
19+
Const True = -1
20+
Const False = 0
1821

1922
'Initialize variables
2023
Rem $Dynamic
@@ -45,12 +48,22 @@ __image_Background = LoadImage("images/back.png", 32)
4548
__image_Screen = NewImage(640, 480, 32)
4649

4750
'...and the FONTs
48-
__font_Header = LoadFont("/usr/share/fonts/truetype/ubuntu/Ubuntu-B.ttf", 14)
49-
__font_Body = LoadFont("/usr/share/fonts/truetype/ubuntu/Ubuntu-L.ttf", 12)
50-
__font_Mono = LoadFont("/usr/share/fonts/truetype/ubuntu/UbuntuMono-R.ttf", 12, "DONTBLEND")
51-
52-
__font_Serif = LoadFont("/usr/share/fonts/truetype/liberation/LiberationSerif-Regular.ttf", 12)
53-
__font_Sans = LoadFont("/usr/share/fonts/truetype/ubuntu/Ubuntu-R.ttf", 12)
51+
$If LINUX Then
52+
__font_Header = LoadFont("/usr/share/fonts/truetype/ubuntu/Ubuntu-B.ttf", 14)
53+
__font_Body = LoadFont("/usr/share/fonts/truetype/ubuntu/Ubuntu-L.ttf", 12)
54+
__font_Mono = LoadFont("/usr/share/fonts/truetype/ubuntu/UbuntuMono-R.ttf", 12, "DONTBLEND")
55+
56+
__font_Serif = LoadFont("/usr/share/fonts/truetype/liberation/LiberationSerif-Regular.ttf", 12)
57+
__font_Sans = LoadFont("/usr/share/fonts/truetype/ubuntu/Ubuntu-R.ttf", 12)
58+
$Else
59+
'TODO: integrate Windows & MacOS fonts
60+
__font_Header = 16
61+
__font_Body = 14
62+
__font_Mono = 14
63+
64+
__font_Serif = 14
65+
__font_Sans = 14
66+
$End If
5467

5568
__screenFont = __font_Header
5669

@@ -81,6 +94,7 @@ __template_WinOptions.FH = __font_Body
8194

8295
'Initialize the WinOptions template's contents
8396
Dest __template_WinOptions.IH
97+
Font __template_WinOptions.FH
8498
PrintString (0, 0), "Close"
8599

86100

wm.bas

+21-12
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,20 @@ Do
5353
5454
Case win_Cat 'Text editor window
5555
If w(win_Cat).Z = 0 Then
56-
Select Case __inKey '__inKey is updated when upd is called.
57-
Case Chr$(8): win_Cat_Text = Left$(win_Cat_Text, Len(win_Cat_Text) - 1) 'backspace
58-
Case Else: win_Cat_Text = win_Cat_Text + __inKey 'Append keypress to window
59-
End Select
6056
61-
If (w(win).W > 8) And (w(win).H > 8) Then
62-
FreeImage w(win).IH 'Resize the window. Not required every frame, but it should be fine.
63-
w(win).IH = NewImage(w(win).W, w(win).H, 32)
64-
Font w(win).FH, w(win).IH
65-
End If
57+
Do Until __inKey = ""
58+
Select Case __inKey '__inKey is updated when upd is called.
59+
Case Chr$(8): win_Cat_Text = Left$(win_Cat_Text, Len(win_Cat_Text) - 1) 'backspace
60+
Case Else: win_Cat_Text = win_Cat_Text + __inKey 'Append keypress to window
61+
End Select
62+
__inKey = InKey$
63+
Loop
64+
65+
'If (w(win).W > 8) And (w(win).H > 8) Then
66+
' FreeImage w(win).IH 'Resize the window. Not required every frame, but it should be fine.
67+
' w(win).IH = NewImage(w(win).W, w(win).H, 32)
68+
' Font w(win).FH, w(win).IH
69+
'End If
6670
6771
Dest w(win_Cat).IH
6872
Print win_Cat_Text;
@@ -250,6 +254,7 @@ Sub updateMouse Static
250254
251255
Dim optMenu As Integer, optWin As Integer
252256
Dim mLockX As Single, mLockY As Single 'Or as I like to call it, mmmlocks and mmmlockie
257+
Dim mouseLatch As Bit
253258
254259
Dim win As Integer, i As Integer
255260
For win = UBound(winZOrder) To LBound(winZOrder) Step -1
@@ -270,14 +275,18 @@ Sub updateMouse Static
270275
grabFocus optMenu
271276
272277
optWin = i
278+
mouseLatch = True
273279
End If
274280
275-
ElseIf (MouseButton(1) Or MouseButton(2)) And (__focusedWindow <> i) Then
281+
ElseIf (MouseButton(1) Or MouseButton(2)) And (mouseLatch = False) Then
276282
grabFocus i
283+
mouseLatch = True
284+
285+
ElseIf (__focusedWindow = i) And (Not MouseButton(1)) Then mouseLatch = False
277286
End If
278287
279-
'ElseIf (mouseIsOver(i) = 0) And (MouseButton(1)) Then __focusedWindow = 0
280-
'ElseIf (mouseIsOver(i)) And (MouseButton(1)) Then grabFocus i
288+
Rem ElseIf (mouseIsOver(i) = false) And (MouseButton(1)) Then __focusedWindow = 0
289+
Rem ElseIf (mouseIsOver(i)) And (MouseButton(1)) Then grabFocus i
281290
End If
282291
283292

0 commit comments

Comments
 (0)