Xfce Forum

Sub domains
 

You are not logged in.

#26 2022-01-21 13:32:03

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,025

Re: new windows always show up in current workspace

I see. I believe the existing settings are for already running applications that request a focus event - not for new running programs. My understanding is that new application startups in Xfce will always start on the current workspace.

You might be able to script something using wmctrl or xdotool that will first register the workspace that the launch command was issued at and then when the program is mapped (visible) move it to that workspace. This would work for apps that take some time to start, but necessarily be helpful for quick starting programs.

Proof of concept script:

#!/bin/bash 
# requires xdotool
# $1 is the app name
# $@ is the app name & parameters

ws=$(xdotool getactivewindow get_desktop_for_window)

# sleep 5

$@ &

while ! xdotool search $1; do sleep .1; done

xdotool search $1 set_desktop_for_window $ws

...make the script executable and call it like this:

SCRIPTNAME APP

...where SCRIPTNAME is the name you give the script and APP is the application you want to run.

Note: uncomment the "sleep 5" command if you want to test with a built-in delay so you can better see how it works with your xterm example.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#27 2022-01-24 09:10:21

peterdb
Member
Registered: 2022-01-18
Posts: 19

Re: new windows always show up in current workspace

Thanks. I was already afraid that some workaround script would be needed. I think that it would work well for starting a new application yourself. But for third-party applications that are running in a specific workspace and launch a new program/window after some time, it seems to get complicated.

Offline

#28 2022-01-24 11:24:43

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,025

Re: new windows always show up in current workspace

peterdb wrote:

But for third-party applications that are running in a specific workspace and launch a new program/window after some time, it seems to get complicated.

This is what those settings I've mentioned earlier should take care of - existing windows that raise themselves (through either urgency or new windows). Can you give an example of a program that does this? Something simple that I can try to replicate. You may have found a bug.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#29 2022-01-24 13:07:39

peterdb
Member
Registered: 2022-01-18
Posts: 19

Re: new windows always show up in current workspace

I experience this issue with Cadence Assembler/Explorer, but this is not a simple program. I will try to find a simple example.

Offline

#30 2022-01-24 14:24:42

peterdb
Member
Registered: 2022-01-18
Posts: 19

Re: new windows always show up in current workspace

I have copied/written a small C program that shows the issue. I do not know how to upload files here, so I just copy the code here:

file: newwindow.c

#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int main(void) {
   Display *d; 
   Window w;
   Window w2; 
   XEvent e;
   const char *msg = "Press a key!";
   const char *msg2 = "Alert!";
   int s;
 
   d = XOpenDisplay(NULL);
   if (d == NULL) {
      fprintf(stderr, "Cannot open display\n");
      exit(1);
   }   
 
   s = DefaultScreen(d);
   w = XCreateSimpleWindow(d, RootWindow(d, s), 10, 10, 100, 100, 1,
                           BlackPixel(d, s), WhitePixel(d, s));
   XSelectInput(d, w, ExposureMask | KeyPressMask);
   XMapWindow(d, w); 
 
   while (1) {
      XNextEvent(d, &e);
      if (e.type == Expose) {
         XFillRectangle(d, w, DefaultGC(d, s), 20, 20, 10, 10);
         XDrawString(d, w, DefaultGC(d, s), 10, 50, msg, strlen(msg));
      }   
      if (e.type == KeyPress)
         break;
   }   

   sleep(5);
 
   w2 = XCreateSimpleWindow(d, RootWindow(d, s), 10, 10, 200, 100, 1,                                                     
                           BlackPixel(d, s), WhitePixel(d, s));
   XSelectInput(d, w2, ExposureMask | KeyPressMask);
   XMapWindow(d, w2);
 
   while (1) {
      XNextEvent(d, &e);
      if (e.type == Expose) {
         XFillRectangle(d, w2, DefaultGC(d, s), 20, 20, 10, 10);
         XDrawString(d, w2, DefaultGC(d, s), 10, 50, msg2, strlen(msg2));
      }   
      if (e.type == KeyPress)
         break;
   }     
   XCloseDisplay(d);
   return 0;
}

Compile with:

gcc newwindow.c -L/usr/X11R6/lib -lX11

