01 June 2017, 23:01 | #21 |
Registered User
Join Date: May 2017
Location: Silkeborg/Denmark
Posts: 22
|
Interesting ...
I now need to determine if a WA_BACKDROP/WLFG_BACKDROP flag is set for a window. |
02 June 2017, 12:24 | #22 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,351
|
No you don't, just check that window->Title isn't null (which is good practice for dealing with any pointers anyway, but especially when dealing with the OS, which often uses null as a a legitimate status or result).
|
02 June 2017, 14:02 | #23 | |
Registered User
Join Date: Oct 2012
Location: Germany
Posts: 585
|
Quote:
The checks I currently perform to filter out the Workbench Window are: NextWindow != NULL and NextWindow->Title!=0 (which should also be "NULL") I also tried NextWindow->Flags & WFLG_BACKDROP but that didn't work very well. Could you describe in more detail what you're trying to achieve? I started out to write a tool which places the active window in the largest free spot on screen - this is where I failed, because the "optimal algorithm" takes 60 seconds on a 060/50 and a FullHD screen, so a heuristic approach would be needed. Instead I created a solution for cascading, maximizing (full, half, quarter screen), minimizing and iconifying (layersV45) windows. Seems as if we could collaborate on this project, if you'd like to? |
|
02 June 2017, 16:21 | #24 |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 471
|
All Workbench windows have a special flag called WA_Workbenchwindow or similar. very easy to filter.
|
02 June 2017, 17:55 | #25 |
Registered User
Join Date: Oct 2012
Location: Germany
Posts: 585
|
|
03 June 2017, 00:16 | #26 |
Registered User
Join Date: May 2017
Location: Silkeborg/Denmark
Posts: 22
|
bubbob42: What I am aiming for is to produce is a tiling window manager with features like dwm or XMonad to name a few. I would also like some sort of status bar. I really have no idea if this is even possible with AmigaOS, but so far it has been fun trying. I plan to draw inspiration from two projects above on how to write tiling algorithms. Read more about tiling window managers here
There is windowtiler on aminet already, but no source code is available and I'd like to know how it is done. Generally speaking I prefer a keyboard controlled tiling wm, since I spend most of work time in a linux cli. bubbob42, if you're interested in tiling wm's, and WinZoom looks closely related, I'd like to collaborate, but I need to write some more C first. Eventually I will put what I produce on github, perhaps we can take it from there and see if our interests align? Concerning the window lister thing, I believe I have ironed out the problems pointed out by Thomas. I also found a workaround to Workbench Window/Backdrop problem. I've tried semi-hard to crash the program from different consoles, while running enforcer which gets no hit (is it enough to run it in a separate console?), and the program does not crash. Code:
#include <stdio.h> #include <string.h> #include <proto/intuition.h> int main(void) { struct Screen *screen; // Lock workbench screen if (screen = LockPubScreen("Workbench")) { struct Window *window; int winnr = 0; char *wintitle; // Loop through windows on screen for (window = screen->FirstWindow; window; window = window->NextWindow) { // Ignore Workbench window, also if its backdropped. if (!(window->Flags & BACKDROP) && (!stricmp(window->Title, "Workbench") == 0)) { if (!window->Title) { wintitle = "Unnamed Window"; } else { wintitle = window->Title; } printf("%s %d\n%s \"%s\"\n%s %4d\n%s %d\n%s %8d\n%s %8d\n", "Window:", winnr, "Title:", wintitle, "Width:", window->Width, "Height:", window->Height, "x:", window->LeftEdge, "y:", window->TopEdge); // Increment window id winnr++; } } // Unlock screen UnlockPubScreen(0, screen); } return 0; } |
03 June 2017, 00:48 | #27 | ||
Registered User
Join Date: Oct 2012
Location: Germany
Posts: 585
|
Quote:
However, it does not provide >2-column or row-tiling like some of the examples you provided. Quote:
Some hints (possible spoiler alert ) : - You will have to build and manage some kind of window list. I use exec lists for this purpose. - I recommend switching from console output to serial debug kprintf() via debug.lib. Why? Because if you're manipulating windows you did not open yourself, the Commodore way (check example windowtabbing Commodity from AmigaMail/NDK) goes like this: Code:
ilock = LockIBase(0L); /* lock intuition base */ /* update your window list here, especially check if target window still exists */ Forbid(); /* kill Multitasking */ UnlockIBase(ilock); /* manipulate the window structure */ Permit(); /* enable Multitasking */ |
||
03 June 2017, 11:13 | #28 |
Registered User
Join Date: May 2017
Location: Silkeborg/Denmark
Posts: 22
|
Looks like valuable advice bubbob42! Thank you.
Which led me to this: https://fs-uae.net/docs/serial-port Great. (I do have a working A1200, but I use fs-uae for testing) |
04 June 2017, 03:31 | #29 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,338
|
Do note that other windows may also have null titles, e.g. requesters and toolbars.
|
04 June 2017, 17:26 | #30 |
Registered User
Join Date: Sep 2014
Location: Poland
Posts: 175
|
|
08 July 2017, 00:22 | #31 |
Registered User
Join Date: May 2017
Location: Silkeborg/Denmark
Posts: 22
|
The last couple of weeks I have dived deeper in to C on the Amiga and it has been fun!
As a way to get more familiar with intuition and how windows are handled within this framework I have expanded the window lister program quite a bit and refactored it. It now includes a check for (IMO relevant) intuition window flags and automatic padding and sizing, based on the console width, for the output table. Code: https://github.com/RasmusEdgar/amiga.../wlist/wlist.c (I tried to post the code here with code tags, but it somehow gets mangled up) The code compiles cleanly with both SAS/C Code:
mkmk smake Code:
gcc wlist.c -o wlist -Werror -Wall -s -noixemul Critical feedback is welcome. Br, edmayn |
08 July 2017, 00:57 | #32 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,039
|
General c/c++ suggestions:
Code:
char *wintitle, bd[3], ac[3], bl[3], wb[3], gz[3], zo[3]; strcpy(ac, "/ac"); strcpy(bl, "/bl"); strcpy(wb, "/wb"); strcpy(gz, "/gz"); strcpy(zo, "/zo"); strcat(flags, zo); if (!wininfos) { free(miscinfo); // <= missing, memory leak printf("Failed to create window array of structs! Exiting.\n"); return 1; } if ((printer = printwindows(wininfos, miscinfo)) != 0) { free(miscinfo); // <= missing, memory leak free(wininfos); // <= missing, memory leak printf("Failed to print windows! Exiting.\n"); return 1; } Use strncat instead of strcat to be on the safe(r) side. Try to use a little different code structure that makes it easier to clean-up partially allocated/initialized stuff. For example, set all pointers/handles/etc. to null/0/..., then at the end, regardless whether you managed to fully initialize everything or not, go through all of them and free/deinitialize those that aren't null/0. That way you also have one common exit point from a function, so it's easier to add new code (otherwise you have to do partial deallocs all over the place). Last edited by a/b; 08 July 2017 at 01:10. Reason: added more stuff |
08 July 2017, 21:28 | #33 |
Registered User
Join Date: May 2017
Location: Silkeborg/Denmark
Posts: 22
|
Thank you for the feedback a/b. Highly appreciated. Very valid points you raise. I'll look into fixing them the next couple of days.
|
22 October 2017, 12:58 | #34 |
Registered User
Join Date: May 2017
Location: Silkeborg/Denmark
Posts: 22
|
I fixed the problems several months ago, did some refactoring of the functions and changed the way I check for window flags. Forgot to update this thread.
You can find the finished code here: https://github.com/RasmusEdgar/amiga.../wlist/wlist.c |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How can I save window positions and sizes in Workbench? | Foebane | support.Apps | 6 | 10 April 2017 15:09 |
rawadf tool for manipulating extended ADFs | Redwood | News | 6 | 14 January 2010 23:23 |
Workbench 3.1 or 1.3 - changing windows | zygzak | New to Emulation or Amiga scene | 16 | 24 October 2009 18:11 |
Workbench On Windows | Oxygene | request.Apps | 28 | 29 September 2008 20:24 |
Window Wizard: How do I clean the windows? | mombasajoe | support.Games | 0 | 28 June 2008 22:25 |
|
|