Custon pop out window appearing in wrong place

Hi. I’m extremely new to coding so any help would be appreciated. Basically I’m trying to create an addon to take my longer actions and turn them into small actions by deleting the keyframes that I don’t need. I was able to get the addon pretty much done, but am having trouble getting the pop up window to behave correctly. See, I created a panel for the toolshelf, where it works just fine, but it also pops up when I click in the area for the markers(like in the bottom of the timeline/dopesheet area). Here is the code if anybody can help a lost and frustrated guy out.

bl_info = {
    "name": "Create Action",
    "author": "",
    "version": (0, 6),
    "blender": (2, 80, 0),
    "location": "View3D > Toolshelf > Marker Select",
    "description": "",
    "category": "Animation"

import bpy
from bpy import ops

#filepath = "//actions.blend"


class MarkerSelect(bpy.types.Operator):
    """Marker Select"""
    bl_idname = ""
    bl_label = "Set Action Range"
    bl_options = {'REGISTER', 'UNDO'}
    #rename_action = bpy.props.StringProperty(name="Action Name")
    start_marker: bpy.props.IntProperty(
        name="In Point",
        description="Set First Marker",
        min=0, max=300000,
    end_marker: bpy.props.IntProperty(
        name="Out Point",
        description="Set Second Marker",
        min=1, max=300000,
    def invoke(self, context, _event):
        wm = context.window_manager
        return wm.invoke_props_dialog(self)

    def poll(cls, context):
        return context.active_object is not None
    # Create Markers
    def execute(self, context):
        scene = context.scene
        obj = bpy.context.object                                                 #active object
        action = obj.animation_data.action                                       #current action
        inPoint ='InPoint', frame=self.start_marker)
        outPoint ='OutPoint', frame=self.end_marker)     #Add markers

        area = bpy.context.area                                                 #Set area to dopesheet
        old_type = area.type
        area.type = 'DOPESHEET_EDITOR'
        ops.action.clickselect(deselect_all=True)                               #Deselect all keyframes
        area.type = old_type                                                     #Return area
        start = scene.timeline_markers.get("InPoint")
        if start:
        end = scene.timeline_markers.get("OutPoint")
        if start:
        for i in action.fcurves:
            for x in i.keyframe_points:
                if[0] > start.frame and[0] < end.frame:              #check greater than/less than marker frames
                    x.select_control_point=False                                 #deselect if in between markers
                    x.select_control_point=True                                   #select if outside of markers
        #Create New Action
        if action:
            print(                                                      #Grab current action name

        action_copy =[].copy()                          #Copy current action

        obj.animation_data.action = action_copy                                      #Set action to copy

        if action:
            print(                                                  #Grab action copy name

        old_name =
        copy_name =
        #new_name = 'heyhey'

        #for action in                                               #Set action copy name to new name
            #if[].name == copy_name:
      [].name = new_name

        ops.action.delete()                                        #Delete Inverted Keyframes
        #data_blocks = set([])
        #data_blocks = set(, data_blocks, fake_user=True)
        return {'FINISHED'}

class MarkersPanel(bpy.types.Panel):
    bl_label = "Action Manager"
    bl_idname = "mpanel"
    bl_space_type = "VIEW_3D"   
    bl_region_type = "UI"
    bl_category = "Act Man"
    bl_context = "objectmode"

    def draw(self, context):
        layout = self.layout

def register():
def unregister():
if __name__ == "__main__":