Run with: a.out
That shows a window, saying "Press a key". After pressing a key, then after 5 seconds the program will open another window with the text "Alert". Pressing a key again will close the application.
If you move to a different workspace after pressing a key (the first time) within the 5 seconds, the other window will open in the new workspace.

Offline

#31 2022-01-24 21:03:08

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,025

Re: new windows always show up in current workspace

Yeah, I'm seeing the same. Unless I'm misunderstanding that setting, I think it might be a bug. Perhaps you can create a bug report for this here.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#32 2022-01-28 08:17:03

peterdb
Member
Registered: 2022-01-18
Posts: 19

Re: new windows always show up in current workspace

Ok, I reported the issue but I got the feedback that that is not what that option is about, and that it is up to the application where to open new windows.

I have to say, if this is the case, then the concept of workspaces in xfce4 is not really what I expected when I started working with it. To me, a workspace is a confined area, separated from other workspaces, as if it were different desktops or so. But this is apparently not the case, and it seems you have to go through quite a bit of trouble to get the separate desktop experience.

Anyway, guess I will have to talk to the vendor of my application now...

Offline

#33 2022-01-28 11:21:06

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,025

Re: new windows always show up in current workspace

Olivier did mention devilspie as an option in that discussion. If the app is always on the same workspace, devilspie can force other child windows to open on the same workspace. Might be an option.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#34 2022-01-31 14:49:00

peterdb
Member
Registered: 2022-01-18
Posts: 19

Re: new windows always show up in current workspace

Yes, I might try devilspie. But it leads to other issues. I am no admin, so I cannot use yum to easily install it, so I have to manually download/install the required packages, so I need to figure out how to do that.

Offline

#35 2022-02-02 02:52:52

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 819

Re: new windows always show up in current workspace

peterdb wrote:

Ok, let's do a simple one. If I enter

sleep 5; xterm &

and immediately go to a different workspace, then the xterm pops up in the workspace where I am. I would like it to pop up in the workspace where I entered the command.

all the windows in the workspace where you entered the command are minimized by the window manager as a response to changing which workspace you want to view.  the workspace you changed to had its minimized windows re-exposed the way they previously were.  that's how the window manager fakes workspaces.  it looks like a workspace for the most part.  but a "workspace" is just a list of windows it keeps track of.

what is needed is a way to tell the window manager which "workspace" a new window belongs in if the window manager is designed to understand this.  i do not know the API details as i have never done any GUI programming.  i was a system/network administrator before retiring.

i currently have startup automation on my Xubuntu 18.04.6 laptop.  to launch a bunch of things in specific workspaces, my script switches to each workspace, waits for the switch to complete, launches the apps to go there, waits for them to be open, and moves on to the next workspace.  after everything is launched and open, it goes back to workspace 0 or 1.

i know of no way to launch an X app such as xlogo into any specific workspace other than the current workspace.

Last edited by Skaperen (2022-02-02 02:57:35)

Offline

#36 2022-02-02 10:46:17

peterdb
Member
Registered: 2022-01-18
Posts: 19

Re: new windows always show up in current workspace

What I want is pretty simple: tell the system that all the windows belonging to a specific application should be created in a specific workspace and stay there. My hope is that that utility devilspie will do the job, but I have to wait until the admin has installed that. Will post the experiences. Also talked to the vendor, but that will take time.

Offline

#37 2022-02-02 23:22:57

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 819

Re: new windows always show up in current workspace

peterdb wrote:

What I want is pretty simple: tell the system that all the windows belonging to a specific application should be created in a specific workspace and stay there. My hope is that that utility devilspie will do the job, but I have to wait until the admin has installed that. Will post the experiences. Also talked to the vendor, but that will take time.

maybe devilspie does not need root permissions.  either it tells the window manager what to do or what is requested or takes over as window manager, in part or in whole.  i don't see how any of that needs root permission.  if so, then the only need for the admin to do it is to make it available for all users.  unless it is poorly written, you should be able to install a private copy in your home directory and use it from there to get going sooner.

you are right that it is simple.  but the X API or window manager API may not have included the data fields to do this.  this is not Xfce specific.  maybe https://askubuntu.com/ would be a better place to ask.

Last edited by Skaperen (2022-02-02 23:24:05)

Offline

Board footer

Powered by FluxBB